aboutsummaryrefslogtreecommitdiff
path: root/miscutils/crontab.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-02-18 11:08:33 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-02-18 11:08:33 +0000
commitc9ca0a32745a43eaa6cb6b7b460718de8ccb84f2 (patch)
tree2b4bdf035b3a3c0436ce823e137d969af4d3a06f /miscutils/crontab.c
parent56244736ec7d0a3c338f542204aae83fb0200346 (diff)
downloadbusybox-c9ca0a32745a43eaa6cb6b7b460718de8ccb84f2.tar.gz
mount: recognize "dirsync" (closes bug 835)
mount: sanitize environ if called by non-root *: adjust for slightly different sanitize routine
Diffstat (limited to 'miscutils/crontab.c')
-rw-r--r--miscutils/crontab.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/miscutils/crontab.c b/miscutils/crontab.c
index bc7f56a22..6b6896469 100644
--- a/miscutils/crontab.c
+++ b/miscutils/crontab.c
@@ -97,7 +97,6 @@ int crontab_main(int argc, char **argv)
char *user_name; /* -u USER */
int fd;
int opt_ler;
- uid_t my_uid;
/* file [opts] Replace crontab from file
* - [opts] Replace crontab from stdin
@@ -118,25 +117,22 @@ int crontab_main(int argc, char **argv)
OPT_ler = OPT_l + OPT_e + OPT_r,
};
- my_uid = getuid();
-
opt_complementary = "?1:dr"; /* max one argument; -d implies -r */
opt_ler = getopt32(argv, "u:c:lerd", &user_name, &crontab_dir);
argv += optind;
- if (my_uid != geteuid()) { /* run by non-root? */
+ if (sanitize_env_if_suid()) { /* Clears dangerous stuff, sets PATH */
+ /* run by non-root? */
if (opt_ler & (OPT_u|OPT_c))
bb_error_msg_and_die("only root can use -c or -u");
- /* Clear dangerous stuff, set PATH */
- sanitize_env_for_suid();
}
if (opt_ler & OPT_u) {
pas = getpwnam(user_name);
if (!pas)
bb_error_msg_and_die("user %s is not known", user_name);
- my_uid = pas->pw_uid;
} else {
+ uid_t my_uid = getuid();
pas = getpwuid(my_uid);
if (!pas)
bb_perror_msg_and_die("no user record for UID %u",
@@ -144,7 +140,6 @@ int crontab_main(int argc, char **argv)
}
#define user_name DONT_USE_ME_BEYOND_THIS_POINT
-#define my_uid DONT_USE_ME_BEYOND_THIS_POINT
/* From now on, keep only -l, -e, -r bits */
opt_ler &= OPT_ler;