feat(helper): implement Polkit authorization for CreateUser/DeleteUser#9
Merged
feat(helper): implement Polkit authorization for CreateUser/DeleteUser#9
Conversation
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
b3728f9 to
5eb5535
Compare
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.
Summary
CreateUserandDeleteUserare 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).PolkitQt6-1as 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 viamessage().service()(fromQDBusContext) and usesPolkitQt1::SystemBusNameSubjectfor identity verification.Changes
helper/CMakeLists.txtfind_package(PolkitQt6-1), conditional link +HAVE_POLKITQTdefinehelper/SystemOps.hcallerBusNameparameter tocheckAuthorization()helper/SystemOps.cpp#ifdef HAVE_POLKITQTguardhelper/CouchPlayHelper.cppmessage().service()toSystemOps::checkAuthorization()tests/CMakeLists.txttests/test_couchplayhelper.cppMockSystemOpssignatureTest plan
test_couchplayhelperbuilds with newMockSystemOpssignature