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
Lint Skipped
Unit Tests Skipped

Event Timeline

kevans accepted this revision.Feb 11 2020, 4:46 AM

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).


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
293 Should it be done also in the !LOGIN_CAP case?


Since getting the home directory isn't being done there anymore but done... accepted this revision.Feb 11 2020, 5:15 AM

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


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 marked an inline comment as done.Feb 12 2020, 6:49 AM
bcr accepted this revision as: manpages.Feb 12 2020, 9:12 AM
bcr added a subscriber: bcr.

OK from manpages. Don't forget to bump the .Dd in the manpage for this content change. accepted this revision.Feb 13 2020, 6:15 PM

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.