summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Bacher <seb128@ubuntu.com>2018-04-02 10:52:47 -0400
committerRay Strode <rstrode@redhat.com>2018-04-02 17:32:25 -0400
commit3345c10cf93dd42cb37f06c7074669ae315c3280 (patch)
treed0a9c22d84c5dc872d14fa80aa9a52d15f02afa9
parent8600ad832a49bccef795a3ef5b81533283f57409 (diff)
downloadpolkit-3345c10cf93dd42cb37f06c7074669ae315c3280.tar.gz
Support polkit session agent running outside user session
commit a68f5dfd7662767b7b9822090b70bc5bd145c50c 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. https://bugs.freedesktop.org/show_bug.cgi?id=96977
-rw-r--r--src/polkit/polkitunixsession-systemd.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/polkit/polkitunixsession-systemd.c b/src/polkit/polkitunixsession-systemd.c
index 8a8bf65..c34f36a 100644
--- a/src/polkit/polkitunixsession-systemd.c
+++ b/src/polkit/polkitunixsession-systemd.c
@@ -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;
+ }
+
+error:
g_set_error (error,
POLKIT_ERROR,
POLKIT_ERROR_FAILED,