Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/utils/sysinst Adds a check to determine the root fil...



details:   https://anonhg.NetBSD.org/src/rev/e0c079a5e174
branches:  trunk
changeset: 779276:e0c079a5e174
user:      jdf <jdf%NetBSD.org@localhost>
date:      Tue May 15 15:50:58 2012 +0000

description:
Adds a check to determine the root filesystem for determining the path of the
rc.conf. Without, the menu would fail as it tried to `chroot ""` (target_root
returns "" for / as root).

diffstat:

 distrib/utils/sysinst/checkrc.c    |  10 +++++++---
 distrib/utils/sysinst/configmenu.c |  21 +++++++++++++++------
 2 files changed, 22 insertions(+), 9 deletions(-)

diffs (66 lines):

diff -r 8e02b714a0dc -r e0c079a5e174 distrib/utils/sysinst/checkrc.c
--- a/distrib/utils/sysinst/checkrc.c   Tue May 15 14:29:29 2012 +0000
+++ b/distrib/utils/sysinst/checkrc.c   Tue May 15 15:50:58 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: checkrc.c,v 1.1 2012/04/06 23:48:53 riz Exp $ */
+/* $NetBSD: checkrc.c,v 1.2 2012/05/15 15:50:58 jdf Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -84,8 +84,12 @@
 
        create_script(varname, filetocheck);
 
-       collect(T_OUTPUT, &buf, "chroot %s /bin/sh %s 2>&1", target_prefix(),
-           RC_CHECK_SCRIPT);
+       if (target_already_root())
+               collect(T_OUTPUT, &buf, "/bin/sh %s 2>&1", RC_CHECK_SCRIPT);
+       else
+               collect(T_OUTPUT, &buf, "chroot %s /bin/sh %s 2>&1",
+                               target_prefix(), RC_CHECK_SCRIPT);
+
 
        unlink(target_expand(RC_CHECK_SCRIPT));
 
diff -r 8e02b714a0dc -r e0c079a5e174 distrib/utils/sysinst/configmenu.c
--- a/distrib/utils/sysinst/configmenu.c        Tue May 15 14:29:29 2012 +0000
+++ b/distrib/utils/sysinst/configmenu.c        Tue May 15 15:50:58 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: configmenu.c,v 1.4 2012/04/30 19:57:52 riz Exp $ */
+/* $NetBSD: configmenu.c,v 1.5 2012/05/15 15:50:58 jdf Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -133,9 +133,14 @@
        if (buf != NULL)
                free(buf);
 
-       collect(T_OUTPUT, &buf,
-           "chroot %s /usr/bin/awk -F: '$1==\"root\" { print $NF; exit }'"
-           " /etc/passwd",target_prefix());
+       if (target_already_root())
+               collect(T_OUTPUT, &buf,
+                   "/usr/bin/awk -F: '$1==\"root\" { print $NF; exit }'"
+                   " /etc/passwd");
+       else
+               collect(T_OUTPUT, &buf,
+                   "chroot %s /usr/bin/awk -F: '$1==\"root\" { print $NF; exit }'"
+                   " /etc/passwd",target_prefix());
 
        config_list[CONFIGOPT_ROOTSH].setting = (const char *)buf;
 }
@@ -213,8 +218,12 @@
        char *buf;
        int rval;
 
-       collect(T_OUTPUT, &buf, "chroot %s getent passwd root | chroot %s cut -d: -f2",
-           target_prefix(), target_prefix());
+       if (target_already_root())
+               collect(T_OUTPUT, &buf, "getent passwd root | cut -d: -f2");
+       else
+               collect(T_OUTPUT, &buf, "chroot %s getent passwd root | "
+                   "chroot %s cut -d: -f2",
+                   target_prefix(), target_prefix());
 
        if (logfp)
                fprintf(logfp,"buf %s strlen(buf) %zu\n", buf, strlen(buf));



Home | Main Index | Thread Index | Old Index