From c9ca0a32745a43eaa6cb6b7b460718de8ccb84f2 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Mon, 18 Feb 2008 11:08:33 +0000 Subject: mount: recognize "dirsync" (closes bug 835) mount: sanitize environ if called by non-root *: adjust for slightly different sanitize routine --- miscutils/crontab.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'miscutils') diff --git a/miscutils/crontab.c b/miscutils/crontab.c index bc7f56a..6b68964 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; -- cgit v1.1