wok diff busybox/stuff/busybox-1.20-su-nochdir.u @ rev 12460

Up busybox (1.20.0)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Apr 22 13:08:24 2012 +0200 (2012-04-22)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/busybox/stuff/busybox-1.20-su-nochdir.u	Sun Apr 22 13:08:24 2012 +0200
     1.3 @@ -0,0 +1,42 @@
     1.4 +su should not chdir to home
     1.5 +--- busybox-1.20.0/include/libbb.h
     1.6 ++++ busybox-1.20.0/include/libbb.h
     1.7 +@@ -1286,6 +1286,7 @@
     1.8 + #define SETUP_ENV_CHANGEENV (1 << 0)
     1.9 + #define SETUP_ENV_CLEARENV  (1 << 1)
    1.10 + #define SETUP_ENV_TO_TMP    (1 << 2)
    1.11 ++#define SETUP_ENV_NO_CHDIR  (1 << 4)
    1.12 + extern void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC;
    1.13 + extern int correct_password(const struct passwd *pw) FAST_FUNC;
    1.14 + /* Returns a malloced string */
    1.15 +
    1.16 +--- busybox-1.20.0/libbb/setup_environment.c
    1.17 ++++ busybox-1.20.0/libbb/setup_environment.c
    1.18 +@@ -37,9 +37,11 @@
    1.19 + 
    1.20 + 	/* Change the current working directory to be the home directory
    1.21 + 	 * of the user */
    1.22 +-	if (chdir(pw->pw_dir)) {
    1.23 +-		xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/");
    1.24 +-		bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
    1.25 ++	if ((flags & SETUP_ENV_NO_CHDIR) == 0) {
    1.26 ++		if (chdir(pw->pw_dir)) {
    1.27 ++			xchdir((flags & SETUP_ENV_TO_TMP) ? "/tmp" : "/");
    1.28 ++			bb_error_msg("can't chdir to home directory '%s'", pw->pw_dir);
    1.29 ++		}
    1.30 + 	}
    1.31 + 
    1.32 + 	if (flags & SETUP_ENV_CLEARENV) {
    1.33 +
    1.34 +--- busybox-1.20.0/loginutils/su.c
    1.35 ++++ busybox-1.20.0/loginutils/su.c
    1.36 +@@ -131,7 +131,8 @@
    1.37 + 	change_identity(pw);
    1.38 + 	setup_environment(opt_shell,
    1.39 + 			((flags & SU_OPT_l) / SU_OPT_l * SETUP_ENV_CLEARENV)
    1.40 +-			+ (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV),
    1.41 ++			+ (!(flags & SU_OPT_mp) * SETUP_ENV_CHANGEENV)
    1.42 ++			+ (!(flags & SU_OPT_l) * SETUP_ENV_NO_CHDIR),
    1.43 + 			pw);
    1.44 + 	IF_SELINUX(set_current_security_context(NULL);)
    1.45 +