aboutsummaryrefslogtreecommitdiff
path: root/sbin/init/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/init/init.c')
-rw-r--r--sbin/init/init.c30
1 files changed, 12 insertions, 18 deletions
diff --git a/sbin/init/init.c b/sbin/init/init.c
index dd8800d21910..d28501053c7f 100644
--- a/sbin/init/init.c
+++ b/sbin/init/init.c
@@ -32,20 +32,6 @@
* SUCH DAMAGE.
*/
-#ifndef lint
-static const char copyright[] =
-"@(#) Copyright (c) 1991, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
-#if 0
-static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 7/15/93";
-#endif
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <sys/param.h>
#include <sys/boottrace.h>
#include <sys/ioctl.h>
@@ -63,6 +49,7 @@ static const char rcsid[] =
#include <fcntl.h>
#include <kenv.h>
#include <libutil.h>
+#include <mntopts.h>
#include <paths.h>
#include <signal.h>
#include <stdarg.h>
@@ -83,7 +70,6 @@ static const char rcsid[] =
#include <login_cap.h>
#endif
-#include "mntopts.h"
#include "pathnames.h"
/*
@@ -865,9 +851,9 @@ single_user(void)
const char *shell;
char *argv[2];
struct timeval tv, tn;
+ struct passwd *pp;
#ifdef SECURE
struct ttyent *typ;
- struct passwd *pp;
static const char banner[] =
"Enter root password, or ^D to go multi-user\n";
char *clear, *password;
@@ -899,6 +885,7 @@ single_user(void)
*/
open_console();
+ pp = getpwnam("root");
#ifdef SECURE
/*
* Check the root password.
@@ -906,7 +893,6 @@ single_user(void)
* it's the only tty that can be 'off' and 'secure'.
*/
typ = getttynam("console");
- pp = getpwnam("root");
if (typ && (typ->ty_status & TTY_SECURE) == 0 &&
pp && *pp->pw_passwd) {
write_stderr(banner);
@@ -923,7 +909,6 @@ single_user(void)
}
}
endttyent();
- endpwent();
#endif /* SECURE */
#ifdef DEBUGSHELL
@@ -944,6 +929,15 @@ single_user(void)
}
#endif /* DEBUGSHELL */
+ if (pp != NULL && pp->pw_dir != NULL && *pp->pw_dir != '\0' &&
+ chdir(pp->pw_dir) == 0) {
+ setenv("HOME", pp->pw_dir, 1);
+ } else {
+ chdir("/");
+ setenv("HOME", "/", 1);
+ }
+ endpwent();
+
/*
* Unblock signals.
* We catch all the interesting ones,