Page MenuHomeFreeBSD

Respect PATH from login.conf in cron.

Authored by on Feb 10 2020, 1:20 AM.



As a followup to the use of login.conf environment vars (other than PATH) in cron, this patch adds PATH (and HOME) to the list of login.conf settings respected.

The new logic is as follows:

  1. SHELL is always _PATH_BSHELL unless explicitly overridden in the crontab file itself; no other settings are respected. This is unchanged.
  1. PATH is taken from the first of: crontab file, login.conf, _PATH_DEFPATH
  1. HOME is taken from the first of: crontab file, login.conf, passwd entry, unset
  1. The current directory for invoking the command is taken from the crontab file's value of HOME (existing behavior), or the passwd entry, but not anywhere else (so it might not equal HOME if that was set in login.conf).
Test Plan

I've done basic functionality tests, open to suggestions for specific things that need checking.

Diff Detail

rS FreeBSD src repository - subversion
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

I think this LGTM; I do wish we had some way to formally test cron(8) in a non-painful way (e.g. intercept and fake CLOCK_REALTIME so we can step through jobs at an expedited rate).

302 ↗(On Diff #68031)

The style around here is so odd, but I did confirm this lined up with the prevailing wrapping...

This revision is now accepted and ready to land.Feb 11 2020, 4:46 AM
303 ↗(On Diff #68031) Should it be done also in the !LOGIN_CAP case?

393 ↗(On Diff #68031)

Since getting the home directory isn't being done there anymore but done...

I don't notice any problems apart from that minor thing.

303 ↗(On Diff #68031)

Good catch. Looks like the simplest fix is to put it back in entry.c in the !LOGIN_CAP case.

Fix bug in non-LOGIN_CAP case. Update manpage.

This revision now requires review to proceed.Feb 12 2020, 6:48 AM
bcr added a subscriber: bcr.

OK from manpages. Don't forget to bump the .Dd in the manpage for this content change.

I don't see any problems with the new version.

This revision is now accepted and ready to land.Feb 13 2020, 6:15 PM
This revision was automatically updated to reflect the committed changes.