fix: allow downgrading of user by explicit CLI argument #3
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.
Problem
By default, boringtun uses the
getloginsyscall to determine which user to downgrade the service's permissions to after startup.getloginreads from/run/utmpto determine the logged in user, but this is a very outdated file which is not populated for processes run by sytemd. This results in the entire boringtun process failing to start when run by systemd, since boringtun can't determine what user ID it was started by, and thus fails to drop its privileges to that user ID.Even
man getlogintells you to bark up a different tree:Changes
This MR adds a
--usercommand line flag which tells boringtun explicitly which user to downgrade permissions to. This allows boringtun to be run either directly as the root user, or withsudoas a sudoer user.If the
--userparameter is not provided, boringtun falls back to legacy behavior (usinggetlogin)