Hello, I have attached a patch that would give the compile-time
possibility of setting root's PATH when a user does an 'su' without the
login environment options.  I think it is potentially insecure to leave
the user's PATH for the superuser to depend on, especially given the large
number of newbies entering the gnu world.  It would be useful to have this
option.

The switch is -DPARANOID_PATH, and causes the path to be set to
DEFAULT_ROOT_LOGIN_PATH.  I have tested it on linux/gcc and on
hp-ux/ansic.  Let me know if there is anything else I should do to make
this patch acceptable....

  cheers from Denice

-- 
denice.deatrich @ epfl.ch, ADM/SIC, E.P.F.L.   PH: +41 (21) 693 22 53
<*> This moment's fortune cookie:
HOST SYSTEM RESPONDING, PROBABLY UP...
--- sh-utils-2.0/src/su.c.orig  Wed Mar 31 07:36:01 1999
+++ sh-utils-2.0/src/su.c       Tue Sep 19 15:44:42 2000
@@ -67,6 +67,10 @@
    -DSYSLOG_NON_ROOT   Log all su's, not just those to root (UID 0).
    Never logs attempted su's to nonexistent accounts.
 
+   -DPARANOID_PATH     set root's path to DEFAULT_ROOT_LOGIN_PATH when the
+                       user does a simple 'su' to superuser
+                       (not the simulated login)
+
    Written by David MacKenzie <[EMAIL PROTECTED]>.  */
 
 #include <config.h>
@@ -326,7 +330,8 @@
   else
     {
       /* Set HOME, SHELL, and if not becoming a super-user,
-        USER and LOGNAME.  */
+        USER and LOGNAME.  But if paranoid setting, then also change 
+        super-user's PATH  */
       if (change_environment)
        {
          xputenv (concat ("HOME", "=", pw->pw_dir));
@@ -335,6 +340,15 @@
            {
              xputenv (concat ("USER", "=", pw->pw_name));
              xputenv (concat ("LOGNAME", "=", pw->pw_name));
+           }
+         else
+           {
+#        if defined (PARANOID_PATH)
+           /* but in this case we set the path for superuser */
+           {
+              xputenv (concat ("PATH", "=",  DEFAULT_ROOT_LOGIN_PATH));
+           }
+#        endif
            }
        }
     }

Reply via email to