2 ms·
I was curious how does session notification from system service works -- what if there is no one logged in? What if there are multiple users? How about ssh conn
by theamk 5y ago
I was curious how does session notification from system service works -- what if there is no one logged in? What if there are multiple users? How about ssh connections?
The answer is as following:
- user's dbus session is used for notifications. On systemd systems, user's dbus socket is in fixed, predictable location, and only depends on username. The script hardcodes this location.
- The normal install procedure records the username of the user who called "install" command and uses their session for notification [0]. So if user "alice" run the install command, and user "john" is logged in, no notifications will be delivered.
- If installer user is not available, an arbitrary user is chosen [1] (!) and program just expect them to be logged in. This happens when installing a .deb file for example.
- If the user is not logged in, or has logged out, the notifications are enqueued and would be shown once user is logged back in.
Overall, this is a bit simplistic and will fail in some multi-user situations... but it still covers most common cases (a single user on the system) and in the spirit of "lightweight" tool.
[0] https://github.com/elesiuta/picosnitch/blob/master/picosnitch.py#L1383 https://github.com/elesiuta/picosnitch/blob/master/picosnitc...
[1] https://github.com/elesiuta/picosnitch/blob/master/picosnitch.py#L67 https://github.com/elesiuta/picosnitch/blob/master/picosnitc...
- icedchai 5y agoSeems odd that it lists /home to pick a user, instead of getpwent.