[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pkg-shadow-devel
Subject:    [Pkg-shadow-devel] Fix default path for root with "su"
From:       Michel Hermier <michel.hermier () gmail ! com>
Date:       2009-11-01 10:28:56
Message-ID: 2e631f490911010228n76eb5905j4fba0562c8cd7f48 () mail ! gmail ! com
[Download RAW message or body]

Hi,

According to the manual:

    The current environment is passed to the new shell. The value of
$PATH is reset to /bin:/usr/bin for normal users, or
    /sbin:/bin:/usr/sbin:/usr/bin for the superuser. This may be
changed with the ENV_PATH and ENV_SUPATH definitions in
/etc/login.defs.

So for me when doing a simple "su" invocation the $PATH should be
"/sbin:/bin:/usr/sbin:/usr/bin" while "su foouser" should return
"/bin:/usr/bin" when /etc/login.defs is not modified. But it is not
the case, we unconditionally get "/bin:/usr/bin". Here is a patch that
correct this behavior.

Cheers,
    Michel

["su.patch" (application/octet-stream)]

--- shadow/src/su.c	2009-10-31 20:12:51.000000000 +0100
+++ shadow/src/su.c	2009-10-31 20:33:32.000000000 +0100
@@ -869,7 +869,8 @@
 
 	cp = getdef_str ((pwent.pw_uid == 0) ? "ENV_SUPATH" : "ENV_PATH");
 	if (NULL == cp) {
-		addenv ("PATH=/bin:/usr/bin", NULL);
+		addenv ((pwent.pw_uid == 0) ? "PATH=/sbin:/bin:/usr/sbin:/usr/bin" : "PATH=/bin:/usr/bin",
+		        NULL);
 	} else if (strchr (cp, '=') != NULL) {
 		addenv (cp, NULL);
 	} else {


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic