diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-22 01:47:19 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-07-22 01:47:19 +0200 |
commit | c9e7843dde3555aea0318b01a428a47b35cf2df4 (patch) | |
tree | ae1730ada5d350d362796a867b935e0ed7433529 | |
parent | da2244fe48b7f1223427a4c1e91d86e398bbceb4 (diff) | |
download | busybox-w32-c9e7843dde3555aea0318b01a428a47b35cf2df4.tar.gz busybox-w32-c9e7843dde3555aea0318b01a428a47b35cf2df4.tar.bz2 busybox-w32-c9e7843dde3555aea0318b01a428a47b35cf2df4.zip |
crond: allow $SHELL and starting user's shell override DEFAULT_SHELL. Closes 6458
function old new delta
crond_main 1134 1149 +15
fork_job 453 454 +1
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | miscutils/crond.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c index 6c54e1a8f..cf3323090 100644 --- a/miscutils/crond.c +++ b/miscutils/crond.c | |||
@@ -153,6 +153,7 @@ struct globals { | |||
153 | const char *log_filename; | 153 | const char *log_filename; |
154 | const char *crontab_dir_name; /* = CRONTABS; */ | 154 | const char *crontab_dir_name; /* = CRONTABS; */ |
155 | CronFile *cron_files; | 155 | CronFile *cron_files; |
156 | char *default_shell; | ||
156 | #if SETENV_LEAKS | 157 | #if SETENV_LEAKS |
157 | char *env_var_user; | 158 | char *env_var_user; |
158 | char *env_var_home; | 159 | char *env_var_home; |
@@ -700,7 +701,7 @@ fork_job(const char *user, int mailFd, CronLine *line, bool run_sendmail) | |||
700 | goto err; | 701 | goto err; |
701 | } | 702 | } |
702 | 703 | ||
703 | shell = line->cl_shell ? line->cl_shell : DEFAULT_SHELL; | 704 | shell = line->cl_shell ? line->cl_shell : G.default_shell; |
704 | prog = run_sendmail ? SENDMAIL : shell; | 705 | prog = run_sendmail ? SENDMAIL : shell; |
705 | 706 | ||
706 | set_env_vars(pas, shell); | 707 | set_env_vars(pas, shell); |
@@ -846,7 +847,7 @@ static pid_t start_one_job(const char *user, CronLine *line) | |||
846 | } | 847 | } |
847 | 848 | ||
848 | /* Prepare things before vfork */ | 849 | /* Prepare things before vfork */ |
849 | shell = line->cl_shell ? line->cl_shell : DEFAULT_SHELL; | 850 | shell = line->cl_shell ? line->cl_shell : G.default_shell; |
850 | set_env_vars(pas, shell); | 851 | set_env_vars(pas, shell); |
851 | 852 | ||
852 | /* Fork as the user in question and run program */ | 853 | /* Fork as the user in question and run program */ |
@@ -1045,6 +1046,10 @@ int crond_main(int argc UNUSED_PARAM, char **argv) | |||
1045 | 1046 | ||
1046 | reopen_logfile_to_stderr(); | 1047 | reopen_logfile_to_stderr(); |
1047 | xchdir(G.crontab_dir_name); | 1048 | xchdir(G.crontab_dir_name); |
1049 | /* $SHELL, or current UID's shell, or DEFAULT_SHELL */ | ||
1050 | /* Useful on Android where DEFAULT_SHELL /bin/sh may not exist */ | ||
1051 | G.default_shell = xstrdup(get_shell_name()); | ||
1052 | |||
1048 | log8("crond (busybox "BB_VER") started, log level %d", G.log_level); | 1053 | log8("crond (busybox "BB_VER") started, log level %d", G.log_level); |
1049 | rescan_crontab_dir(); | 1054 | rescan_crontab_dir(); |
1050 | write_pidfile(CONFIG_PID_FILE_PATH "/crond.pid"); | 1055 | write_pidfile(CONFIG_PID_FILE_PATH "/crond.pid"); |