fix(linux): stop offering a file picker that cannot open - #13
Open
ayozetr wants to merge 1 commit into
Open
Conversation
On Linux the file picker never opens once the binary carries CAP_NET_RAW, which scripts/run-linux.sh grants by default. rfd routes dialogs through xdg-desktop-portal, which identifies its caller by opening /proc/<pid>/root; the kernel gates that behind ptrace_may_access, which refuses unless the reader holds a superset of the target's permitted capabilities. The portal holds none, so every request comes back as: Portal operation not allowed: Unable to open /proc/<pid>/root pick_file() then returns None, indistinguishable from the user cancelling, so both "choose game" buttons look like they do nothing at all. Nothing can satisfy both sides: capture needs the capability for as long as the app can reopen a socket, and a permitted capability can only be dropped, never regained. (Restoring the dumpable flag with prctl is not enough — it fixes the ownership of /proc/self but not the capability comparison.) So detect the situation and offer what does work: Settings swaps the browse button for a text field, and the hub's button records why it cannot open a dialog instead of failing silently.
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.
On Linux the file picker never opens once the binary carries
CAP_NET_RAW, whichscripts/run-linux.shgrants by default.rfdroutes dialogs throughxdg-desktop-portal, which identifies its caller by opening/proc/<pid>/root. The kernel gates that behindptrace_may_access, which refuses unless the reader holds a superset of the target's permitted capabilities. The portal holds none, so:pick_file()then returnsNone, indistinguishable from the user cancelling, so both "choose game" buttons appear to do nothing at all, and nothing surfaces where a user would see it.Measured rather than inferred — same user, same machine:
CapPrm/proc/<pid>/rootcap_net_rawNothing can satisfy both sides: capture needs the capability for as long as the app can reopen a socket, and a permitted capability can only be dropped, never regained. Restoring the dumpable flag with
prctl(PR_SET_DUMPABLE)is not enough either — it fixes the ownership of/proc/selfbut not the capability comparison, which I confirmed before discarding that approach.So this detects the situation and offers what does work: Settings swaps the browse button for a text field, and the hub button records why it cannot open a dialog instead of failing silently.
Happy to take this in a different direction if you would rather — switching
rfdto its GTK3 backend would restore a real picker, at the cost of a GTK build dependency on Linux (which would partly undo #11).Context in #8.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.