Write PIDFile inside /var/run/usbguard directory #498
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to #460, it is possible to run USBGuard as an unprivileged (non-root) user even with the -f option & Type=forking in the unit file. To get this to work, I had to:
EDIT:
5) Add "CAP_DAC_OVERRIDE" to "AmbientCapabilities=" and "CapabilityBoundingSet=" in the unit file. This is needed so that USBGuard can actually write to the "authorized" properties of the different USB devices under /sys. I think this shouldn't be much of a security risk, since other hardening options in the unit file prevent arbitrary writes to the rest of the system.
6) Add "AmbientCapabilities=CAP_CHOWN CAP_FOWNER CAP_AUDIT_WRITE CAP_DAC_OVERRIDE" if you want to allow non-root users to manage USBGuard through the IPC interface.
And after testing, #3 is very obviously not necessary. USBGuard has the "-p" option to specify where the PID file is written to, no recompilation needed. That's what I get for looking at the source code before the man page...
It would be nice if the PID file was in its own folder by default, but it's not a major issue. Given that CAP_DAC_OVERRIDE is needed, I won't submit a PR to make running as a dedicated user the default. But for those who are interested, the above should be all that's needed to make it work.