diff --git a/sbin/init/init.c b/sbin/init/init.c index a3cdcdcaa4c8..37125deb3477 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -506,7 +506,7 @@ has_securelevel(void) len = sizeof curlevel; if (sysctl(name, 2, &curlevel, &len, NULL, 0) == -1) { /* If it doesn't exist, it's okay. */ - if (errno == ENOENT) + if (errno == ENOENT) return 0; } return 1; @@ -716,18 +716,26 @@ single_user(void) #ifdef ALTSHELL (void)fprintf(stderr, "Enter pathname of shell or RETURN for %s: ", shell); + +// XXXNH doesn't work for me if (fgets(altshell, sizeof(altshell), stdin) == NULL) { altshell[0] = '\0'; +(void)fprintf(stderr, "altshell '%s' (true)\n", altshell); } else { +(void)fprintf(stderr, "altshell '%s' (false)\n", altshell); /* nuke \n */ char *p; if ((p = strchr(altshell, '\n')) != NULL) *p = '\0'; +(void)fprintf(stderr, "altshell '%s' (false 2) %d\n", altshell, __LINE__); } if (altshell[0]) shell = altshell; +(void)fprintf(stderr, "altshell '%s' %d\n", altshell, __LINE__); +(void)fprintf(stderr, " shell '%s' %d\n", shell, __LINE__); + #endif /* ALTSHELL */ /* @@ -745,9 +753,15 @@ single_user(void) argv[0] = "-sh"; argv[1] = 0; (void)setenv("PATH", INIT_PATH, 1); +(void)fprintf(stderr, " path '%s' %d\n", INIT_PATH, __LINE__); #ifdef ALTSHELL + argv[0] = shell; if (altshell[0]) argv[0] = altshell; + +(void)fprintf(stderr, "altshell '%s' %d\n", altshell, __LINE__); +(void)fprintf(stderr, " shell '%s' %d\n", shell, __LINE__); + (void)execv(shell, __UNCONST(argv)); emergency("can't exec `%s' for single user: %m", shell); argv[0] = "-sh"; @@ -798,11 +812,11 @@ single_user(void) if (WTERMSIG(status) == SIGKILL) { /* executed /sbin/reboot; wait for the end quietly */ sigset_t s; - + (void)sigfillset(&s); for (;;) (void)sigsuspend(&s); - } else { + } else { warning("single user shell terminated (%x), restarting", status); (void)sigaction(SIGTSTP, &satstp, NULL); @@ -977,7 +991,7 @@ start_session_db(void) return 1; } return 0; - + } /* @@ -1186,7 +1200,7 @@ read_ttys(void) if (stat(_PATH_WTMPX, &st) != -1 && st.st_size != 0) { struct timeval down_time; - TIMESPEC_TO_TIMEVAL(&down_time, + TIMESPEC_TO_TIMEVAL(&down_time, st.st_atime > st.st_mtime ? &st.st_atimespec : &st.st_mtimespec); make_utmpx("", DOWN_MSG, DOWN_TIME, 0, &down_time, 0); @@ -1495,7 +1509,7 @@ multi_user(void) /* * If the administrator has not set the security level to -1 * to indicate that the kernel should not run multiuser in secure - * mode, and the run script has not set a higher level of security + * mode, and the run script has not set a higher level of security * than level 1, then put the kernel into secure mode. */ if (getsecuritylevel() == 0) @@ -1723,7 +1737,7 @@ mfs_dev(void) (void)execl(INIT_BSHELL, "sh", access("./MAKEDEV", X_OK) == 0 ? "./MAKEDEV" : "/etc/MAKEDEV", - "-MM", "init", NULL); + "-MM", "init", NULL); _exit(10); /* NOTREACHED */