Open rohbotics opened 7 years ago
Upstart actually has a similar capability. Historically we've done it this way because of wanting to be able to create directories and chown them as required (eg, the log dir). However, I'd be open to reconsidering this— if you're open to putting some work into it I would love to discuss a PR.
As noted in the docs [1], when using setuidgid, the groups and group permissions for that user are lost, which is pretty annoying for nodes that deal with hardware. Udev fixes do work, but are kind of painful to configure.
With systemd, you can run a service as a specific user, preserving the groups. In the service section of the unit file you can add something like this:
And then remove the setgiduid stuff from the /usr/sbin script, so that the service launches properly as the non-root user. This would be pretty nice to have, and the sbin script could be kept compatible with upstart by checking if UID=0 before using setgiduid.