Commit 3345c10c authored by Sebastien's avatar Sebastien Committed by Ray Strode

Support polkit session agent running outside user session

commit a68f5dfd made
session applications that are running from a user bus
work with polkitd, by falling back to using the currently
active session.

This commit is similar, but for the polkit agent.  It allows,
a polkit agent to be run from a systemd --user service
that's not running directly in the users session.
parent 8600ad83
......@@ -451,6 +451,7 @@ polkit_unix_session_initable_init (GInitable *initable,
PolkitUnixSession *session = POLKIT_UNIX_SESSION (initable);
gboolean ret = FALSE;
char *s;
uid_t uid;
if (session->session_id != NULL)
......@@ -467,6 +468,19 @@ polkit_unix_session_initable_init (GInitable *initable,
goto out;
/* Now do process -> uid -> graphical session (systemd version 213)*/
if (sd_pid_get_owner_uid (session->pid, &uid) < 0)
goto error;
if (sd_uid_get_display (uid, &s) >= 0)
session->session_id = g_strdup (s);
free (s);
ret = TRUE;
goto out;
g_set_error (error,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment