On Thu, Jul 11, 2024 at 04:53:51PM +0200, Paul Sopka wrote: > Since I was not 100% convinced by Turnstile, I made an attempt on a very > simple alternative way to handle user session tracking. > > The (currently very crude) script only runs once on each login and logout > and does the following: > > On login: > > - Possibly create a /run/session/${USER} directory. > > - Possibly start the user supervision tree (from S6/s6-rc or OpenRC, or > anything but itself). > > - If it does not exist, create a file named after the login type (e.g. sshd) > at /run/session/${USER}/${LOGIN_TYPE}. > > - Write a line (any content, but just one line) to > /run/session/${USER}/${LOGIN_TYPE}. > > - If the line count inĀ /run/session/${USER}/${LOGIN_TYPE} is 1, start the > bundle corresponding to ${LOGIN_TYPE} e.g. sshd. These two last points, if you really decide to implement them like that in the final version, may require some synchronization, e.g. via file locking. It is not impossible (I mean, it is quite unlikely, but especially with automated CI systems not impossible *at all*) for two SSH sessions to come in practically at once, and I have indeed seen shell startup scripts run the same program at the same time. It would be... interesting to have one login session write the first line, then another session immediately write the second one, and then neither of them will find exactly one line in the file :) And same for logout. G'luck, Peter -- Peter Pentchev roam@ringlet.net roam@debian.org peter@morpheusly.com PGP key: https://www.ringlet.net/roam/roam.key.asc Key fingerprint 2EE7 A7A5 17FC 124C F115 C354 651E EFB0 2527 DF13