Skip to content

ak-sysd: add permission relay - #1564

Open
BeryJu wants to merge 4 commits into
mainfrom
ak-sysd/relay
Open

BeryJu wants to merge 4 commits into
mainfrom
ak-sysd/relay

Conversation

@BeryJu

@BeryJu BeryJu commented Sep 26, 2026

Copy link
Copy Markdown
Member

No description provided.

BeryJu and others added 4 commits August 25, 2026 18:26
ak-agent-desktop runs unprivileged and can't open sysd's CTRL socket
(SysdSocketID::CTRL, SocketPermMode::Admin), which currently only the
root-run `ak-sysd domains join` CLI can reach. Add a temporary,
per-session elevation path instead of running the whole app elevated:

- New `ak-sysd-ctrl-relay` binary that pumps bytes between an
  unprivileged rendezvous endpoint and the real CTRL socket.
- `ak_platform::net::elevate` drives it per platform (pkexec on Linux,
  a locked-down rendezvous pipe + ShellExecuteExW("runas") on Windows,
  an SMAppService-registered daemon reached over XPC on macOS) and
  hands back a plain tonic Channel, so `Client::new_elevated_ctrl()`
  is a drop-in for existing SystemCtrlClient<Channel> call sites.
- New polkit action `io.goauthentik.platform.sysd-ctrl-relay`
  (auth_admin_keep), distinct from the existing self-auth-only
  `io.goauthentik.platform.authorize` action used by ak-platform-authz.

Linux path is compiled, clippy-clean, and covered by the existing net
test suite. Windows and macOS code is hand-verified against their
respective APIs but not built/run (no toolchain in this environment) —
flagged inline the same way agent_starter/win.rs already does.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Adds the relay helper binary (and, on macOS, its embedded LaunchDaemon
plist) to each platform's build/package pipeline, and registers the
macOS SMAppService daemon from ak-agent-desktop at startup:

- Linux: build target + nfpm entry shipping it in the agent-desktop
  package at /usr/bin/ak-sysd-ctrl-relay, root-owned 0755 so pkexec
  trusts it per its target-path requirements.
- Windows: build target + signing + a File entry in the existing sysd
  Component, landing at the exact path net::elevate::windows expects
  alongside ak-sysd.
- macOS: build target + copies the binary into Contents/MacOS and its
  launchd plist into Contents/Library/LaunchDaemons, matching what
  SMAppService.daemon(plistName:) expects to find in the app bundle.
  ak-agent-desktop now calls ensure_registered() at startup
  (best-effort — a pending user approval shouldn't block the rest of
  the app).

Whole workspace (minus the Windows-only ee/wcp crates, which can't
build off Windows) still checks and clippetes clean.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
# Conflicts:
#	Cargo.lock
#	Makefile
#	ak-platform/Cargo.toml
@codecov

codecov Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 1.76991% with 222 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.04%. Comparing base (48038e1) to head (9708099).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
ak-platform/src/net/xpc.rs 0.00% 132 Missing ⚠️
ak-platform/src/net/elevate/macos.rs 0.00% 33 Missing ⚠️
ak-platform/src/net/elevate/linux.rs 0.00% 22 Missing ⚠️
ak-platform/src/net/elevate/mod.rs 0.00% 18 Missing ⚠️
ak-platform/src/paths.rs 0.00% 6 Missing ⚠️
ak-agent-desktop/src-tauri/src/lib.rs 0.00% 5 Missing ⚠️
ak-platform/src/client/sysd.rs 0.00% 4 Missing ⚠️
ak-platform/src/grpc/mod.rs 66.66% 0 Missing and 2 partials ⚠️

❗ There is a different number of reports uploaded between BASE (48038e1) and HEAD (9708099). Click for more details.

HEAD has 12 uploads less than BASE
Flag BASE (48038e1) HEAD (9708099)
rs-windows-2025-ak-platform 1 0
rs-windows-2025-ak-meta 1 0
rs-windows-2025-ak-browser-support 1 0
rs-windows-2025-ak-platform-authz 1 0
rs-windows-2025-ak-sysd 1 0
rs-windows-2025-ak-flow-executor 1 0
rs-windows-2025-ak-platform-keyring 1 0
rs-windows-2025-ak-agent 1 0
rs-windows-2025-ak-platform-facts 1 0
rs-windows-2025-ee/wcp 1 0
rs-windows-2025-ak-cli 1 0
rs-windows-2025-ak-agent-desktop 1 0
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1564      +/-   ##
==========================================
- Coverage   45.76%   40.04%   -5.73%     
==========================================
  Files         193      168      -25     
  Lines       15694    11733    -3961     
  Branches    14963    11002    -3961     
==========================================
- Hits         7183     4698    -2485     
+ Misses       8139     6793    -1346     
+ Partials      372      242     -130     
Flag Coverage Δ
rs-macos-26-ak-agent 32.15% <ø> (ø)
rs-macos-26-ak-agent-desktop 0.00% <0.00%> (ø)
rs-macos-26-ak-api-cli 100.00% <ø> (ø)
rs-macos-26-ak-api-cli-gen 66.71% <ø> (ø)
rs-macos-26-ak-browser-support 23.93% <ø> (ø)
rs-macos-26-ak-cli 24.11% <ø> (ø)
rs-macos-26-ak-flow-executor 13.62% <ø> (ø)
rs-macos-26-ak-meta 0.00% <ø> (ø)
rs-macos-26-ak-meta-macros 0.00% <ø> (ø)
rs-macos-26-ak-platform 58.88% <2.02%> (-6.74%) ⬇️
rs-macos-26-ak-platform-authz 0.00% <ø> (ø)
rs-macos-26-ak-platform-facts 83.44% <ø> (ø)
rs-macos-26-ak-platform-keyring 65.64% <ø> (ø)
rs-macos-26-ak-sysd 36.69% <ø> (ø)
rs-ubuntu-24.04-ak-agent 32.15% <ø> (+1.99%) ⬆️
rs-ubuntu-24.04-ak-agent-desktop 0.00% <0.00%> (ø)
rs-ubuntu-24.04-ak-api-cli 100.00% <ø> (ø)
rs-ubuntu-24.04-ak-api-cli-gen 66.71% <ø> (ø)
rs-ubuntu-24.04-ak-browser-support 23.93% <ø> (ø)
rs-ubuntu-24.04-ak-cli 24.11% <ø> (ø)
rs-ubuntu-24.04-ak-flow-executor 13.62% <ø> (ø)
rs-ubuntu-24.04-ak-meta 0.00% <ø> (ø)
rs-ubuntu-24.04-ak-meta-macros 0.00% <ø> (ø)
rs-ubuntu-24.04-ak-nss 77.37% <ø> (ø)
rs-ubuntu-24.04-ak-pam 0.00% <ø> (ø)
rs-ubuntu-24.04-ak-platform 63.07% <7.27%> (-1.85%) ⬇️
rs-ubuntu-24.04-ak-platform-authz 0.00% <ø> (ø)
rs-ubuntu-24.04-ak-platform-facts 82.64% <ø> (ø)
rs-ubuntu-24.04-ak-platform-keyring 53.08% <ø> (ø)
rs-ubuntu-24.04-ak-sysd 36.94% <ø> (ø)
rs-ubuntu-24.04-arm-ak-agent 32.15% <ø> (ø)
rs-ubuntu-24.04-arm-ak-agent-desktop 0.00% <0.00%> (ø)
rs-ubuntu-24.04-arm-ak-api-cli 100.00% <ø> (ø)
rs-ubuntu-24.04-arm-ak-api-cli-gen 66.71% <ø> (ø)
rs-ubuntu-24.04-arm-ak-browser-support 23.93% <ø> (ø)
rs-ubuntu-24.04-arm-ak-cli 24.11% <ø> (ø)
rs-ubuntu-24.04-arm-ak-flow-executor 13.62% <ø> (ø)
rs-ubuntu-24.04-arm-ak-meta 0.00% <ø> (ø)
rs-ubuntu-24.04-arm-ak-meta-macros 0.00% <ø> (ø)
rs-ubuntu-24.04-arm-ak-nss 77.37% <ø> (ø)
rs-ubuntu-24.04-arm-ak-pam 0.00% <ø> (ø)
rs-ubuntu-24.04-arm-ak-platform 63.07% <7.27%> (-1.85%) ⬇️
rs-ubuntu-24.04-arm-ak-platform-authz 0.00% <ø> (ø)
rs-ubuntu-24.04-arm-ak-platform-facts 82.64% <ø> (ø)
rs-ubuntu-24.04-arm-ak-platform-keyring 53.08% <ø> (ø)
rs-ubuntu-24.04-arm-ak-sysd 36.94% <ø> (ø)
rs-windows-2025-ak-agent ?
rs-windows-2025-ak-agent-desktop ?
rs-windows-2025-ak-api-cli 100.00% <ø> (ø)
rs-windows-2025-ak-api-cli-gen 66.71% <ø> (ø)
rs-windows-2025-ak-browser-support ?
rs-windows-2025-ak-cli ?
rs-windows-2025-ak-flow-executor ?
rs-windows-2025-ak-meta ?
rs-windows-2025-ak-meta-macros 0.00% <ø> (ø)
rs-windows-2025-ak-platform ?
rs-windows-2025-ak-platform-authz ?
rs-windows-2025-ak-platform-facts ?
rs-windows-2025-ak-platform-keyring ?
rs-windows-2025-ak-sysd ?
rs-windows-2025-ee/wcp ?
swift 3.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant