char *argv0; /* First arguments; show up in ps listing */
int maxproclen; /* Maximal length of argv[0] with \0 */
struct utmp utproto; /* Only used for sizeof(utproto.ut_id) */
-char *user_console = NULL; /* User console device */
char *console_dev; /* Console device. */
int pipe_fd = -1; /* /dev/initctl */
int did_boot = 0; /* Did we already do BOOT* stuff? */
int tried_vtmaster = 0;
char *s;
- if (user_console) {
- console_dev = user_console;
- } else if ((s = getenv("CONSOLE")) != NULL)
+ if ((s = getenv("CONSOLE")) != NULL)
console_dev = s;
else {
console_dev = CONSOLE;
/*
* Set pre and post processing
*/
- tty.c_iflag = IGNPAR|ICRNL|IXON|IXANY;
+ tty.c_iflag = IGNPAR|ICRNL|IXON|IXANY
+#ifdef IUTF8 /* Not defined on FreeBSD */
+ | (tty.c_iflag & IUTF8)
+#endif /* IUTF8 */
+ ;
tty.c_oflag = OPOST|ONLCR;
tty.c_lflag = ISIG|ICANON|ECHO|ECHOCTL|ECHOPRT|ECHOKE;
sigprocmask(SIG_SETMASK, &omask, NULL);
+ /*
+ * Update utmp/wtmp file prior to starting
+ * any child. This MUST be done right here in
+ * the child process in order to prevent a race
+ * condition that occurs when the child
+ * process' time slice executes before the
+ * parent (can and does happen in a uniprocessor
+ * environment). If the child is a getty and
+ * the race condition happens, then init's utmp
+ * update will happen AFTER the getty runs
+ * and expects utmp to be updated already!
+ *
+ * Do NOT log if process field starts with '+'
+ * FIXME: that's for compatibility with *very*
+ * old getties - probably it can be taken out.
+ */
+ if (ch->action == RESPAWN && ch->process[0] != '+')
+ write_utmp_wtmp("", ch->id, getpid(), INIT_PROCESS, "");
+
/*
* In sysinit, boot, bootwait or single user mode:
* for any wait-type subprocess we _force_ the console
case ONDEMAND:
case RESPAWN:
ch->flags |= RUNNING;
- if (spawn(ch, &(ch->pid)) < 0) break;
- /*
- * Do NOT log if process field starts with '+'
- * FIXME: that's for compatibility with *very*
- * old getties - probably it can be taken out.
- */
- if (ch->process[0] != '+')
- write_utmp_wtmp("", ch->id, ch->pid,
- INIT_PROCESS, "");
+ (void)spawn(ch, &(ch->pid));
break;
}
}
strncpy(ch->id, id, sizeof(utproto.ut_id) + 1); /* Hack for different libs. */
strncpy(ch->process, process, sizeof(ch->process) - 1);
if (rlevel[0]) {
- for(f = 0; f < sizeof(rlevel) - 1 && rlevel[f]; f++) {
+ for(f = 0; f < (int)sizeof(rlevel) - 1 && rlevel[f]; f++) {
ch->rlevel[f] = rlevel[f];
if (ch->rlevel[f] == 's') ch->rlevel[f] = 'S';
}
case INIT_CMD_SETENV:
initcmd_setenv(request.i.data, sizeof(request.i.data));
break;
- case INIT_CMD_CHANGECONS:
- if (user_console) {
- free(user_console);
- user_console = NULL;
- }
- if (!request.i.bsd.reserved[0])
- user_console = NULL;
- else
- user_console = strdup(request.i.bsd.reserved);
- console_init();
- quit = 1;
- break;
default:
initlog(L_VB, "got unimplemented initrequest.");
break;
char *p;
int f;
int isinit;
+#ifdef WITH_SELINUX
int enforce = 0;
+#endif
/* Get my own name */
if ((p = strrchr(argv[0], '/')) != NULL)
*/
isinit = (getpid() == 1);
for (f = 1; f < argc; f++) {
- if (!strcmp(argv[f], "-i") || !strcmp(argv[f], "--init"))
+ if (!strcmp(argv[f], "-i") || !strcmp(argv[f], "--init")) {
isinit = 1;
break;
+ }
}
if (!isinit) exit(telinit(p, argc, argv));