Hi Craig, Thanks for reviewing my suggestions!
On Mon, Jul 28, 2025 at 08:07:12PM +1000, Craig Small wrote: > On Mon, 28 Jul 2025 at 17:31, Andrew Bower <[email protected]> wrote: > > I think we should do this: > > Remove sd_booted() check > if sd_get_sessions() > < 0 && != ENOENT: error > > 0: show sessions > default: fallback to utmp > > This should deal with: > 1. systemd and elogind with some login sessions: show sessions > 2. neither systemd nor elogind: fallback to utmp reading > 3. systemd and elogind with no sessions: show nothing, as now, but via > fallback utmp route with no practical difference. > > I don't see a downside from this approach. > > I think this is the correct way too. I'll double check that 0 user path > because > it looks odd, but its probably doing the right thing. A slight tweak to this algorithm might allay anxiety about the 0 sessions case, whereby we reintroduce the sd_booted() check in a different place to create an alternative path: if sd_get_sessions() < 0 && != ENOENT: error > 0 || sd_booted(): show sessions default: fallback to utmp In this case if systemd is running then the utmp fallback is never attempted - this results in no ambiguity about the outcome in this more predictable scenario. (N.B. would also need to zero out the session count in case of ENOENT) What do you think of this variation? Andrew

