Skip to content

Commit d003aa1

Browse files
muelliradosroka
authored andcommitted
dbus: check whether the client wanted interactive authentication
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. The flag is available since 2.46: https://libsoup.org/gio/GDBusMessage.html#GDBusMessageFlags Hence, we update the dependency in configure.ac.
1 parent 673431e commit d003aa1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Diff for: configure.ac

+1-1
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ if test "x$with_dbus" = xyes; then
467467
#
468468
# Check for required D-Bus modules
469469
#
470-
PKG_CHECK_MODULES([dbus], [dbus-1 gio-2.0 polkit-gobject-1],
470+
PKG_CHECK_MODULES([dbus], [dbus-1 gio-2.0 >= 2.46 polkit-gobject-1],
471471
[AC_DEFINE([HAVE_DBUS], [1], [Required GDBus API available])
472472
dbus_summary="system-wide; $dbus_CFLAGS $dbus_LIBS"],
473473
[AC_MSG_FAILURE([Required D-Bus modules (dbus-1, gio-2.0, polkit-gobject-1) not found!])]

Diff for: src/DBus/DBusBridge.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,11 @@ namespace usbguard
517517
polkit_details_insert (details, "polkit.message", "This USBGuard action needs authorization");
518518
USBGUARD_LOG(Trace) << "Customized.";
519519
USBGUARD_LOG(Trace) << "Checking authorization of action \"" << action_id.str() << "\" with Polkit ...";
520-
const PolkitCheckAuthorizationFlags flags = POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION;
520+
GDBusMessage* const message = g_dbus_method_invocation_get_message (invocation);
521+
const PolkitCheckAuthorizationFlags flags = (g_dbus_message_get_flags (message) &
522+
G_DBUS_MESSAGE_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION)
523+
? POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION
524+
: POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE;
521525
PolkitAuthorizationResult* const result = polkit_authority_check_authorization_sync
522526
(authority,
523527
subject,

0 commit comments

Comments
 (0)