NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
bin/43591: cron for user not defining PATH
>Number: 43591
>Category: bin
>Synopsis: cron for user not defining PATH
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jul 10 01:50:00 +0000 2010
>Originator: reed%reedmedia.net@localhost
>Release: NetBSD 5.99
>Organization:
>Environment:
>Description:
One of my cron jobs failed since PATH was not defined.
I looked at my email headers and saw:
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/jreed>
X-Cron-Env: <LOGNAME=jreed>
X-Cron-Env: <USER=jreed>
X-Cron-Env: </usr/bin:/bin:/usr/pkg/bin:/usr/local/bin>
Notice the last line probably should have PATH=. I looked at older email
headers from an old cron and it did have PATH.
This is:
/usr/sbin/cron:
$NetBSD: crt0.c,v 1.5 2007/09/27 10:51:18 dogcow Exp $
$NetBSD: cron.c,v 1.6 2010/05/18 21:49:51 christos Exp $
$NetBSD: database.c,v 1.2 2010/05/06 18:53:17 christos Exp $
$NetBSD: do_command.c,v 1.2 2010/05/06 18:53:17 christos Exp $
$NetBSD: entry.c,v 1.2 2010/05/06 18:53:17 christos Exp $
$NetBSD: env.c,v 1.2 2010/05/06 18:53:17 christos Exp $
$NetBSD: job.c,v 1.2 2010/05/06 18:53:17 christos Exp $
$NetBSD: misc.c,v 1.2 2010/05/06 18:53:17 christos Exp $
$NetBSD: popen.c,v 1.2 2010/05/06 18:53:17 christos Exp $
$NetBSD: pw_dup.c,v 1.2 2010/05/06 18:53:17 christos Exp $
root's cron job does work. I have it run a script that simply is just
one line:
echo $PATH
The cron email has:
X-Cron-Env: <PATH=/bin:/sbin:/usr/bin:/usr/sbin>
And the body is:
/bin:/sbin:/usr/bin:/usr/sbin
root's crontab specifically defines the PATH.
# crontab -l -u root | grep PATH
PATH=/bin:/sbin:/usr/bin:/usr/sbin
But running the shell script as a normal user does:
X-Cron-Env: </usr/bin:/bin:/usr/pkg/bin:/usr/local/bin>
(notice no PATH=)
The output is:
/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin
(see it has different PATH)
So then I had it also run "env" and "export" in the shell script. For
the root it is:
CRON_WITHIN=7200
PWD=/var/log
HOME=/var/log
PATH=/bin:/sbin:/usr/bin:/usr/sbin
USER=root
LOGNAME=root
SHELL=/bin/sh
CRON_WITHIN
HOME
LOGNAME
PATH
PWD
SHELL
USER
(notice root's does have PATH)
For the regular user it is:
PWD=/home/jreed
HOME=/home/jreed
USER=jreed
LOGNAME=jreed
SHELL=/bin/sh
HOME
LOGNAME
PWD
SHELL
USER
(notice no PATH)
Now when I do set PATH in the user's crontab, it is fixed:
X-Cron-Env: <PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/pkg/bin:/foo/bar>
and my output:
/bin:/sbin:/usr/bin:/usr/sbin:/usr/pkg/bin:/foo/bar
PWD=/home/jreed
HOME=/home/jreed
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/pkg/bin:/foo/bar
USER=jreed
LOGNAME=jreed
SHELL=/bin/sh
HOME
LOGNAME
PATH
PWD
SHELL
USER
Maybe the problem is related to the patches related to path for
login classes. I didn't test vixie-cron from pkgsrc to compare.
>How-To-Repeat:
cron job as a normal user (or maybe remove PATH from root's crontab?)
>Fix:
>Unformatted:
Home |
Main Index |
Thread Index |
Old Index