OpenSolaris

Printable Version Enter a New Search
Bug ID 6655359
Synopsis cron assumes malloc returns zeros memory and then sets root's path by luck rather than judgement
State 10-Fix Delivered (Fix available in build)
Category:Subcategory utility:scheduling
Keywords rtiq_regression
Responsible Engineer Jonathan Ca
Reported Against snv_80 , snv_81
Duplicate Of
Introduced In solaris_nevada
Commit to Fix snv_93
Fixed In snv_93
Release Fixed solaris_nevada(snv_93)
Related Bugs 6416652
Submit Date 25-January-2008
Last Update Date 3-July-2008
Description
Cron is not setting root's path correctly until after root's crontab file is edited.

If you add this line to root's crontab:

* * * * * echo $PATH > /tmp/.root_patch

using crontab -e then after the job runs  /tmp/.root_patch looks like this:

# cat  /tmp/.root_patch
/usr/sbin:/usr/bin
# 

However if you reboot the system or restart cron the file will look like this:

# cat  /tmp/.root_patch
/usr/bin:
# 

The problem appears to have been introduced by:

6416652 *cron* suffers from amnesia if name services aren't there at boot time

which fails to fill in the uid into cron's usr structure.  Mostly this does not matter as the uid is checked later before jobs run. However the selection of the PATH is done before the uid is filled in making the selection of the PATH random.

The solution is to set the path after verifying the users credentials:


------- cron.c -------
*** /tmp/sccs.99aDEx    Fri Jan 25 16:57:09 2008
--- cron.c      Fri Jan 25 16:56:48 2008
***************
*** 2079,2090 ****
                return (0);
        }
  #endif
-       if ((e->u)->uid == 0) { /* set default path */
-               /* path settable in defaults file */
-               envinit[2] = supath;
-       } else {
-               envinit[2] = path;
-       }
  
        /*
         * the tempnam() function uses malloc(3C) to allocate space for the
--- 2079,2084 ----
***************
*** 2290,2295 ****
--- 2284,2296 ----
                clean_out_user(e->u);
                exit(1);
        }
+       
+       if ((e->u)->uid == 0) { /* set default path */
+               /* path settable in defaults file */
+               envinit[2] = supath;
+       } else {
+               envinit[2] = path;
+       }
  
        if (e->etype != CRONEVENT) {
                r = audit_cron_session(e->u->name, NULL,
Work Around
N/A
Comments
N/A