RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1536111 - Option -P to inherited the PATH from the environment does not work
Summary: Option -P to inherited the PATH from the environment does not work
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: cronie
Version: 7.7
Hardware: x86_64
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Marcel Plch
QA Contact: Jan Houska
URL:
Whiteboard:
Depends On:
Blocks: 1594286
TreeView+ depends on / blocked
 
Reported: 2018-01-18 16:13 UTC by Welterlen Benoit
Modified: 2021-03-11 16:57 UTC (History)
5 users (show)

Fixed In Version: 1.4.11-21
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-08-06 12:35:18 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Patch to fix (997 bytes, text/plain)
2018-01-18 16:13 UTC, Welterlen Benoit
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2019:2041 0 None None None 2019-08-06 12:35:25 UTC

Description Welterlen Benoit 2018-01-18 16:13:35 UTC
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.

Comment 3 Daphne Shaw 2018-07-24 03:20:41 UTC
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?

Comment 5 Chris Williams 2018-11-05 15:25:50 UTC
This BZ will be evaluated for release in 7.7.

Comment 8 Jan Houska 2019-06-12 13:38:16 UTC
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

Comment 9 Jan Houska 2019-06-18 11:42:23 UTC
VERIFIED 

The test PASSED  on all architectures:
https://beaker.engineering.redhat.com/jobs/3611473
https://beaker.engineering.redhat.com/jobs/3602105

Comment 11 errata-xmlrpc 2019-08-06 12:35:18 UTC
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


Note You need to log in before you can comment on or make changes to this bug.