vixie-cron/alt/vixie-cron-4.1.20060426-alt-path.patch
Dmitry V. Levin c818bfcc82 crond: change default $PATH to something reasonable (ALT#25846)
Change default path for uid != 0 to
	/usr/local/bin:/usr/bin:/bin:$HOME/bin
Change default path for uid == 0 to
	/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:$HOME/bin
2011-07-07 15:41:24 +00:00

16 lines
684 B
Diff

--- vixie-cron-4.1.20060426/usr.sbin/cron/entry.c
+++ vixie-cron-4.1.20060426/usr.sbin/cron/entry.c
@@ -306,8 +306,10 @@
#ifndef LOGIN_CAP
/* If login.conf is in use we will get the default PATH later. */
if (!env_get("PATH", e->envp)) {
- if (snprintf(envstr, sizeof envstr, "PATH=%s", _PATH_DEFPATH) >=
- sizeof(envstr))
+ if (snprintf(envstr, sizeof(envstr), "PATH=%s:%s/bin",
+ (pw->pw_uid ? "/usr/local/bin:/usr/bin:/bin" :
+ "/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin"),
+ pw->pw_dir) >= sizeof(envstr))
log_it("CRON", getpid(), "error", "can't set PATH");
else {
if ((tenvp = env_set(e->envp, envstr)) == NULL) {