News for hackers. Stuff that matters.
Re:Show HN: Picosnitch – a reliable and lightweight security... by theamk on Monday January 03, 2022 @03:19PM (#29786180)
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/picosnitc...

[1] https://github.com/elesiuta/picosnitch/blob/master/picosnitc...

Re:Show HN: Picosnitch – a reliable and lightweight security... by icedchai on Monday January 03, 2022 @10:23PM (#29790914)
Seems odd that it lists /home to pick a user, instead of getpwent.