summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index ef466b4..d748afd 100644
--- a/src/util.c
+++ b/src/util.c
@@ -251,3 +251,34 @@ get_user_groups (const gchar *user,
return res;
}
+
+
+gboolean
+get_caller_uid (DBusGMethodInvocation *context, gint *uid)
+{
+ PolkitSubject *subject;
+ PolkitSubject *process;
+ GError *error;
+
+ subject = polkit_system_bus_name_new (dbus_g_method_get_sender (context));
+ process = polkit_system_bus_name_get_process_sync (POLKIT_SYSTEM_BUS_NAME (subject), NULL, NULL);
+ if (!process) {
+ g_object_unref (subject);
+ return FALSE;
+ }
+
+ error = NULL;
+ *uid = polkit_unix_process_get_owner (POLKIT_UNIX_PROCESS (process), &error);
+ if (error) {
+ g_error_free (error);
+ g_object_unref (subject);
+ g_object_unref (process);
+
+ return FALSE;
+ }
+
+ g_object_unref (subject);
+ g_object_unref (process);
+
+ return TRUE;
+}