Skip to content

Commit

Permalink
dbus: check whether the client wanted interactive authentication
Browse files Browse the repository at this point in the history
Some clients do not want to prompt for passwords, e.g. when authorising keyboards
when the screen is locked, prompting for a password doesn't make sense because
the user cannot enter anything.
This change extracts the flags and checks whether the client called with
G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION.
  • Loading branch information
muelli committed Apr 15, 2022
1 parent 4982b01 commit 0a86714
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/DBus/DBusBridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,11 @@ namespace usbguard
polkit_details_insert (details, "polkit.message", "This USBGuard action needs authorization");
USBGUARD_LOG(Trace) << "Customized.";
USBGUARD_LOG(Trace) << "Checking authorization of action \"" << action_id.str() << "\" with Polkit ...";
const PolkitCheckAuthorizationFlags flags = POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION;
GDBusMessage *message = g_dbus_method_invocation_get_message (invocation);
const PolkitCheckAuthorizationFlags flags = (g_dbus_message_get_flags (message) & G_DBUS_MESSAGE_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION)
? POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION
: POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE;

PolkitAuthorizationResult* const result = polkit_authority_check_authorization_sync
(authority,
subject,
Expand Down

0 comments on commit 0a86714

Please sign in to comment.