diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-17 17:58:44 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-17 17:58:44 +0000 |
commit | a474b689914e38e7cd2f9c22ee7b8308cdeeb955 (patch) | |
tree | f36a66849cd90633fe90337652900ee305456923 /init/init.c | |
parent | 02a1c6a7c337334a171787a4dd84083029fd490f (diff) | |
download | busybox-w32-a474b689914e38e7cd2f9c22ee7b8308cdeeb955.tar.gz busybox-w32-a474b689914e38e7cd2f9c22ee7b8308cdeeb955.tar.bz2 busybox-w32-a474b689914e38e7cd2f9c22ee7b8308cdeeb955.zip |
init: fix compile-time error; fix exiting on broken config file
parse_config: cosmetics
Diffstat (limited to 'init/init.c')
-rw-r--r-- | init/init.c | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/init/init.c b/init/init.c index 3f16551ea..9637589ce 100644 --- a/init/init.c +++ b/init/init.c | |||
@@ -777,12 +777,10 @@ static void parse_inittab(void) | |||
777 | fclose(file); | 777 | fclose(file); |
778 | #else | 778 | #else |
779 | char *token[4]; | 779 | char *token[4]; |
780 | static const char actions[] ALIGN1 = { | 780 | /* order must correspond to SYSINIT..RESTART constants */ |
781 | "sysinit\0""respawn\0""askfirst\0""wait\0""once\0" | 781 | static const char actions[] ALIGN1 = |
782 | "ctrlaltdel\0""shutdown\0""restart\0" | 782 | "sysinit\0""respawn\0""askfirst\0""wait\0""once\0" |
783 | }; | 783 | "ctrlaltdel\0""shutdown\0""restart\0"; |
784 | enum {STR_SYSINIT=0, STR_RESPAWN, STR_ASKFIRST, STR_WAIT, STR_ONCE, | ||
785 | STR_CTRLALTDEL, STR_SHUTDOWN, STR_RESTART}; | ||
786 | 784 | ||
787 | parser_t *parser = config_open(INITTAB); | 785 | parser_t *parser = config_open(INITTAB); |
788 | /* No inittab file -- set up some default behavior */ | 786 | /* No inittab file -- set up some default behavior */ |
@@ -798,6 +796,7 @@ static void parse_inittab(void) | |||
798 | new_init_action(RESTART, "init", ""); | 796 | new_init_action(RESTART, "init", ""); |
799 | /* Askfirst shell on tty1-4 */ | 797 | /* Askfirst shell on tty1-4 */ |
800 | new_init_action(ASKFIRST, bb_default_login_shell, ""); | 798 | new_init_action(ASKFIRST, bb_default_login_shell, ""); |
799 | //TODO: VC_1 instead of ""? "" is console -> ctty problems -> angry users | ||
801 | new_init_action(ASKFIRST, bb_default_login_shell, VC_2); | 800 | new_init_action(ASKFIRST, bb_default_login_shell, VC_2); |
802 | new_init_action(ASKFIRST, bb_default_login_shell, VC_3); | 801 | new_init_action(ASKFIRST, bb_default_login_shell, VC_3); |
803 | new_init_action(ASKFIRST, bb_default_login_shell, VC_4); | 802 | new_init_action(ASKFIRST, bb_default_login_shell, VC_4); |
@@ -807,28 +806,25 @@ static void parse_inittab(void) | |||
807 | return; | 806 | return; |
808 | } | 807 | } |
809 | /* optional_tty:ignored_runlevel:action:command | 808 | /* optional_tty:ignored_runlevel:action:command |
810 | * i.e. 4 tokens, minimum number of tokens is 2 ("::sysinit:echo foo") | 809 | * Delims are not to be collapsed and need exactly 4 tokens |
811 | * We require tokens not to be collapsed -- need exactly 4 tokens. | ||
812 | */ | 810 | */ |
813 | while (config_read(parser, token, -4, 2, ":", '#') >= 0) { | 811 | while (config_read(parser, token, -4, 0, ":", '#') >= 0) { |
814 | int action = -1; | 812 | int action; |
815 | char *tty = token[0]; | 813 | char *tty = token[0]; |
816 | char *action_string = token[2]; | ||
817 | char *command = token[3]; | ||
818 | 814 | ||
819 | if (action_string) | 815 | if (!token[3]) /* less than 4 tokens */ |
820 | action = index_in_strings(actions, action_string); | ||
821 | if (action < 0 || !command || !strlen(command)) | ||
822 | goto bad_entry; | 816 | goto bad_entry; |
823 | if (tty) { | 817 | action = index_in_strings(actions, token[2]); |
824 | /* turn .*TTY -> /dev/TTY */ | 818 | if (action < 0 || !token[3][0]) /* token[3]: command */ |
825 | if (!strncmp(tty, "/dev/", 5)) | 819 | goto bad_entry; |
820 | /* turn .*TTY -> /dev/TTY */ | ||
821 | if (tty[0]) { | ||
822 | if (strncmp(tty, "/dev/", 5) == 0) | ||
826 | tty += 5; | 823 | tty += 5; |
827 | tty = concat_path_file("/dev/", tty); | 824 | tty = concat_path_file("/dev/", tty); |
828 | } else | 825 | } |
829 | tty = ""; /* XXX: ugh. */ | 826 | new_init_action(1 << action, token[3], tty); |
830 | new_init_action (1<<action, command, tty); | 827 | if (tty[0]) |
831 | if (ENABLE_FEATURE_CLEAN_UP) | ||
832 | free(tty); | 828 | free(tty); |
833 | continue; | 829 | continue; |
834 | bad_entry: | 830 | bad_entry: |