File sudo-1.6.9p17-secure_path.diff of Package sudo
Index: env.c
===================================================================
--- env.c.orig
+++ env.c
@@ -530,7 +530,7 @@ rebuild_env(envp, sudo_mode, noexec)
#ifdef SECURE_PATH
/* Replace the PATH envariable with a secure one. */
- if (!user_is_exempt()) {
+ if (!user_is_exempt() && def_env_reset) {
insert_env(format_env("PATH", SECURE_PATH, VNULL), &env, 1);
SET(didvar, DID_PATH);
}
Index: find_path.c
===================================================================
--- find_path.c.orig
+++ find_path.c
@@ -93,7 +93,7 @@ find_path(infile, outfile, sbp, path)
/* Use PATH passed in unless SECURE_PATH is in effect. */
#ifdef SECURE_PATH
- if (!user_is_exempt())
+ if (!user_is_exempt() && def_env_reset)
path = SECURE_PATH;
#endif /* SECURE_PATH */
if (path == NULL)
Index: logging.c
===================================================================
--- logging.c.orig
+++ logging.c
@@ -466,7 +466,7 @@ send_mail(line)
#ifndef NO_ROOT_MAILER
static char *root_envp[] = {
"HOME=/",
- "PATH=/usr/bin:/bin",
+ "PATH=/usr/sbin:/bin:/usr/bin:/sbin",
"LOGNAME=root",
"USERNAME=root",
"USER=root",
Index: pathnames.h.in
===================================================================
--- pathnames.h.in.orig
+++ pathnames.h.in
@@ -41,9 +41,10 @@
#define _PATH_DEVNULL "/dev/null"
#endif /* _PATH_DEVNULL */
-#ifndef _PATH_DEFPATH
-#define _PATH_DEFPATH "/usr/bin:/bin"
-#endif /* _PATH_DEFPATH */
+/*
+ * _PATH_DEFPATH included from <paths.h> contains only "/usr/bin:/bin"
+ */
+#define _PATH_DEFPATH "/usr/sbin:/bin:/usr/bin:/sbin"
/*
* NOTE: _PATH_SUDOERS is usually overriden by the Makefile.