There is currently no single place where environment variables can be set that are required by daemons and cron jobs in addition to logged-in users.
The most glaring issue with this is when setting up a system with no public connectivity other than an HTTP proxy, there is no single place that allows you to set the proxy address that is recognized by both the ntpd leapsecond file fetch (invoked from cron via "service ntpd onefetch" which clears the environment) and the package vulnerability database fetch (invoked from cron).
This patch proposes four substantive changes (and one largely cosmetic cleanup):
- init(8) sets the environment variables of the "daemon" class when running /etc/rc (and also those of "default" when running other processes).
- cron(8) sets the environment variables of the user and/or login class for which it is invoking a job, prior to processing environment variable settings in the crontab file.
- env(1) gets options -L user/class and -U user/class to set the environment of the specified user either from login.conf alone (-L) or both login.conf and ~/.login_conf if present (-U). This is to enable:
- service(8) sets the environment of the "daemon" class before invoking the rc script.
- The MAIL environment variable gets split out into a separate "mail" capability because things work more cleanly that way (easier to suppress it in the "daemon" class where it will not be properly expanded, for example).
This is a fairly early work in progress, in particular there is no documentation yet.