summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorDenys Vlasenko2017-07-22 01:47:19 +0200
committerDenys Vlasenko2017-07-22 01:47:19 +0200
commitc9e7843dde3555aea0318b01a428a47b35cf2df4 (patch)
treeae1730ada5d350d362796a867b935e0ed7433529 /miscutils
parentda2244fe48b7f1223427a4c1e91d86e398bbceb4 (diff)
downloadbusybox-c9e7843dde3555aea0318b01a428a47b35cf2df4.zip
busybox-c9e7843dde3555aea0318b01a428a47b35cf2df4.tar.gz
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>
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/crond.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/miscutils/crond.c b/miscutils/crond.c
index 6c54e1a..cf33230 100644
--- a/miscutils/crond.c
+++ b/miscutils/crond.c
@@ -153,6 +153,7 @@ struct globals {
const char *log_filename;
const char *crontab_dir_name; /* = CRONTABS; */
CronFile *cron_files;
+ char *default_shell;
#if SETENV_LEAKS
char *env_var_user;
char *env_var_home;
@@ -700,7 +701,7 @@ fork_job(const char *user, int mailFd, CronLine *line, bool run_sendmail)
goto err;
}
- shell = line->cl_shell ? line->cl_shell : DEFAULT_SHELL;
+ shell = line->cl_shell ? line->cl_shell : G.default_shell;
prog = run_sendmail ? SENDMAIL : shell;
set_env_vars(pas, shell);
@@ -846,7 +847,7 @@ static pid_t start_one_job(const char *user, CronLine *line)
}
/* Prepare things before vfork */
- shell = line->cl_shell ? line->cl_shell : DEFAULT_SHELL;
+ shell = line->cl_shell ? line->cl_shell : G.default_shell;
set_env_vars(pas, shell);
/* Fork as the user in question and run program */
@@ -1045,6 +1046,10 @@ int crond_main(int argc UNUSED_PARAM, char **argv)
reopen_logfile_to_stderr();
xchdir(G.crontab_dir_name);
+ /* $SHELL, or current UID's shell, or DEFAULT_SHELL */
+ /* Useful on Android where DEFAULT_SHELL /bin/sh may not exist */
+ G.default_shell = xstrdup(get_shell_name());
+
log8("crond (busybox "BB_VER") started, log level %d", G.log_level);
rescan_crontab_dir();
write_pidfile(CONFIG_PID_FILE_PATH "/crond.pid");