<div dir="ltr"><div dir="ltr">On Fri, Apr 2, 2021 at 7:17 PM Arseny Maslennikov <<a href="mailto:arseny@altlinux.org">arseny@altlinux.org</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi everyone!<br>
<br>
Recently there's a trend for session-specific processes and services<br>
(and even GUI apps, via `systemd-run --scope') to run as their own user<br>
units on eligible systems/distros, to have a clean and controlled cgroup<br>
hierarchy.<br>
<br>
I've been looking at <a href="https://systemd.io/DESKTOP_ENVIRONMENTS/" rel="noreferrer" target="_blank">https://systemd.io/DESKTOP_ENVIRONMENTS/</a> and see no<br>
answer to the following question: how can a process, e. g. gvfs-daemon,<br>
know which logind-session is it run for (for example, to find out the<br>
seat by session ID), if it's actually in a user service unit?<br>
The libsystemd source for sd_pid_get_session(), which is used by gvfs as<br>
of today, gives a hint that function won't work in that case, since a<br>
user service process's /proc/self/cgroup does not contain<br>
"session-XXX.scope".<br></blockquote><div><br></div><div>I don't think most daemons need to know this? Polkit has already changed its policy from allowing actions for specific active session, to allowing them for the whole uid if it owns *an* active session.<br></div><div><br></div><div>Also, part of the trend includes not running more than one graphical session per uid. So the daemon doesn't really need to ask, if there's only one answer. (Note that stuff like $DISPLAY gets imported into systemd --user's environment, to make it available to the services' environment, and you can't make $DISPLAY have two values at once.)</div><div><br></div><div>And if the daemon did know "its" session, that sounds like it would make it *less* useful with two sessions, because you would have no way to run a second instance for the other session anyway.</div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Mantas Mikulėnas</div></div></div>