server: detect graphical sessions under systemd --user compositors - #558
Open
TheSkyentist wants to merge 3 commits into
Open
server: detect graphical sessions under systemd --user compositors#558TheSkyentist wants to merge 3 commits into
TheSkyentist wants to merge 3 commits into
Conversation
Add two fallbacks to SessionType detection, used only when logind can't place the peer in a session at all: reading the peer's own /proc/<pid>/environ for WAYLAND_DISPLAY/DISPLAY, and, since that is commonly blocked by Yama's ptrace_scope, falling back further to the systemd --user manager's own exported environment, which compositors following this integration model populate on startup and which is readable over D-Bus without needing ptrace access.
📊 Code Coverage Report
Coverage report generated by cargo-tarpaulin |
Extract the WAYLAND_DISPLAY/DISPLAY lookup shared by from_environ and from_systemd_user_environment into from_display_vars, add unit tests for it, drop the unneeded allocation, and make both helpers private since only detect() is used externally.
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.
Fixes #557
Fix
SessionType::detectnow falls back pastlogind, in order:/proc/<pid>/environ, since compositors exportWAYLAND_DISPLAY/DISPLAYto the clients they spawn. This is often blocked by Yama'sptrace_scope(default 1 on many distros), since the daemon is never an ancestor of its D-Bus peers.--usermanager's own exported environment, which compositors following this integration model populate on startup (e.g. viadbus-update-activation-environment) and which isreadable live over D-Bus with noptrace_scoperestriction. This is coarser, since it is session-wide rather than peer-specific, so it is only used oncelogindgives no answer at all for the peer.Each step is only consulted if the previous one could not place the peer in a session at all, so a definite non-graphical answer from
logind(e.g. a real tty/SSH login) is still trusted as-is.Testing
Reproduced and confirmed fixed on Arch Linux with niri run as a systemd
--userservice andlyas greeter. Added unit tests forfrom_environ.cargo test,cargo clippy --all-targetsclean.