|
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,
|