device: Only interactively authorize if requested to do so

DBus sends a flags for whether interactive authorization is desired.
Adher to it instead of just assuming we can go ahead with doing an
interactive authoritzation.
This commit is contained in:
Benjamin Berg 2020-12-04 14:10:03 +01:00 committed by Marco Trevisan
parent b54a007ccf
commit 397995055c

View file

@ -819,6 +819,8 @@ _fprint_device_check_polkit_for_action (FprintDevice *rdev,
GError **error)
{
FprintDevicePrivate *priv = fprint_device_get_instance_private (rdev);
PolkitCheckAuthorizationFlags flags = POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE;
GDBusMessage *message;
const char *sender;
g_autoptr(GError) local_error = NULL;
@ -829,11 +831,15 @@ _fprint_device_check_polkit_for_action (FprintDevice *rdev,
sender = g_dbus_method_invocation_get_sender (invocation);
subject = polkit_system_bus_name_new (sender);
message = g_dbus_method_invocation_get_message (invocation);
if (g_dbus_message_get_flags (message) & G_DBUS_MESSAGE_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION)
flags |= POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION;
result = polkit_authority_check_authorization_sync (priv->auth,
subject,
action,
NULL,
POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
flags,
NULL, &local_error);
if (result == NULL)
{