+ while (fgets(buf, INIT_BUFFS_SIZE, file) != NULL) {
+ static const char actions[] =
+ STR_SYSINIT "sysinit\0"
+ STR_RESPAWN "respawn\0"
+ STR_ASKFIRST "askfirst\0"
+ STR_WAIT "wait\0"
+ STR_ONCE "once\0"
+ STR_CTRLALTDEL "ctrlaltdel\0"
+ STR_SHUTDOWN "shutdown\0"
+ STR_RESTART "restart\0"
+ ;
+ char tmpConsole[CONSOLE_NAME_SIZE];
+ char *id, *runlev, *action, *command;
+ const char *a;
+
+ /* Skip leading spaces */
+ id = skip_whitespace(buf);
+ /* Skip the line if it's a comment */
+ if (*id == '#' || *id == '\n')
+ continue;
+ /* Trim the trailing '\n' */
+ *strchrnul(id, '\n') = '\0';
+
+ /* Line is: "id:runlevel_ignored:action:command" */
+ runlev = strchr(id, ':');
+ if (runlev == NULL /*|| runlev[1] == '\0' - not needed */)
+ goto bad_entry;
+ action = strchr(runlev + 1, ':');
+ if (action == NULL /*|| action[1] == '\0' - not needed */)
+ goto bad_entry;
+ command = strchr(action + 1, ':');
+ if (command == NULL || command[1] == '\0')
+ goto bad_entry;
+
+ *command = '\0'; /* action => ":action\0" now */
+ for (a = actions; a[0]; a += strlen(a) + 1) {
+ if (strcmp(a + 1, action + 1) == 0) {
+ *runlev = '\0';
+ if (*id != '\0') {
+ if (strncmp(id, "/dev/", 5) == 0)
+ id += 5;
+ strcpy(tmpConsole, "/dev/");
+ safe_strncpy(tmpConsole + 5, id,
+ sizeof(tmpConsole) - 5);
+ id = tmpConsole;
+ }
+ new_init_action((uint8_t)a[0], command + 1, id);
+ goto next_line;
+ }
+ }
+ *command = ':';
+ /* Choke on an unknown action */
+ bad_entry:
+ message(L_LOG | L_CONSOLE, "Bad inittab entry: %s", id);
+ next_line: ;