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
This commit is contained in:
Дмитрий Левин 2011-07-07 15:41:24 +00:00
parent e8e5e13b48
commit c818bfcc82
2 changed files with 19 additions and 2 deletions

View File

@ -0,0 +1,15 @@
--- 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) {

View File

@ -37,7 +37,8 @@ Patch12: vixie-cron-4.1.20040916-alt-children.patch
Patch13: vixie-cron-4.1.20060426-owl-tmp.patch
Patch14: vixie-cron-4.1.20040916-alt-setproctitle.patch
Patch15: vixie-cron-4.1.20060426-alt-crontab-list.patch
Patch16: vixie-cron-4.1.20060426-alt-selinux.patch
Patch16: vixie-cron-4.1.20060426-alt-path.patch
Patch17: vixie-cron-4.1.20060426-alt-selinux.patch
BuildRequires: libpam-devel, setproctitle-devel
%{?_with_selinux:BuildRequires: libselinux-devel}
@ -64,7 +65,8 @@ modifications by the NetBSD, OpenBSD, Red Hat, Owl and ALT teams.
%patch13 -p1
%patch14 -p1
%patch15 -p1
%{?_with_selinux:%patch16 -p1}
%patch16 -p1
%{?_with_selinux:%patch17 -p1}
sed -i 's/^\(static char const rcsid\[\] =\).*/\1 "%name-%version-%release";/' \
usr.sbin/cron/crontab.c