Module Name:    src
Committed By:   jdf
Date:           Tue May 15 15:50:58 UTC 2012

Modified Files:
        src/distrib/utils/sysinst: checkrc.c configmenu.c

Log Message:
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).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/distrib/utils/sysinst/checkrc.c
cvs rdiff -u -r1.4 -r1.5 src/distrib/utils/sysinst/configmenu.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/distrib/utils/sysinst/checkrc.c
diff -u src/distrib/utils/sysinst/checkrc.c:1.1 src/distrib/utils/sysinst/checkrc.c:1.2
--- src/distrib/utils/sysinst/checkrc.c:1.1	Fri Apr  6 23:48:53 2012
+++ src/distrib/utils/sysinst/checkrc.c	Tue May 15 15:50:58 2012
@@ -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 @@ check(const char *varname, int filetoche
 
 	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));
 

Index: src/distrib/utils/sysinst/configmenu.c
diff -u src/distrib/utils/sysinst/configmenu.c:1.4 src/distrib/utils/sysinst/configmenu.c:1.5
--- src/distrib/utils/sysinst/configmenu.c:1.4	Mon Apr 30 19:57:52 2012
+++ src/distrib/utils/sysinst/configmenu.c	Tue May 15 15:50:58 2012
@@ -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 @@ get_rootsh(void)
 	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 @@ check_root_password(void)
 	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));

Reply via email to