Adds a check to determine the root filesystem for determining the path of the trunk
authorjdf <jdf@NetBSD.org>
Tue, 15 May 2012 15:50:58 +0000
branchtrunk
changeset 211100 4d8a9afbafa6
parent 211099 94c486f88002
child 211101 8c754515ca05
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).
distrib/utils/sysinst/checkrc.c
distrib/utils/sysinst/configmenu.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));
 
--- 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));