Repository navigation
fix: read KWin tablet emulation env from wrapper, Xwayland, or systemd when non-dumpable - #499
Merged
Merged
Conversation
…d when non-dumpable Distros such as Fedora ship /usr/bin/kwin_wayland with cap_sys_nice=ep, making the process non-dumpable so /proc/<pid>/environ returns EACCES (or ENOENT under hidepid=2) and breaking KDE background pointer input. When /proc/<kwin_pid>/environ is unreadable, fall back to: 1. KWin's kwin_wayland_wrapper parent (or org.kde.KWinWrapper verified via task/*/children when /proc/<kwin_pid> is hidden), which carries no file capabilities and spawns kwin_wayland with its environment verbatim. 2. A direct dumpable Xwayland child of KWin (verified via PPid). 3. KWin's systemd user .service unit when ExecStart runs KWin or its wrapper directly and PAMName is empty. Otherwise fail closed as before. Fixes #498
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: 43f20606-cf55-44ce-af59-a09f3658ea8c) |
Collaborator
Author
Self-review (clean context)Self-review complete: no blocking findings remain. Verified
Documented limits (non-blocking)
|
Merged
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 #498.
Why
Distros such as Fedora ship
/usr/bin/kwin_waylandwith file capabilities (cap_sys_nice=ep). A process exec'd from a binary with file capabilities is non-dumpable (dumpable = 0), so/proc/<pid>/environis0400 root:rootand returnsEACCES(orENOENTunderhidepid=2) to the desktop user.kwin_blocker()previously read only/proc/<kwin_pid>/environand failed closed, refusing every KDE backgroundclick,dragandscroll.What changed
When
/proc/<kwin_pid>/environfails withPermissionDeniedorNotFound,kwin_blocker()checks verified sources in order before failing closed:kwin_wayland_wrapperparent (ororg.kde.KWinWrapperunderhidepid): Both systemd (plasma-kwin_wayland.service) and non-systemd (plasma-session) Plasma Wayland sessions startkwin_waylandas a direct child ofkwin_wayland_wrapper, which carries no file capabilities and launcheskwin_waylandwith its environment verbatim (includingplasma-kwin_wayland.servicedrop-ins,environment.d, andplasma-workspace/env). When/proc/<kwin_pid>/statusis readable,PPidmust matchkwin_wayland_wrapper(or.kwin_wayland_wrapper-wrapped) or the session bus owner oforg.kde.KWinWrapper; an unrelated parent (such as a shell) is rejected. When/proc/<kwin_pid>is hidden,org.kde.KWinWrapperis verified againsttask/*/childrenwhen readable.Xwaylandchild of KWin: KWin spawnsXwaylandwithQProcessEnvironment::systemEnvironment()after loweringCAP_SYS_NICE, so a direct dumpableXwaylandchild (verified viaPPid == kwin_pid) carries KWin's environment even withoutkwin_wayland_wrapper..serviceunit (org.freedesktop.systemd1): WhenGetUnitByPIDreturns a.service(not a.scope),ExecStartrunskwin_waylandorkwin_wayland_wrapperdirectly, andPAMNameis empty, the check evaluatesManager.Environment,Service.Environment,Service.EnvironmentFiles(followingsystemd.exec(5)quoting/continuation rules, failing closed on missing required files, globs or malformed quotes), andService.UnsetEnvironment. Unlike/procsnapshots, systemd reports its current loaded state.Also lists
KWIN_WAYLAND_EMULATE_TABLETinscripts/check_env_forwarding.pyNOT_ENVIRONMENT(read from KWin's environment, not the server's) and adds aCHANGELOG.mdentry under[Unreleased].Tests
PR_SET_DUMPABLE=0fixtures verifying/proc/<pid>/environreturnsEACCES,kwin_wayland_wrapperparent fallback detects unset/0/1, a non-wrappershparent fails closed, and a directXwaylandchild fallback detects unset/1./proc+ private D-Bus fixtures coveringhidepid=2withtask/*/childrenverification, NixOS.kwin_wayland_wrapper-wrapped,PPidmismatch rejection, and direct/proc/<kwin_pid>/environprecedence.systemd.exec(5)EnvironmentFileparsing (comments, single/double quotes, escapes, multi-line quoted values,=\continuations, malformed input) and precedence (Manager.Environment->Environment->EnvironmentFile->UnsetEnvironment).org.freedesktop.systemd1integration tests exercisingGetUnitByPID,Properties.GetAll,.servicevs.scoperejection, andEnvironmentFileoverride.cargo fmt --all -- --check,cargo clippy --locked --all-targets -- -D warnings,RUSTDOCFLAGS="-D warnings" cargo doc --locked --no-deps --document-private-items,cargo test --locked --no-fail-fast,scripts/mcp_safety_check.py,scripts/check_plugins.sh,cargo publish --dry-run --locked.Review