summaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer2010-02-24 16:10:09 +0100
committerDenys Vlasenko2010-02-26 09:31:40 +0100
commit99709ab03387ca623e3fc1cac69d242ed44da45c (patch)
treede266d18b15ab43efc0c46dd72f9d926db129c13 /miscutils
parent7e7728cd66482f6898e3896bf05a12f0f8137e79 (diff)
downloadbusybox-99709ab03387ca623e3fc1cac69d242ed44da45c.zip
busybox-99709ab03387ca623e3fc1cac69d242ed44da45c.tar.gz
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.c21
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");