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 044440435..7d5709521 100644 --- a/miscutils/crontab.c +++ b/miscutils/crontab.c | |||
| @@ -17,22 +17,6 @@ | |||
| 17 | #define CRONUPDATE "cron.update" | 17 | #define CRONUPDATE "cron.update" |
| 18 | #endif | 18 | #endif |
| 19 | 19 | ||
| 20 | static void change_user(const struct passwd *pas) | ||
| 21 | { | ||
| 22 | xsetenv("USER", pas->pw_name); | ||
| 23 | xsetenv("HOME", pas->pw_dir); | ||
| 24 | xsetenv("SHELL", DEFAULT_SHELL); | ||
| 25 | |||
| 26 | /* initgroups, setgid, setuid */ | ||
| 27 | change_identity(pas); | ||
| 28 | |||
| 29 | if (chdir(pas->pw_dir) < 0) { | ||
| 30 | bb_perror_msg("chdir(%s) by %s failed", | ||
| 31 | pas->pw_dir, pas->pw_name); | ||
| 32 | xchdir("/tmp"); | ||
| 33 | } | ||
| 34 | } | ||
| 35 | |||
| 36 | static void edit_file(const struct passwd *pas, const char *file) | 20 | static void edit_file(const struct passwd *pas, const char *file) |
| 37 | { | 21 | { |
| 38 | const char *ptr; | 22 | const char *ptr; |
| @@ -46,7 +30,10 @@ static void edit_file(const struct passwd *pas, const char *file) | |||
| 46 | } | 30 | } |
| 47 | 31 | ||
| 48 | /* CHILD - change user and run editor */ | 32 | /* CHILD - change user and run editor */ |
| 49 | change_user(pas); | 33 | /* initgroups, setgid, setuid */ |
| 34 | change_identity(pas); | ||
| 35 | setup_environment(DEFAULT_SHELL, 0, | ||
| 36 | SETUP_ENV_CHANGEENV | SETUP_ENV_TO_TMP, pas); | ||
| 50 | ptr = getenv("VISUAL"); | 37 | ptr = getenv("VISUAL"); |
| 51 | if (!ptr) { | 38 | if (!ptr) { |
| 52 | ptr = getenv("EDITOR"); | 39 | ptr = getenv("EDITOR"); |
