Friday 12 February 2021

Re: Making cron stop overriding PATH?

Thanks for bringing this up for discussion, Julian.

On Fri, Feb 12, 2021 at 09:53:33PM +0100, Julian Andres Klode wrote:
> it seems that cron defines two PATH right now. Stuff launched from
> /etc/crontab - e.g. /etc/cron.daily and friends - get a PATH _similar_
> to the normal one, except that:

> - /{s,}bin comes before /usr/{s,bin}
> - /snap/bin is missing

> It is:
> PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

> (see /etc/crontab)

> Cron jobs launched in user sessions just get the PATH=/usr/bin:/bin, not
> even /usr/local dirs. You'd expect that it would be the other way
> around, with /usr/local missing for system wide jobs (which might come
> preinstalled), but available in user jobs.

> We're considering removing those PATH overrides and have cron inherit
> PATH from pam_env, and I'm looking for some feedback, and maybe someone
> has an insight into the background of why this is the way it is.

My $.02, in the time that I have been maintaining pam in Debian this policy
of ignoring PATH from pam_env has never been discussed with me. And I do
not think there's any reason to consider cron "special" as a service such
that it should diverge from the default system path as set by systemd/pam -
any such divergence is simply a bug, as seen in the case of /snap/bin.

--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
Ubuntu Developer https://www.debian.org/
slangasek@ubuntu.com vorlon@debian.org