Page MenuHomeFreeBSD

Respect PATH from login.conf in cron.
ClosedPublic

Authored by andrew_tao173.riddles.org.uk on Feb 10 2020, 1:20 AM.
Tags
None
Referenced Files
F81680223: D23597.id68031.diff
Fri, Apr 19, 8:27 PM
Unknown Object (File)
Tue, Mar 26, 1:49 AM
Unknown Object (File)
Feb 23 2024, 11:44 PM
Unknown Object (File)
Feb 23 2024, 11:43 PM
Unknown Object (File)
Feb 23 2024, 11:43 PM
Unknown Object (File)
Feb 23 2024, 11:43 PM
Unknown Object (File)
Feb 23 2024, 4:39 PM
Unknown Object (File)
Feb 6 2024, 5:17 PM
Subscribers

Details

Summary

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

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
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).

usr.sbin/cron/cron/do_command.c
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
usr.sbin/cron/cron/do_command.c
303 ↗(On Diff #68031)

...here. Should it be done also in the !LOGIN_CAP case?

usr.sbin/cron/lib/entry.c
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.

usr.sbin/cron/cron/do_command.c
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.