Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] make use of linux capabilities to run as non-root #417

Open
dkwo opened this issue Dec 2, 2024 · 4 comments
Open

[question] make use of linux capabilities to run as non-root #417

dkwo opened this issue Dec 2, 2024 · 4 comments

Comments

@dkwo
Copy link

dkwo commented Dec 2, 2024

I was wondering whether the dhcpcd daemon supports being run as a non-root user, by simply giving some capabilities to its process, either using setpriv, something like

exec setpriv --reuid _wpas --regid _wpas --clear-groups \
  --ambient-caps -all,+net_admin,+net_raw \
  --inh-caps -all,+net_admin,+net_raw \
  --bounding-set -all,+net_admin,+net_raw \
  --no-new-privs -- wpa_supplicant ${OPTS}

(here I use the example for wpa_supplicant, its user being _wpas) or any similar functionality provided by the service manager.

I understand there's the privsep build option, but I was wondering whether this alternative is supported and makes sense from upstream viewpoint. If so, are net_admin and net_raw necessary and sufficient capabilities?

@rsmarples
Copy link
Member

Sort answer no and no plans for it either.

At best we can document it because dhcpcd is mainly installed by package managers which need to then run setpriv.
Each time you create a new file, it's set caps are discarded.

@dkwo
Copy link
Author

dkwo commented Dec 7, 2024

@rsmarples I think you are misunderstanding how setpriv (part of util-linux) works: it does not touch the binary file, rather it starts a process with those capabilities. The init/service manager can also do it, e.g. I believe systemd and dinit have this feature. This is to be compared with setcap, which instead does what you say and is not a preffered choice.

Btw, with just +net_admin,+net_raw,+net_bind_service I get no errors nor warnings, if I'm not using privsep. Everything seems to work fine.

@rsmarples
Copy link
Member

OK, but privsep will give you better protection than capabilities for the front facing processes which are the most vulnerable.
So the question is now can we make it work with privsep?

@dkwo
Copy link
Author

dkwo commented Dec 8, 2024

I agree. I can try to experiment more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants