Version 1.56.2

Released: 2019-04-09

Cron $PATH invalid fixed

Bug introduced in 1.56.1:

Add the php binary path to cron PATH

where $PATH is not a valid variable to be set for PATH= in a cron.

New internal default now changed to for 1.56.2:

set_php_bin_path_in_crons=0

but you can set it to:

set_php_bin_path_in_crons=1

if you wish to use it with the new logic, which should be ok now.

Updates to 1.56.1 done after about "1pm MST" April 9th are should have:

set_php_bin_path_in_crons=0

so you'd be fine. Confirm if you have that:

./directadmin c | grep set_php_bin_path_in_crons
IMPLICATION

If you save a cron with this feature enabled, you might get something like:

PATH=/usr/local/php72/bin:$PATH

which should appear fine, but the issue is that cron does not support $PATH variables, it must be fully expanded.

As a result, our path is only:

PATH=/usr/local/php72/bin

so simple global calls like "ls" or "grep" won't be found.

WORKAROUND for 1.56.1:

If you're an end-User with ssh, you can edit your crontab using:

crontab -e

and delete the PATH line.

For Admn's, use this in the directadmin.conf:

set_php_bin_path_in_crons=0

and hunt for any affected Users with:

grep '$PATH' /var/spool/cron/*

Debian:

grep '$PATH' /var/spool/cron/crontabs/*

TASK.QUEUE

upon updating to DirectAdmin 1.56.2, the scripts/update.sh will call:

echo 'action=rewrite&value=cron_path' >> /usr/local/directadmin/data/task.queue

which will hunt in all crons for 3 cases which must be true:

  1. The PATH= must start with the /usr/local/phpXX/bin

  2. The PATH= must contain $PATH

  3. The timestamp on the crontab file for this User must be newer than March 20th, as the bug didn't exist before this.

If any of the above are false, the user is skipped, and no swapping happens.


If it's just the 2 values, then:

PATH=/usr/local/phpXX/bin:$PATH

then

if set_php_bin_path_in_crons==0, then the PATH is removed completely.

for cases where there are more than 2 entries, DA will swap $PATH with the Users' current $PATH (obtained via su and other means)


If it's more than 2 PATH values, then more issues were at play and it's assumed you do want a custom entry so DA will replace $PATH with the User's path.

===================

Note: it's not easy to obtain the User's true PATH in the even the User does not have a shell enbabled.

For this case, DA will use the cron internal PATH default, as per the FreeBSD man page for CRONTAB(5), plus /home/username/bin added to the list.

For all OS, in the event DA cannot get the User's path (when it's trying to do so), the same default will be assumed:

PATH=/usr/local/phpXX/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/username/bin

for example (XX replaced with php version)

Last Updated: