wok-next view busybox/stuff/busybox-1.20-su-nochdir.u @ rev 12997
lrzip: Clean up.
author | Christopher Rogers <slaxemulator@gmail.com> |
---|---|
date | Wed Jun 06 05:48:30 2012 +0000 (2012-06-06) |
parents | |
children |
line source
1 su should not chdir to home
2 --- busybox-1.20.0/include/libbb.h
3 +++ busybox-1.20.0/include/libbb.h
4 @@ -1286,6 +1286,7 @@
5 #define SETUP_ENV_CHANGEENV (1 << 0)
6 #define SETUP_ENV_CLEARENV (1 << 1)
7 #define SETUP_ENV_TO_TMP (1 << 2)
8 +#define SETUP_ENV_NO_CHDIR (1 << 4)
9 extern void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC;
10 extern int correct_password(const struct passwd *pw) FAST_FUNC;
11 /* Returns a malloced string */
13 --- busybox-1.20.0/libbb/setup_environment.c
14 +++ busybox-1.20.0/libbb/setup_environment.c
15 @@ -37,9 +37,11 @@
17 /* Change the current working directory to be the home directory
18 * of the user */
19 - if (chdir(pw->pw_dir)) {
20 - xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/");
21 - bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
22 + if ((flags & SETUP_ENV_NO_CHDIR) == 0) {
23 + if (chdir(pw->pw_dir)) {
24 + xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/");
25 + bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
26 + }
27 }
29 if (flags & SETUP_ENV_CLEARENV) {
31 --- busybox-1.20.0/loginutils/su.c
32 +++ busybox-1.20.0/loginutils/su.c
33 @@ -131,7 +131,8 @@
34 change_identity(pw);
35 setup_environment(opt_shell,
36 ((flags & SU_OPT_l) / SU_OPT_l * SETUP_ENV_CLEARENV)
37 - + (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV),
38 + + (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV)
39 + + (!(flags & SU_OPT_l) * SETUP_ENV_NO_CHDIR),
40 pw);
41 IF_SELINUX(set_current_security_context(NULL);)