rev |
line source |
pascal@12460
|
1 su should not chdir to home
|
pascal@12460
|
2 --- busybox-1.20.0/include/libbb.h
|
pascal@12460
|
3 +++ busybox-1.20.0/include/libbb.h
|
pascal@12460
|
4 @@ -1286,6 +1286,7 @@
|
pascal@12460
|
5 #define SETUP_ENV_CHANGEENV (1 << 0)
|
pascal@12460
|
6 #define SETUP_ENV_CLEARENV (1 << 1)
|
pascal@12460
|
7 #define SETUP_ENV_TO_TMP (1 << 2)
|
pascal@12460
|
8 +#define SETUP_ENV_NO_CHDIR (1 << 4)
|
pascal@12460
|
9 extern void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC;
|
pascal@12460
|
10 extern int correct_password(const struct passwd *pw) FAST_FUNC;
|
pascal@12460
|
11 /* Returns a malloced string */
|
pascal@12460
|
12
|
pascal@12460
|
13 --- busybox-1.20.0/libbb/setup_environment.c
|
pascal@12460
|
14 +++ busybox-1.20.0/libbb/setup_environment.c
|
pascal@12460
|
15 @@ -37,9 +37,11 @@
|
pascal@12460
|
16
|
pascal@12460
|
17 /* Change the current working directory to be the home directory
|
pascal@12460
|
18 * of the user */
|
pascal@12460
|
19 - if (chdir(pw->pw_dir)) {
|
pascal@12460
|
20 - xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/");
|
pascal@12460
|
21 - bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
|
pascal@12460
|
22 + if ((flags & SETUP_ENV_NO_CHDIR) == 0) {
|
pascal@12460
|
23 + if (chdir(pw->pw_dir)) {
|
pascal@12460
|
24 + xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/");
|
pascal@12460
|
25 + bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
|
pascal@12460
|
26 + }
|
pascal@12460
|
27 }
|
pascal@12460
|
28
|
pascal@12460
|
29 if (flags & SETUP_ENV_CLEARENV) {
|
pascal@12460
|
30
|
pascal@12460
|
31 --- busybox-1.20.0/loginutils/su.c
|
pascal@12460
|
32 +++ busybox-1.20.0/loginutils/su.c
|
pascal@12460
|
33 @@ -131,7 +131,8 @@
|
pascal@12460
|
34 change_identity(pw);
|
pascal@12460
|
35 setup_environment(opt_shell,
|
pascal@12460
|
36 ((flags & SU_OPT_l) / SU_OPT_l * SETUP_ENV_CLEARENV)
|
pascal@12460
|
37 - + (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV),
|
pascal@12460
|
38 + + (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV)
|
pascal@12460
|
39 + + (!(flags & SU_OPT_l) * SETUP_ENV_NO_CHDIR),
|
pascal@12460
|
40 pw);
|
pascal@12460
|
41 IF_SELINUX(set_current_security_context(NULL);)
|
pascal@12460
|
42
|