robur-coop / albatross

Albatross: orchestrate and manage MirageOS unikernels with Solo5
ISC License
141 stars 17 forks source link

Avoid daemons to override sockets of already executing daemons #91

Closed hannesm closed 2 years ago

hannesm commented 2 years ago

To avoid accidental executions of albatross_console etc. (which will create and claim the socket). Eventually these programs should as well not start up if the socket is already there and opened (but that may lead to rather intricate semantics).

hannesm commented 2 years ago

Hmm, but on Linux systems there's no /usr/libexec -- so what is the way to go on Linux for installing daemons and avoiding them to be accidentally started multiple times?

One way would be to look whether the socket exists, and if yes, whether there's something listening upon connect.

Any ideas /cc @reynir

reynir commented 2 years ago

On Linux the systemd scripts use systemd socket activation -- A separate albatross_console.socket systemd file exists that creates the socket and on connection starts up albatross-console --systemd-socket-activation (via albatross_console.service) and passes the socket as a file descriptor. If used this way then creating the socket is handled by systemd and I think it should avoid recreating/claiming existing sockets. But this of course does not prevent a user from manually running albatross-console.

I would be in favor of moving the daemon binaries to /usr/libexec/ as that would make it less likely a user would run the binary directly.