Fix: allow nonroot startup with linux file caps by removing redundant pre-check#8209
Open
Jipok wants to merge 1 commit intoAdguardTeam:masterfrom
Open
Fix: allow nonroot startup with linux file caps by removing redundant pre-check#8209Jipok wants to merge 1 commit intoAdguardTeam:masterfrom
Jipok wants to merge 1 commit intoAdguardTeam:masterfrom
Conversation
21dd115 to
29d3408
Compare
|
Just to mention, this patch is working for years \o/ It is sad that no one cares |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #4714
Supersedes #4728
This issue has been open since 2022. The previous attempt to fix it stalled because of complexity involved in correctly detecting Linux capabilities via
prctl(checking Ambient vs Bounding sets).I propose a simpler, more robust approach: remove the predictive check entirely during startup.
setcap 'cap_net_bind_service=+ep'currently get a fatal error, even though the OS allows binding. This change fixes it.net.ipv4.ip_unprivileged_port_start), orauthbind. Conversely, it can be blocked by LSMs (SELinux/AppArmor), Landlock sandboxing, or eBPF policies, even if the process has root privileges. Predicting the outcome viaprctlis impossible to do accurately. The only reliable check is thebind()syscall itself.aghnet.CheckPort. This function attempts the actual bind and correctly handlesos.ErrPermissionby printing the relevant help message and exiting.trueunconditionally, relying onCheckPortfor validation.internal/aghnet/net_linux.gountouched. This ensures thatcontrolupdate.gostill seesfalsefor file-based capabilities (which is correct, as updating the binary wipes file caps), preventing broken auto-updates.