sysprofd: actually check authorization result

This commit is contained in:
Christian Hergert
2019-05-17 14:36:42 -07:00
parent 7e5317cc7e
commit 931112b195

View File

@ -201,6 +201,7 @@ static gboolean
ipc_service_impl_g_authorize_method (GDBusInterfaceSkeleton *skeleton, ipc_service_impl_g_authorize_method (GDBusInterfaceSkeleton *skeleton,
GDBusMethodInvocation *invocation) GDBusMethodInvocation *invocation)
{ {
PolkitAuthorizationResult *res = NULL;
PolkitAuthority *authority = NULL; PolkitAuthority *authority = NULL;
PolkitSubject *subject = NULL; PolkitSubject *subject = NULL;
const gchar *peer_name; const gchar *peer_name;
@ -213,13 +214,14 @@ ipc_service_impl_g_authorize_method (GDBusInterfaceSkeleton *skeleton,
if (!(authority = polkit_authority_get_sync (NULL, NULL)) || if (!(authority = polkit_authority_get_sync (NULL, NULL)) ||
!(subject = polkit_system_bus_name_new (peer_name)) || !(subject = polkit_system_bus_name_new (peer_name)) ||
!polkit_authority_check_authorization_sync (authority, !(res = polkit_authority_check_authorization_sync (authority,
POLKIT_SUBJECT (subject), POLKIT_SUBJECT (subject),
"org.gnome.sysprof3.profile", "org.gnome.sysprof3.profile",
NULL, NULL,
POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION, POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION,
NULL, NULL,
NULL)) NULL)) ||
!polkit_authorization_result_get_is_authorized (res))
{ {
g_dbus_method_invocation_return_error (g_steal_pointer (&invocation), g_dbus_method_invocation_return_error (g_steal_pointer (&invocation),
G_DBUS_ERROR, G_DBUS_ERROR,
@ -230,6 +232,7 @@ ipc_service_impl_g_authorize_method (GDBusInterfaceSkeleton *skeleton,
g_clear_object (&authority); g_clear_object (&authority);
g_clear_object (&subject); g_clear_object (&subject);
g_clear_object (&res);
return ret; return ret;
} }