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

From: Peter Pentchev <roam_at_ringlet.net>
Date: Sat, 13 Jul 2024 12:43:15 +0300

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_at_ringlet.net roam_at_debian.org peter_at_morpheusly.com
PGP key:        https://www.ringlet.net/roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13

Received on Sat Jul 13 2024 - 11:43:15 CEST

This archive was generated by hypermail 2.4.0 : Sun Jul 14 2024 - 11:11:19 CEST