#include <utmp.h>
#include <ctype.h>
#include <stdarg.h>
+#include <sys/ttydefaults.h>
#include <sys/syslog.h>
#include <sys/time.h>
f = fdopen(fd, "r");
- if (get_cmd(f) != C_VER)
+ if (get_cmd(f) != C_VER) {
+ fclose(f);
return -1;
+ }
get_string(old_version, sizeof(old_version), f);
oops_error = 0;
for (pp = &family; (*pp = get_record(f)) != NULL; pp = &((*pp)->next))
rlim.rlim_cur = RLIM_INFINITY;
rlim.rlim_max = RLIM_INFINITY;
setrlimit(RLIMIT_CORE, &rlim);
- chdir("/");
+ if (0 != chdir("/"))
+ initlog(L_VB, "unable to chdir to /: %s",
+ strerror(errno));
signal(SIGSEGV, SIG_DFL);
raise(SIGSEGV);
/* Set ioctl settings to default ones */
console_stty();
- } else {
+ } else { /* parent */
+ int fd;
setsid();
- if ((f = console_open(O_RDWR|O_NOCTTY)) < 0) {
+ if ((fd = console_open(O_RDWR|O_NOCTTY)) < 0) {
initlog(L_VB, "open(%s): %s", console_dev,
strerror(errno));
- f = open("/dev/null", O_RDWR);
+ fd = open("/dev/null", O_RDWR);
}
- dup(f);
- dup(f);
+ dup(fd);
+ dup(fd);
}
/*
if (rlevel && strlen(rlevel) > 11)
strcpy(err, "rlevel field too long (max 11 characters)");
if (process && strlen(process) > 127)
- strcpy(err, "process field too long");
+ strcpy(err, "process field too long (max 127 characters)");
if (action && strlen(action) > 32)
strcpy(err, "action field too long");
if (err[0] != 0) {
if (!strchr("0123456789SsQqAaBbCcUu", argv[optind][0]))
usage(progname);
request.cmd = INIT_CMD_RUNLVL;
- request.runlevel = env ? 0 : argv[optind][0];
+ request.runlevel = argv[optind][0];
request.sleeptime = sltime;
}
/* Change to the root directory. */
- chdir("/");
+ if (0 != chdir("/"))
+ initlog(L_VB, "unable to chdir to /: %s",
+ strerror(errno));
/* Open the fifo and write a command. */
/* Make sure we don't hang on opening /dev/initctl */