Skip to content

feat(helper): implement Polkit authorization for CreateUser/DeleteUser#9

Merged
hikaps merged 4 commits intodevelopfrom
feature/polkit-create-delete-user
Apr 22, 2026
Merged

feat(helper): implement Polkit authorization for CreateUser/DeleteUser#9
hikaps merged 4 commits intodevelopfrom
feature/polkit-create-delete-user

Conversation

@hikaps
Copy link
Copy Markdown
Owner

@hikaps hikaps commented Apr 19, 2026

Summary

  • Implements Option A Polkit authorization: only CreateUser and DeleteUser are gated with Polkit prompts. All other D-Bus methods (ChangeDeviceOwner, LaunchInstance, MountSharedDirectories, etc.) continue to rely on the D-Bus system bus ACL (wheel/games groups).
  • Uses PolkitQt6-1 as an optional build dependency — when unavailable, the helper compiles and runs identically to before (trusts D-Bus ACL for all actions).
  • checkAuthorization() now receives the caller's D-Bus bus name via message().service() (from QDBusContext) and uses PolkitQt1::SystemBusNameSubject for identity verification.

Changes

File Change
helper/CMakeLists.txt Optional find_package(PolkitQt6-1), conditional link + HAVE_POLKITQT define
helper/SystemOps.h Added callerBusName parameter to checkAuthorization()
helper/SystemOps.cpp Real Polkit check for create-user/delete-user; #ifdef HAVE_POLKITQT guard
helper/CouchPlayHelper.cpp Forwards message().service() to SystemOps::checkAuthorization()
tests/CMakeLists.txt Optional PolkitQt6-1 for helper test
tests/test_couchplayhelper.cpp Updated MockSystemOps signature

Test plan

  • Full project build passes (with PolkitQt6-1 installed)
  • Full project build passes (without PolkitQt6-1 — optional fallback)
  • 7/7 existing CI tests pass with no regressions
  • test_couchplayhelper builds with new MockSystemOps signature
  • CI passes on this PR

hikaps added 4 commits April 22, 2026 12:10
Option A: only gate user management with Polkit. All other actions
(ChangeDeviceOwner, LaunchInstance, MountSharedDirectories, etc.)
continue to rely on the D-Bus system bus ACL (wheel/games groups).

When PolkitQt6-1 is available at build time, checkAuthorization()
performs real Polkit checks for create-user and delete-user actions.
When unavailable, falls back to trusting the D-Bus ACL (same as before).
- Deny user-management actions when PolkitQt6 is not compiled in (was
  return true, allowing any user in the games group to create/delete
  accounts without admin authentication)
- Check Authority::hasError() before calling checkAuthorizationSync()
  to handle polkitd unavailability gracefully
- Log distinct messages for Unknown result (daemon down) vs explicit
  denial vs authority error
- Extract action string constants to shared PolkitActions.h header,
  eliminating magic string duplication between CouchPlayHelper and
  SystemOps
- Replace 'Option A' design-discussion comment with proper threat
  model documentation
- Move find_package(PolkitQt6-1) to root CMakeLists.txt with a
  WARNING message when not found (makes security implications visible
  at configure time)
- Remove duplicate find_package from helper/ and tests/ CMakeLists
- Add PolkitActions.h to helper source list
@hikaps hikaps force-pushed the feature/polkit-create-delete-user branch from b3728f9 to 5eb5535 Compare April 22, 2026 19:11
@hikaps hikaps merged commit 7bc2711 into develop Apr 22, 2026
1 check passed
@hikaps hikaps deleted the feature/polkit-create-delete-user branch April 22, 2026 20:07
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