[systemd-devel] systemd pam and O_CLOEXEC problem

David Herrmann dh.herrmann at gmail.com
Mon May 12 04:58:02 PDT 2014


Hi

On Mon, May 12, 2014 at 1:49 PM, Sergei Kabanov <s.kabanov70 at mail.ru> wrote:
> Hello
> But all children will have that descriptor open. So when parent process will
> die logind will not be notified.

And? That's intentional. If you want to close the session if the main
process dies, use something like /bin/login does: call
pam_close_session() on SIGCHLD.

Note that if we set O_CLOEXEC, then the exec() after the pam-dance
will immediately close the FIFO, thus also close the session. So we
cannot set O_CLOEXEC. So please call pam_close_session() to notify
systemd about session-deaths, or use something like this:

for i in /proc/self/fd/* ; do close($i); done

to close all file-descriptors before you exec(). But this is really
just a nasty hack.

Thanks
David


More information about the systemd-devel mailing list