3 ms·
Your idea is wrong. nobody is not a suitable account for running daemons as. It has a very specific purpose, originating in NFS. That purpose is to be the vi
by JdeBP 9y ago
Your idea is wrong.
nobody is not a suitable account for running daemons as. It has a very specific purpose, originating in NFS. That purpose is to be the visible owner of files and directories in mounted NFS filesystems in certain circumstances. Daemon processes in general run as unprivileged accounts that should own a minimal amount of filesystem entities relevant to their operation. They certainly should not run as accounts that own vast tracts of the filesystem that the daemon programs have no business dealing in.
* https://askubuntu.com/a/674397/43344 https://askubuntu.com/a/674397/43344
For best results, a daemon process that has dropped privileges should run under the aegis of an unprivileged account that is a rôle account specific to that one service. This allows one to grant filesystem access and object ownership specifically, and enables the kernel's usual mechanisms for preventing other (unprivileged) processes from messing with the daemon process with the likes of ptrace() and kill().
And if the account given as the one to drop privileges to does not exist in the user account database and is invalid, the service should fail to run.
This is what daemontools-family service management does; because setuidgid (or runuid, or chpst, or whatever) abends with a fatal error when it fails to find the account in the system's account database. This is what the Solaris SMF does, too. It switches the service to the "maintenance" state when the "user" property for the method context is wrong:
Nov 12 22:24:17 aocdbs02a inetd[1053]: Property 'user' of instance svc:/network/stdiscover:default is missing, inconsistent or invalid
Nov 12 22:24:17 aocdbs02a inetd[1053]: Invalid configuration for instance svc:/network/stdiscover:default, placing in maintenance
It is what Upstart does, as well:
* https://bugs.launchpad.net/upstart/+bug/1165013 https://bugs.launchpad.net/upstart/+bug/1165013
- the_mitsuhiko 9y agoIt is a suitable user and has been used to run daemons for a long time. That it's not the ideal choice should be obvious.
- JdeBP 9y agoNo; I have just explained why nobody is unsuitable. Please bring yourself up to date and learn better. This is stuff that the world learned was the wrong thing to do in the 1990s. (The note in the LSB recommending against running daemons in a single shared account dates from 2002, and that was years late to the party.)