HomeFreeBSD

service(8): use an environment more consistent with init(8)

Description

service(8): use an environment more consistent with init(8)

init(8) sets the "daemon" login class without specifying a pw
entry (so no substitutions are done on the variables). service(8)'s
use of env -L had the effect of specifying root's pw entry, with two
effects: getpwnam and getpwuid are being called, which may not be
entirely safe depending on what nsswitch is up to and what stage of
boot we are at, and substitutions would have been done.

Fix by teaching env(8) to allow -L -/classname to set the class
environment with no pw entry at all specified, and use it in
service(8).

PR: 253959
Approved by: re (gjb)

(cherry picked from commit 55deb0a5f089c8a27cfc1666655b93881c2b47ae)
(cherry picked from commit 0c1a5eaae83267365330437adb60f44e1a622a2b)
(cherry picked from commit 872ec7e5b6f35d84745b49c02f58572632de22ed)

Details

Provenance
andrew_tao173.riddles.org.ukAuthored on Mar 3 2021, 6:25 PM
kevansCommitted on Mar 17 2021, 12:11 AM
Parents
rG56dd03e0f2b1: linux(4): make getcwd(2) return ERANGE instead of ENOMEM
Branches
Unknown
Tags
Unknown