void-packages/srcpkgs/polkit/patches/turnstile.patch

58 lines
2.1 KiB
Diff

commit 8d98aa421b92765695af13c033cf7e80375c03fe
Author: q66 <q66@chimera-linux.org>
Date: Sun Jul 2 15:44:51 2023 +0200
ensure turnstile-session processes fall back to display check
As turnstile session is shared between sessions, let us fall back
to the check for whether a graphical session is in place. We need
this as our dbus session bus is managed through turnstile. In
systemd-using systems there is no problem because user units are
not a part of any explicit session (we don't get this luxury
because using a session is the only way to make sure our pid is
tracked in systemd at all; we need that to be able to resolve
PID to UID).
diff --git a/src/polkitbackend/polkitbackendsessionmonitor-systemd.c b/src/polkitbackend/polkitbackendsessionmonitor-systemd.c
index b00cdbd..9a3f3c3 100644
--- a/src/polkitbackend/polkitbackendsessionmonitor-systemd.c
+++ b/src/polkitbackend/polkitbackendsessionmonitor-systemd.c
@@ -346,7 +346,7 @@ polkit_backend_session_monitor_get_session_for_subject (PolkitBackendSessionMoni
PolkitUnixProcess *tmp_process = NULL;
PolkitUnixProcess *process = NULL;
PolkitSubject *session = NULL;
- char *session_id = NULL;
+ char *session_id = NULL, *service_id = NULL;
pid_t pid;
#if HAVE_SD_UID_GET_DISPLAY
uid_t uid;
@@ -377,8 +377,26 @@ polkit_backend_session_monitor_get_session_for_subject (PolkitBackendSessionMoni
if (sd_pid_get_session (pid, &session_id) >= 0)
{
- session = polkit_unix_session_new (session_id);
- goto out;
+ /* if belonging to turnstile, ignore */
+ if (sd_session_get_service (session_id, &service_id) >= 0)
+ {
+ if (strcmp (service_id, "turnstiled"))
+ {
+ free (service_id);
+ session = polkit_unix_session_new (session_id);
+ goto out;
+ }
+ else
+ {
+ /* turnstile-managed processes are shared */
+ free(service_id);
+ }
+ }
+ else
+ {
+ session = polkit_unix_session_new (session_id);
+ goto out;
+ }
}
#if HAVE_SD_UID_GET_DISPLAY