Re: s6/s6-rc policy for Gentoo: user session tracking

Peter Pentchev <[email protected]> Sat, 13 Jul 2024 12:43:15 +0300
Newsgroups gmane.comp.sysutils.supervision.general
Message-ID <[email protected]>
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  [email protected] [email protected] [email protected]
PGP key:        https://www.ringlet.net/roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEELuenpRf8EkzxFcNUZR7vsCUn3xMFAmaSTC0ACgkQZR7vsCUn
3xO8lRAAqiPmUjQjG4FP5cbon1WDmnFtZ6cgT5OPPmurLkEd05Me2ffxCPdUtlrM
GiyQa8lwevzBEWeWVvWHV64m462++MtId6zIZ6pCgSwQ+jZtCRUDn9juseI5imxS
nORCi8mBA3+yUil5bv85zoERor5M+Kgp7efnvpXKSQou67pH4ocwkANKIrY7veCN
K+yqHcUkDB9ydm3u7BFgSm8TLKpBv/4htOWYm+LAjOon9zjlXRXzKM3jzI5jWmxK
qMobqhHngRXoNL53I51cp3PD8kmFmoVPZhJaoZx8d2TJ+q05QjNSaMJCW47LrvSD
QMpQj1vdfKpMLa571E8kEzk8u4F7PmLuRjxKjmj+I4QHefgVUEgMckVvfobVMtXU
JnF2/nWxerOPKAddSSUAz2H/SF3FDvtGkKOZuVl2OxTJZyMjDWDPydnXt1nlzUXK
ykCyhuzTj3kYTYYcWu07IFjXuyypo7kzaCL6xI759w8JvVarI0dDCmHY9ipdWmHN
QgZKY/XlLakhDLFO/JNcOIqjR9EDDOH+JNVXm9S1ApOjWAby1NZDz5CUfYbsQSGb
VeYuGyLoP7vDNlRrZxS7Xt8DCQPH6kFsGDZvka6RakNgtXqNLWtw4peFoXv527O6
bpN3wrN9cy14Q9M3zSP1Tq1adkv25t0pHQWt4Oay2uu6nNlFxGQ=
=ecKB
-----END PGP SIGNATURE-----