Repository navigation
Strip dangerous caps from gsr-kms-server and btop - #12103
chessing234 wants to merge 8 commits into
Conversation
Arch grants the helper a root-equivalent capability; drop it on install/upgrade and prefer portal capture when the capability is absent so recording does not escalate through pkexec.
7094642 to
8a07b82
Compare
Automated AI review
Verified: on an existing install that runs the new migrations, both capabilities are stripped and stay stripped across later package upgrades. The The new hooks are not installed as pacman hooks, so fresh installs keep both capabilities
Fresh installs also never run the migrations: Impact: based on source reading, fresh installs keep Suggested change: add install lines for both hooks to the
|
| Input | Base | Head, capability present | Head, capability stripped |
|---|---|---|---|
--fullscreen |
-w <focused monitor> (KMS) |
same as base | -w portal |
| default, region picked | Omarchy picker, then -w WxH+X+Y |
same as base | -w portal, Omarchy picker not shown |
USE_PORTAL=true + --fullscreen |
-w <focused monitor> |
-w portal |
-w portal |
Impact:
--fullscreenwas added for agents (commit83e7f413), and Omarchy's agent skills tell agents to use it. The script does not pass-restore-portal-session, so the portal share picker opens (per gsr 6.1.3 and xdg-desktop-portal-hyprland source) and the script waits until a person picks or cancels.- Base keeps portal opt-in on purpose: the unchanged header comment says "Off by default because the portal path can fail EGL DMA-BUF modifier import on some configurations", and commit
6a5e5378is "Bypass portal by default for screenrecording due to portal bug". The PR's script comment says it prefers portal, but neither the PR nor the comment addresses that earlier decision or the portal failure behind it, and the change applies to every migrated install. How often that portal failure occurs was not established. - The region-picker flow in
manual/12-screenshots-recording.mdand the webcam overlay's region anchoring no longer describe the default.
The trade-off itself is defensible: without the capability, KMS capture makes gsr run gsr-kms-server through pkexec as full root, with an authentication prompt.
Suggested change: state the default change in the PR description so maintainers can decide on it, update the "Off by default" header comment and the manual, and document OMARCHY_SCREENRECORD_USE_KMS. Note that after the strip, agents have no non-interactive route: KMS needs a pkexec prompt and portal needs a pick, so the agent docs for --fullscreen need updating too. Passing -restore-portal-session yes could let later recordings reuse the previous selection (untested; the first recording would still need a pick, and the restored source is the last one picked, not the focused monitor).
The migration's /etc/pacman.d/hooks copies become a second, unowned source of truth
Both migrations write hooks into /etc/pacman.d/hooks/ using the same file names as the in-tree hooks, but without Depends = omarchy.
Impact (per pacman 7.1.0 source and alpm-hooks(5)):
- A same-named hook in
/etc/pacman.d/hooksoverrides a packaged one, so once the hooks are packaged, migrated systems keep running the/etccopy. The[[ ! -f $hook ]]guard means later hook changes never reach them. - No package owns the copies, so they survive removal of
omarchyand then pointExecat a missing binary whenever btop or gpu-screen-recorder is installed or upgraded (a non-fatal pacman error). - A
/dev/nullmask symlink fails-f, so the migration replaces an administrator's mask. In a sandbox case with a dangling symlink in place of the hook, the migration replaced the symlink and stripped the capability. - Because the hook re-strips on every gpu-screen-recorder upgrade, the documented
OMARCHY_SCREENRECORD_USE_KMS=true"after restoring the capability" lasts only until the next upgrade, after which each recording goes throughpkexec.
Suggested change: once the hooks are packaged, reduce each migration to stripping the current capability. If the /etc copies are kept, add Depends = omarchy and plan how they are removed.
btop loses CPU package power and Intel GPU monitoring
setcap -r removes all of btop's file capabilities, including cap_perfmon, not only CAP_DAC_READ_SEARCH as the commit title says. btop's README describes these capabilities as needed for Intel GPU and CPU wattage (btop 1.4.7 source):
- CPU package power reads
intel-raplenergy_uj, which the kernel exposes as mode 0400. - Intel GPU stats open CPU-wide perf events, which need
CAP_PERFMONat the defaultperf_event_paranoidof 2.
Impact: Omarchy's shipped config/btop/btop.conf enables show_cpu_watts and Intel GPU display. After this change, btop run as a normal user no longer shows either (source reading, not run on hardware).
Suggested change: state this trade-off in the PR, or keep cap_perfmon (for example setcap cap_perfmon=ep /usr/bin/btop) and drop only the DAC bypass. That keeps Intel GPU stats; CPU package power would still need the DAC bypass. Either is a maintainer judgement call.
Optional test improvement: test/shell.d/gsr-kms-caps-test.sh and the config-test.sh additions only check file presence and grep for strings. A mutant that inverts the portal fallback, turns the strip helper into a no-op, moves the hook to PreTransaction and reduces the migration to its echo line still passes gsr-kms-caps-test.sh (exit 0). Making the hard-coded /usr/bin/gsr-kms-server path overridable, stubbing getcap on PATH and asserting the recorder's -w argument (as screenrecording-test.sh already runs the script with a stub recorder), plus a migration test with recorded sudo/setcap stubs, would cover the behavior.
Review information
Test scope: Pinned head 8a07b82e. Source review of the PR, omarchy-pkgs packaging, omarchy-iso, gpu-screen-recorder 6.1.3 with its Arch packaging, btop 1.4.7 with its Arch packaging, pacman 7.1.0, libcap and xdg-desktop-portal-hyprland. Sandboxed runs with stubbed sudo, setcap, getcap and recorder: a backend-selection matrix for base, head and a mutant, a migration harness, a test-mutation run and the repository's bin-style-test.sh. No real pacman transaction, capability change, pkexec prompt, portal session or btop hardware reading was exercised.
AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.
Opt out: To stop receiving these reviews, reply to this comment saying so.
|
switched the new bin helpers to omarchy-cmd-present so bin-style-test passes. packaging the alpm hooks in omarchy-pkgs is still a separate follow-up. |
|
cmd-present fix is up. hook packaging + btop/portal behaviour are maintainer calls / omarchy-pkgs work. |
Automated AI review
Follow-up to the earlier review, checked at head
Verified: Optional: a simpler option also exists. Hook packaging (reply to the author's comment)The reply calls hook packaging a separate omarchy-pkgs follow-up. No companion omarchy-pkgs PR or branch was found. At omarchy-pkgs
Impact: as in the earlier review, fresh installs keep Suggested change: open the omarchy-pkgs PR that adds both hooks to the Correction:
|
[Medium impact] The changes affect two desktop utilities and the screen-recording workflow. The PR still needs fixes because recording can lose its fallback, and Findings
SummaryThis PR removes file capabilities from
Reviews (3) · Last reviewed commit: "Keep wf-recorder-only setups off the GSR..." · Reviewed by Greptile |
| elif [[ ${OMARCHY_SCREENRECORD_USE_KMS:-false} != "true" ]] && | ||
| ! gsr_kms_has_sys_admin; then | ||
| use_portal=true |
There was a problem hiding this comment.
Recorder fallback stops working
When gsr-kms-server is missing or its capabilities have been stripped, the new default sets target="portal". The recorder loop then skips wf-recorder. Machines where gpu-screen-recorder is unavailable or rejects the GPU, including Apple Silicon, can no longer record even when wf-recorder is installed.
Keep monitor/region targets available when choosing or falling back to wf-recorder; it does not need the KMS helper.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| if [[ $FULLSCREEN == "true" && $use_portal != "true" ]]; then | ||
| target="monitor:$(omarchy-hyprland-monitor-focused)" | ||
| capture_args=(-w "${target#monitor:}" -s "${RESOLUTION:-$(default_resolution)}") | ||
| elif [[ ${OMARCHY_SCREENRECORD_USE_PORTAL:-false} == "true" ]]; then | ||
| elif [[ $use_portal == "true" ]]; then | ||
| target="portal" | ||
| capture_args=(-w portal -s "${RESOLUTION:-$(default_resolution)}") |
There was a problem hiding this comment.
Full-screen recording waits for input
After the migration strips CAP_SYS_ADMIN, --fullscreen takes the portal branch instead of recording the focused monitor. It passes -w portal, so recording waits for the user to choose a source. This breaks the documented picker-free command used for automated screen recordings.
Preserve a noninteractive full-screen path without restoring the privileged helper.
| grep -Fq 'gsr_kms_has_sys_admin' "$capture" || | ||
| fail "screenrecording must detect whether gsr-kms-server still has CAP_SYS_ADMIN" | ||
| grep -Fq 'OMARCHY_SCREENRECORD_USE_KMS' "$capture" || | ||
| fail "screenrecording must allow forcing KMS after restoring the capability" | ||
| grep -Fq 'use_portal=true' "$capture" || | ||
| fail "screenrecording must fall back to portal when CAP_SYS_ADMIN is absent" | ||
| pass "screenrecording avoids pkexec when gsr-kms-server has no CAP_SYS_ADMIN" |
There was a problem hiding this comment.
Tests check text, not behavior
These checks search for source strings instead of running the behavior they claim to test. Capability detection or the portal choice can break while the checks stay green.
AGENTS.md forbids tests that restate the implementation through source searches. It also requires extending the area's existing test file. Replace these checks with behavior checks in screenrecording-test.sh; the added hook-string checks in config-test.sh repeat the same pattern. These repository requirements must be satisfied before merging.
File Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
Test plan
test/shell.d/config-test.sh(both hook checks)test/shell.d/gsr-kms-caps-test.sh