w: Fix handling with elogind
Fix potential crash when systemd not in use and lack of results when elogind in use.
Addresses discussion points in https://bugs.debian.org/1108549 by taking advantage of the unambiguous information from systemd while coping with the fact that you can't distinguish between no sessions under elogind or not running elogind by falling back to utmp reading if systemd not running.
Scenarios tested
scenario | systemd | elogind | none1 |
---|---|---|---|
sessions | ✓ | ✓ | ✓ (utmp) |
no sessions | ✓ 2 | ✓ 2 | ✓ 2 |
error | N/A |
Empty cells untested. The case of error from sd_get_sessions() seems low risk to me for testing purposes.
Edited by Andrew Bower