Bug 1536111
Summary: | Option -P to inherited the PATH from the environment does not work | ||||||
---|---|---|---|---|---|---|---|
Product: | Red Hat Enterprise Linux 7 | Reporter: | Welterlen Benoit <bwelterl> | ||||
Component: | cronie | Assignee: | Marcel Plch <mplch> | ||||
Status: | CLOSED ERRATA | QA Contact: | Jan Houska <jhouska> | ||||
Severity: | unspecified | Docs Contact: | |||||
Priority: | unspecified | ||||||
Version: | 7.7 | CC: | cww, dshaw, hhorak, jhouska, vdanek | ||||
Target Milestone: | rc | Keywords: | Reopened | ||||
Target Release: | --- | ||||||
Hardware: | x86_64 | ||||||
OS: | Unspecified | ||||||
Whiteboard: | |||||||
Fixed In Version: | 1.4.11-21 | Doc Type: | No Doc Update | ||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | Environment: | ||||||
Last Closed: | 2019-08-06 12:35:18 UTC | Type: | Bug | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Bug Depends On: | |||||||
Bug Blocks: | 1594286 | ||||||
Attachments: |
|
I just hit this bug as well. Is there some reason why it was closed WONTFIX? Is there a workaround or a better way to do this? This BZ will be evaluated for release in 7.7. VERIFIED: NEW PASS: cronie-1.4.11-23.el7 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 09:20:45 ] :: [ BEGIN ] :: Running 'rlServiceStop crond' Redirecting to /bin/systemctl status crond.service ● crond.service - Command Scheduler Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled) Active: active (running) since St 2019-06-12 09:17:55 EDT; 2min 49s ago Main PID: 1175 (crond) CGroup: /system.slice/crond.service └─1175 /usr/sbin/crond -n čen 12 09:17:55 host-10-0-137-117 systemd[1]: Started Command Scheduler. čen 12 09:17:56 host-10-0-137-117 crond[1175]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 97% if used.) čen 12 09:17:56 host-10-0-137-117 crond[1175]: (CRON) INFO (running with inotify support) Redirecting to /bin/systemctl stop crond.service :: [ 09:20:45 ] :: [ PASS ] :: Command 'rlServiceStop crond' (Expected 0, got 0) :: [ 09:20:45 ] :: [ BEGIN ] :: Running 'rlServiceStart crond' Redirecting to /bin/systemctl status crond.service ● crond.service - Command Scheduler Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled) Active: inactive (dead) since St 2019-06-12 09:20:45 EDT; 38ms ago Process: 1175 ExecStart=/usr/sbin/crond -n $CRONDARGS (code=exited, status=0/SUCCESS) Main PID: 1175 (code=exited, status=0/SUCCESS) čen 12 09:17:55 host-10-0-137-117 systemd[1]: Started Command Scheduler. čen 12 09:17:56 host-10-0-137-117 crond[1175]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 97% if used.) čen 12 09:17:56 host-10-0-137-117 crond[1175]: (CRON) INFO (running with inotify support) čen 12 09:20:45 ci-vm-10-0-137-117.hosted.upshift.rdu2.redhat.com systemd[1]: Stopping Command Scheduler... čen 12 09:20:45 ci-vm-10-0-137-117.hosted.upshift.rdu2.redhat.com systemd[1]: Stopped Command Scheduler. Redirecting to /bin/systemctl start crond.service :: [ 09:20:45 ] :: [ LOG ] :: rlServiceStart: Service crond started successfully :: [ 09:20:45 ] :: [ PASS ] :: Command 'rlServiceStart crond' (Expected 0, got 0) :: [ 09:21:46 ] :: [ PASS ] :: File '/tmp/path_cron' should contain '/newpath/' :: [ 09:21:46 ] :: [ PASS ] :: File '/tmp/path_cron' should not contain '/usr/local/bin:/usr/bin' --cat /tmp/path_cron------------- /newpath/ --/cat /tmp/path_cron------------ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 61s :: Assertions: 4 good, 0 bad :: RESULT: PASS (Test) OLD FAIL cronie-1.4.11-19.el7 :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Test :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: [ 09:25:47 ] :: [ BEGIN ] :: Running 'rlServiceStop crond' Redirecting to /bin/systemctl status crond.service ● crond.service - Command Scheduler Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled) Active: active (running) since St 2019-06-12 09:25:24 EDT; 22s ago Main PID: 3182 (crond) CGroup: /system.slice/crond.service └─3182 /usr/sbin/crond -n čen 12 09:25:24 host-10-0-137-126 systemd[1]: Started Command Scheduler. čen 12 09:25:24 host-10-0-137-126 crond[3182]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 45% if used.) čen 12 09:25:25 host-10-0-137-126 crond[3182]: (CRON) INFO (running with inotify support) Redirecting to /bin/systemctl stop crond.service :: [ 09:25:47 ] :: [ PASS ] :: Command 'rlServiceStop crond' (Expected 0, got 0) :: [ 09:25:47 ] :: [ BEGIN ] :: Running 'rlServiceStart crond' Redirecting to /bin/systemctl status crond.service ● crond.service - Command Scheduler Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled) Active: inactive (dead) since St 2019-06-12 09:25:47 EDT; 64ms ago Process: 3182 ExecStart=/usr/sbin/crond -n $CRONDARGS (code=exited, status=0/SUCCESS) Main PID: 3182 (code=exited, status=0/SUCCESS) čen 12 09:25:24 host-10-0-137-126 systemd[1]: Started Command Scheduler. čen 12 09:25:24 host-10-0-137-126 crond[3182]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 45% if used.) čen 12 09:25:25 host-10-0-137-126 crond[3182]: (CRON) INFO (running with inotify support) čen 12 09:25:47 ci-vm-10-0-137-126.hosted.upshift.rdu2.redhat.com systemd[1]: Stopping Command Scheduler... čen 12 09:25:47 ci-vm-10-0-137-126.hosted.upshift.rdu2.redhat.com systemd[1]: Stopped Command Scheduler. Redirecting to /bin/systemctl start crond.service :: [ 09:25:47 ] :: [ LOG ] :: rlServiceStart: Service crond started successfully :: [ 09:25:47 ] :: [ PASS ] :: Command 'rlServiceStart crond' (Expected 0, got 0) :: [ 09:26:48 ] :: [ FAIL ] :: File '/tmp/path_cron' should contain '/newpath/' :: [ 09:26:48 ] :: [ FAIL ] :: File '/tmp/path_cron' should not contain '/usr/local/bin:/usr/bin' --cat /tmp/path_cron------------- /usr/local/bin:/usr/bin --/cat /tmp/path_cron------------ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Duration: 61s :: Assertions: 2 good, 2 bad :: RESULT: FAIL VERIFIED The test PASSED on all architectures: https://beaker.engineering.redhat.com/jobs/3611473 https://beaker.engineering.redhat.com/jobs/3602105 Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHBA-2019:2041 |
Created attachment 1382962 [details] Patch to fix Description of problem: According to the man page : -P Don't set PATH. PATH is instead inherited from the environment. but this does not work, the default path is set : /usr/bin:/bin Version-Release number of selected component (if applicable): cronie-1.4.11* How reproducible: Easy Steps to Reproduce: 1. set CRONDARGS="-P" and PATH="/newpath/ in" /etc/sysconfig/crond 2. Add a task with no PATH defined : /etc/cron.d/echopath SHELL=/bin/bash * * * * * root echo $PATH >> /tmp/path_cron 3. restart crond : systemctl restart crond Actual results: cat /tmp/path_cron /usr/bin:/bin Expected results: cat /tmp/path_cron /newpath/ Additional info: This has been fixed in this commit : 56c0fa2f7785c103cb5b431a5892b83978514755 commit 56c0fa2f7785c103cb5b431a5892b83978514755 Author: Robert Byrnes <Robert.Byrnes> Date: Thu Nov 5 14:38:13 2015 +0100 Inherit PATH from the crond environment if -P option is used. diff --git a/src/entry.c b/src/entry.c index 3638207..ce37756 100644 --- a/src/entry.c +++ b/src/entry.c @@ -343,8 +343,18 @@ entry *load_entry(FILE * file, void (*error_func) (), struct passwd *pw, e->envp = tenvp; #ifndef LOGIN_CAP /* If login.conf is in used we will get the default PATH later. */ - if (ChangePath && !env_get("PATH", e->envp)) { - if (glue_strings(envstr, sizeof envstr, "PATH", _PATH_DEFPATH, '=')) { + if (!env_get("PATH", e->envp)) { + char *defpath; + + if (ChangePath) + defpath = _PATH_DEFPATH; + else { + defpath = getenv("PATH"); + if (defpath == NULL) + defpath = _PATH_DEFPATH; + } + + if (glue_strings(envstr, sizeof envstr, "PATH", defpath, '=')) { if ((tenvp = env_set(e->envp, envstr)) == NULL) { ecode = e_memory; goto eof; I have a srpm and rpm that fix this issue.