Error message consistency:
1. don't print the program name in the message [syslog does it] 2. no extraneous \n [syslog takes care of it] 3. quote strings as `%s' [we are using syslog] 4. use %m instead of error = %d
This commit is contained in:
parent
64d44756ee
commit
6accae529c
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: init.c,v 1.79 2006/09/23 18:57:26 he Exp $ */
|
||||
/* $NetBSD: init.c,v 1.80 2006/09/25 19:42:04 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n"
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)init.c 8.2 (Berkeley) 4/28/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: init.c,v 1.79 2006/09/23 18:57:26 he Exp $");
|
||||
__RCSID("$NetBSD: init.c,v 1.80 2006/09/25 19:42:04 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
@ -303,7 +303,7 @@ main(int argc, char **argv)
|
||||
runcom_mode = FASTBOOT;
|
||||
break;
|
||||
default:
|
||||
warning("unrecognized flag '-%c'", c);
|
||||
warning("unrecognized flag `%c'", c);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -533,7 +533,7 @@ setsecuritylevel(int newlevel)
|
||||
name[0] = CTL_KERN;
|
||||
name[1] = KERN_SECURELVL;
|
||||
if (sysctl(name, 2, NULL, NULL, &newlevel, sizeof newlevel) == -1) {
|
||||
emergency( "cannot change kernel security level from"
|
||||
emergency("cannot change kernel security level from"
|
||||
" %d to %d: %m", curlevel, newlevel);
|
||||
return;
|
||||
}
|
||||
@ -678,7 +678,7 @@ single_user(void)
|
||||
(void)memset(clear, 0, _PASSWORD_LEN);
|
||||
if (strcmp(password, pp->pw_passwd) == 0)
|
||||
break;
|
||||
warning("single-user login failed\n");
|
||||
warning("single-user login failed");
|
||||
}
|
||||
}
|
||||
endttyent();
|
||||
@ -721,11 +721,11 @@ single_user(void)
|
||||
if (altshell[0])
|
||||
argv[0] = altshell;
|
||||
(void)execv(shell, __UNCONST(argv));
|
||||
emergency("can't exec %s for single user: %m", shell);
|
||||
emergency("can't exec `%s' for single user: %m", shell);
|
||||
argv[0] = "-sh";
|
||||
#endif /* ALTSHELL */
|
||||
(void)execv(INIT_BSHELL, __UNCONST(argv));
|
||||
emergency("can't exec %s for single user: %m", INIT_BSHELL);
|
||||
emergency("can't exec `%s' for single user: %m", INIT_BSHELL);
|
||||
(void)sleep(STALL_TIMEOUT);
|
||||
_exit(1);
|
||||
}
|
||||
@ -734,7 +734,7 @@ single_user(void)
|
||||
/*
|
||||
* We are seriously hosed. Do our best.
|
||||
*/
|
||||
emergency("can't fork single-user shell, trying again");
|
||||
emergency("can't fork single-user shell: %m, trying again");
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0)
|
||||
continue;
|
||||
(void)sigaction(SIGTSTP, &satstp, NULL);
|
||||
@ -754,7 +754,7 @@ single_user(void)
|
||||
return (state_func_t)single_user;
|
||||
}
|
||||
if (wpid == pid && WIFSTOPPED(status)) {
|
||||
warning("init: shell stopped, restarting\n");
|
||||
warning("shell stopped, restarting");
|
||||
kill(pid, SIGCONT);
|
||||
wpid = -1;
|
||||
}
|
||||
@ -823,18 +823,18 @@ runetcrc(int trychroot)
|
||||
#ifdef CHROOT
|
||||
if (trychroot)
|
||||
if (chroot(rootdir) != 0) {
|
||||
warning("failed to chroot to %s, error: %m",
|
||||
warning("failed to chroot to `%s': %m",
|
||||
rootdir);
|
||||
_exit(1); /* force single user mode */
|
||||
}
|
||||
#endif /* CHROOT */
|
||||
|
||||
(void)execv(INIT_BSHELL, __UNCONST(argv));
|
||||
stall("can't exec %s for %s: %m", INIT_BSHELL, _PATH_RUNCOM);
|
||||
stall("can't exec `%s' for `%s': %m", INIT_BSHELL, _PATH_RUNCOM);
|
||||
_exit(1); /* force single user mode */
|
||||
/*NOTREACHED*/
|
||||
case -1:
|
||||
emergency("can't fork for %s on %s: %m", INIT_BSHELL,
|
||||
emergency("can't fork for `%s' on `%s': %m", INIT_BSHELL,
|
||||
_PATH_RUNCOM);
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0)
|
||||
continue;
|
||||
@ -853,12 +853,12 @@ runetcrc(int trychroot)
|
||||
if (wpid == -1) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
warning("wait for %s on %s failed: %m; going to "
|
||||
warning("wait for `%s' on `%s' failed: %m; going to "
|
||||
"single user mode", INIT_BSHELL, _PATH_RUNCOM);
|
||||
return (state_func_t)single_user;
|
||||
}
|
||||
if (wpid == pid && WIFSTOPPED(status)) {
|
||||
warning("init: %s on %s stopped, restarting\n",
|
||||
warning("`%s' on `%s' stopped, restarting",
|
||||
INIT_BSHELL, _PATH_RUNCOM);
|
||||
(void)kill(pid, SIGCONT);
|
||||
wpid = -1;
|
||||
@ -876,7 +876,7 @@ runetcrc(int trychroot)
|
||||
}
|
||||
|
||||
if (!WIFEXITED(status)) {
|
||||
warning("%s on %s terminated abnormally, going to "
|
||||
warning("`%s' on `%s' terminated abnormally, going to "
|
||||
"single user mode", INIT_BSHELL, _PATH_RUNCOM);
|
||||
return (state_func_t)single_user;
|
||||
}
|
||||
@ -1112,7 +1112,7 @@ setupargv(session_t *sp, struct ttyent *typ)
|
||||
return (0);
|
||||
sp->se_getty_argv = construct_argv(sp->se_getty);
|
||||
if (sp->se_getty_argv == NULL) {
|
||||
warning("can't parse getty for port %s", sp->se_device);
|
||||
warning("can't parse getty for port `%s'", sp->se_device);
|
||||
free(sp->se_getty);
|
||||
sp->se_getty = NULL;
|
||||
return (0);
|
||||
@ -1123,7 +1123,7 @@ setupargv(session_t *sp, struct ttyent *typ)
|
||||
sp->se_window = strdup(typ->ty_window);
|
||||
sp->se_window_argv = construct_argv(sp->se_window);
|
||||
if (sp->se_window_argv == NULL) {
|
||||
warning("can't parse window for port %s",
|
||||
warning("can't parse window for port `%s'",
|
||||
sp->se_device);
|
||||
free(sp->se_window);
|
||||
sp->se_window = NULL;
|
||||
@ -1177,7 +1177,7 @@ read_ttys(void)
|
||||
sessions = NULL;
|
||||
|
||||
if (start_session_db()) {
|
||||
warning("read_ttys: start_session_db failed, death\n");
|
||||
warning("start_session_db failed, death");
|
||||
#ifdef CHROOT
|
||||
/* If /etc/rc ran in chroot, we want to kill any survivors. */
|
||||
if (did_multiuser_chroot)
|
||||
@ -1211,7 +1211,7 @@ start_window_system(session_t *sp)
|
||||
sigset_t mask;
|
||||
|
||||
if ((pid = fork()) == -1) {
|
||||
emergency("can't fork for window system on port %s: %m",
|
||||
emergency("can't fork for window system on port `%s': %m",
|
||||
sp->se_device);
|
||||
/* hope that getty fails and we can try again */
|
||||
return;
|
||||
@ -1224,10 +1224,10 @@ start_window_system(session_t *sp)
|
||||
sigprocmask(SIG_SETMASK, &mask, NULL);
|
||||
|
||||
if (setsid() < 0)
|
||||
emergency("setsid failed (window) %m");
|
||||
emergency("setsid failed (window): %m");
|
||||
|
||||
(void)execv(sp->se_window_argv[0], sp->se_window_argv);
|
||||
stall("can't exec window system '%s' for port %s: %m",
|
||||
stall("can't exec window system `%s' for port `%s': %m",
|
||||
sp->se_window_argv[0], sp->se_device);
|
||||
_exit(1);
|
||||
}
|
||||
@ -1246,7 +1246,8 @@ start_getty(session_t *sp)
|
||||
* fork(), not vfork() -- we can't afford to block.
|
||||
*/
|
||||
if ((pid = fork()) == -1) {
|
||||
emergency("can't fork for getty on port %s: %m", sp->se_device);
|
||||
emergency("can't fork for getty on port `%s': %m",
|
||||
sp->se_device);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1257,7 +1258,7 @@ start_getty(session_t *sp)
|
||||
/* If /etc/rc did proceed inside chroot, we have to try as well. */
|
||||
if (did_multiuser_chroot)
|
||||
if (chroot(rootdir) != 0) {
|
||||
stall("can't chroot getty '%s' inside %s: %m",
|
||||
stall("can't chroot getty `%s' inside `%s': %m",
|
||||
sp->se_getty_argv[0], rootdir);
|
||||
_exit(1);
|
||||
}
|
||||
@ -1265,7 +1266,7 @@ start_getty(session_t *sp)
|
||||
|
||||
if (current_time > sp->se_started.tv_sec &&
|
||||
current_time - sp->se_started.tv_sec < GETTY_SPACING) {
|
||||
warning("getty repeating too quickly on port %s, sleeping",
|
||||
warning("getty repeating too quickly on port `%s', sleeping",
|
||||
sp->se_device);
|
||||
(void)sleep(GETTY_SLEEP);
|
||||
}
|
||||
@ -1279,7 +1280,7 @@ start_getty(session_t *sp)
|
||||
(void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *) 0);
|
||||
|
||||
(void)execv(sp->se_getty_argv[0], sp->se_getty_argv);
|
||||
stall("can't exec getty '%s' for port %s: %m",
|
||||
stall("can't exec getty `%s' for port `%s': %m",
|
||||
sp->se_getty_argv[0], sp->se_device);
|
||||
_exit(1);
|
||||
/*NOTREACHED*/
|
||||
@ -1320,7 +1321,7 @@ make_utmpx(const char *name, const char *line, int type, pid_t pid,
|
||||
(void)strncpy(ut.ut_id, line, sizeof(ut.ut_id));
|
||||
|
||||
if (pututxline(&ut) == NULL)
|
||||
warning("can't add utmpx record for port %s", ut.ut_line);
|
||||
warning("can't add utmpx record for `%s': %m", ut.ut_line);
|
||||
}
|
||||
|
||||
static char
|
||||
@ -1353,7 +1354,7 @@ utmpx_set_runlevel(char old, char new)
|
||||
ut.ut_exit.e_exit = old;
|
||||
ut.ut_exit.e_termination = new;
|
||||
if (pututxline(&ut) == NULL)
|
||||
warning("can't add utmpx record for runlevel");
|
||||
warning("can't add utmpx record for `runlevel': %m");
|
||||
}
|
||||
#endif /* SUPPORT_UTMPX */
|
||||
|
||||
@ -1496,7 +1497,7 @@ clean_ttys(void)
|
||||
if (sp) {
|
||||
sp->se_flags |= SE_PRESENT;
|
||||
if (sp->se_index != session_index) {
|
||||
warning("port %s changed utmp index from "
|
||||
warning("port `%s' changed utmp index from "
|
||||
"%d to %d", sp->se_device, sp->se_index,
|
||||
session_index);
|
||||
sp->se_index = session_index;
|
||||
@ -1510,7 +1511,7 @@ clean_ttys(void)
|
||||
}
|
||||
sp->se_flags &= ~SE_SHUTDOWN;
|
||||
if (setupargv(sp, typ) == 0) {
|
||||
warning("can't parse getty for port %s",
|
||||
warning("can't parse getty for port `%s'",
|
||||
sp->se_device);
|
||||
sp->se_flags |= SE_SHUTDOWN;
|
||||
if (sp->se_process != 0)
|
||||
@ -1795,7 +1796,7 @@ createsysctlnode()
|
||||
node.sysctl_num = CTL_CREATE;
|
||||
snprintf(node.sysctl_name, SYSCTL_NAMELEN, "init");
|
||||
if (sysctl(&mib[0], 1, &node, &len, &node, len) == -1) {
|
||||
warning("could not create init node, error = %d", errno);
|
||||
warning("could not create init node: %m");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@ -1815,7 +1816,7 @@ createsysctlnode()
|
||||
node.sysctl_num = CTL_CREATE;
|
||||
snprintf(node.sysctl_name, SYSCTL_NAMELEN, "root");
|
||||
if (sysctl(&mib[0], 2, NULL, NULL, &node, len) == -1) {
|
||||
warning("could not create init.root node, error = %d", errno);
|
||||
warning("could not create init.root node: %m");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
@ -1832,7 +1833,7 @@ shouldchroot()
|
||||
len = sizeof(struct sysctlnode);
|
||||
|
||||
if (sysctlbyname("init.root", rootdir, &len, NULL, 0) == -1) {
|
||||
warning("could not read init.root, error = %d", errno);
|
||||
warning("could not read init.root: %m");
|
||||
|
||||
/* Child killed our node. Recreate it. */
|
||||
if (errno == ENOENT) {
|
||||
|
Loading…
Reference in New Issue
Block a user