diff options
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/crontab.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/miscutils/crontab.c b/miscutils/crontab.c index 0444404..7d57095 100644 --- a/miscutils/crontab.c +++ b/miscutils/crontab.c @@ -17,22 +17,6 @@ #define CRONUPDATE "cron.update" #endif -static void change_user(const struct passwd *pas) -{ - xsetenv("USER", pas->pw_name); - xsetenv("HOME", pas->pw_dir); - xsetenv("SHELL", DEFAULT_SHELL); - - /* initgroups, setgid, setuid */ - change_identity(pas); - - if (chdir(pas->pw_dir) < 0) { - bb_perror_msg("chdir(%s) by %s failed", - pas->pw_dir, pas->pw_name); - xchdir("/tmp"); - } -} - static void edit_file(const struct passwd *pas, const char *file) { const char *ptr; @@ -46,7 +30,10 @@ static void edit_file(const struct passwd *pas, const char *file) } /* CHILD - change user and run editor */ - change_user(pas); + /* initgroups, setgid, setuid */ + change_identity(pas); + setup_environment(DEFAULT_SHELL, 0, + SETUP_ENV_CHANGEENV | SETUP_ENV_TO_TMP, pas); ptr = getenv("VISUAL"); if (!ptr) { ptr = getenv("EDITOR"); |