Subject: bug#540: elogind unmounts /run/user/$UID tmpfs filesystem after logging in again

From: Frank <[email-masked]>
Date: Wed, 20 Jan 2021 16:31:25 +0100

Hi Mark,

I played around with the slim PAM configuration and found a possible 
solution: change the elogind class from "user" to "greeter". Slim does 
not fork a helper process so changing it makes sense to me. When a new 
session is created, previous sessions close in the background, even if 
the logout/login cycle is rapid. Looks promising?

This is what I changed (needs polishing, obviously):

--- common-session	2020-05-30 17:32:28.000000000 +0200
+++ common-session-slim	2021-01-20 16:01:33.521567369 +0100
@@ -22,5 +22,5 @@
  session	required			pam_permit.so
  # and here are more per-package modules (the "Additional" block)
  session	required	pam_unix.so
-session	optional			pam_elogind.so
+session	optional	pam_elogind.so class=greeter
  # end of pam-auth-update config

--- slim.orig	2020-01-07 12:09:49.000000000 +0100
+++ slim	2021-01-20 15:55:39.223866000 +0100
@@ -14,7 +14,7 @@
  session [success=ok ignore=ignore module_unknown=ignore default=bad]    
pam_selinux.so close
  session required        pam_limits.so
  session required        pam_loginuid.so
-@include common-session
+@include common-session-slim
  # SELinux needs to intervene at login time to ensure that the process
  # starts in the proper default security context. Only sessions which 
are
  # intended to run in the user's context should be run after this.

The result:
---------------------------- snip -------------------------------
devuan@devuan:~$ loginctl list-sessions; loginctl session-status
SESSION  UID USER   SEAT  TTY
       1 1000 devuan seat0
      c3 1000 devuan seat0

2 sessions listed.
c3 - devuan (1000)
            Since: Wed 2021-01-20 16:04:01 CET; 2s ago
           Leader: 4556 (slim)
             Seat: seat0; vc7
          Display: :0.0
           Remote: user root
          Service: slim; type x11; class greeter
            State: active
---------------------------- snip -------------------------------

Regards,
Frank

> I agree with you that the issue it not easy to fix. I ran into it when
> I was configuring my .xsessionrc and could not figure out what I did
> wrong in order to break the runtime directory. I usually just login
> once a day at most, so I won't run into the issue very often.
> 
> At least the workaround - add "UserStopDelaySec=infinity" to section
> [Login] in config file /etc/elogind/logind.conf - works, but isn't
> great either. Perhaps it would be best to deprecate Slim and switch
> the default DM to either LightDM or SDDM?
> 
> Anyway, I'll play around with the Slim config and PAM config some more
> (until I get bored). If I find a solution (against all odds) I'll let
> you know.
>