diff options
| author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2010-02-24 16:10:09 +0100 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-02-26 09:31:40 +0100 |
| commit | 99709ab03387ca623e3fc1cac69d242ed44da45c (patch) | |
| tree | de266d18b15ab43efc0c46dd72f9d926db129c13 /miscutils | |
| parent | 7e7728cd66482f6898e3896bf05a12f0f8137e79 (diff) | |
| download | busybox-w32-99709ab03387ca623e3fc1cac69d242ed44da45c.tar.gz busybox-w32-99709ab03387ca623e3fc1cac69d242ed44da45c.tar.bz2 busybox-w32-99709ab03387ca623e3fc1cac69d242ed44da45c.zip | |
crontab: use setup_environment
function old new delta
setup_environment 184 198 +14
.rodata 131770 131747 -23
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 14/-23) Total: -9 bytes
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
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"); |
