<div dir="ltr"><div dir="ltr">On Mon, Oct 12, 2020 at 8:16 PM Thomas HUMMEL <<a href="mailto:thomas.hummel@pasteur.fr">thomas.hummel@pasteur.fr</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">Thanks for your answer. Still I'm quite confused.<br>
<br>
On 12/10/2020 18:21, Mantas Mikulėnas wrote:<br>
<br>
<br>
> It's a worker process which calls pam_open_session() and <br>
> pam_close_session() on behalf of the user@<uid>.service unit.<br>
<br>
Well I may be misunderstanding but this user@<uid>.service seems like a <br>
top level (for this user) placeholder for various other services units <br>
and/or scope, among which the init.scope corresponding to the sd-pam and <br>
systemd --user processes).<br></blockquote><div><br></div><div>Yes, but it is *not* a top level for *all* of the user's processes – just for those that are managed through systemctl --user.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
So you mean that any service in this placeholder can and do use the <br>
sd-pam helper to call pam_open_session() and pam_close_session instead <br>
of doing it themselves, passing it the relevant PAMName ?<br></blockquote><div><br></div><div>No, I'm talking about system (global) services.</div><div><br></div><div>user@<uid>.service, itself, is a system service.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
> So when you see sd-pam under user@<uid>.service, that means it's <br>
> handling the "systemd-user" PAM service.<br>
<br>
I'm not sure I understood in which cases this PAM service name is used<br></blockquote><div><br></div><div>It's used in only one case: when starting the "user@<uid>.service" unit.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
> They're different but related. Systemd user sessions are always managed <br>
> through PAM (the pam_systemd module), so whenever cron calls <br>
> pam_open_session() it indirectly starts a systemd session as well.<br>
<br>
You mean crond running as the user who has his own crontab does call <br>
pam_open_session() which is defined in the pam_systemd module ?<br>
If this is correct, this has indeed nothing to do with the sd-pam <br>
pam_open_seesion() mentionned above or does it ?<br>
<br></blockquote><div><br></div><div>Yes, they're completely separate PAM instances.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> <br>
>     - what does the first error message refers to and why does the<br>
>     systemd-user pam service name get passed ? and by which systemd (system<br>
>     or user) ?<br>
> <br>
> <br>
> Your systemd --user instance is run as a service<br>
<br>
Yes I understood that. But again I'm not really sure what services or <br>
other units it is supposed to run if I didn't defined user custom <br></blockquote><div><br></div><div>Well, that doesn't mean it shouldn't be started at all – for a few reasons:</div><div><br></div><div>1) pam_systemd doesn't know that you don't have any custom units.</div><div>2) Even if you don't have any units in ~/.config/systemd, there might be package-installed ones in /usr/lib/systemd/user (such as gpg-agent.socket).</div><div>3) systemd --user can also be used for transient units via `systemd-run`.<br></div><div><br></div><div>Though, it's true that most of those things are about interactive logins. Actually I kind of wish that pam_systemd would have an option to *only* create the user-<uid>.slice cgroup but without starting user@.service... (Arch Linux's /etc/pam.d/crond does not list pam_systemd at all, and it hasn't really created any issues so far.)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
services. Is it responsible to run things like the user's UI termnials <br>
for instance ?<br></blockquote><div><br></div><div>Generally no. Even though your login processes belong to a "user session", they are not managed by user@<uid>.service in any way.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<br>
> Because of that, the service needs to have its own PAM service name and <br>
> makes its own PAM calls independently from crond or anything else.<br>
<br>
Ok so it's this service (systemd --user) which uses the systemd-user PAM <br>
service name ? Passed to the generic sd-pam worker ? Correct ?<br></blockquote><div><br></div><div>Yes.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> <br>
>     - what is the failing systemd job the second message refers to ? Does<br>
>     this mean that the crond "session" gets created by the systemd --user<br>
>     instance (as some gnome apps in other contexts for instance) ?<br>
> <br>
> <br>
> No, it's mostly the opposite – the starting of user@<uid>.service is <br>
> triggered by crond opening its PAM session.<br>
<br>
Sorry I don't get it : what service exactly is started ? crond opening <br>
its PAM session does not cause a systemd --user to be instanciated or <br></blockquote><div><br></div><div>It does *if* your distro's /etc/pam.d/cron[d] includes the pam_systemd module. (So on Debian it does, on Arch it doesn't.)</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
does it ? I thought the only way to have a systemd --user was through <br>
the creation via pam_systemd notifying systemd-logind at a user fist <br>
login (and/or to linger the user)<br></blockquote><div><br></div><div>Yes but that's exactly what happens in cron as well. When crond calls PAM, it does exactly the same thing as when a user logs in interactively – it calls PAM open_session in pretty much the same way as e.g. sshd or console login would. The only difference is the PAM service name (and therefore a different /etc/pam.d config file).</div><div><br></div></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Mantas Mikulėnas</div></div></div>