clearpathrobotics / robot_upstart

ROS package of helper functions related to bringing up roslaunch on system startup.
BSD 3-Clause "New" or "Revised" License
196 stars 96 forks source link

Request: Ability to use systemd User= directive #52

Open rohbotics opened 7 years ago

rohbotics commented 7 years ago

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:

[Service]
User={USER}

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.

mikepurvis commented 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.