kvaps / fake-systemd

MIT License
40 stars 16 forks source link

Any hints on how Systemd Socket Support Might be Added #7

Open s243a opened 3 years ago

s243a commented 3 years ago

As I discussed elsewhere (see post) this doesn't work with the snap package manager because it doesn't support systemd sockets. I tried to use ncat and socat to create the sockets:

ncat -U /run/snapd.socket  -v --listen --keep-open --exec /usr/lib/snapd/snapd 0666
socat TCP-LISTEN:0666,reuseaddr UNIX-CLIENT:/run/snapd.socket

https://forum.puppylinux.com/viewtopic.php?p=9359#p9359

but I don't really know what I'm doing. I know this project is no longer being maintained but any hints about how I might go about implementing fake systemd sockets via a bash script would be greatly appreciated. :)

s243a commented 3 years ago

As I discussed elsewhere (see post) this doesn't work with the snap package manager because it doesn't support systemd sockets. I tried to use ncat and socat to create the sockets:

ncat -U /run/snapd.socket  -v --listen --keep-open --exec /usr/lib/snapd/snapd 0666
socat TCP-LISTEN:0666,reuseaddr UNIX-CLIENT:/run/snapd.socket

https://forum.puppylinux.com/viewtopic.php?p=9359#p9359

but I don't really know what I'm doing. I know this project is no longer being maintained but any hints about how I might go about implementing fake systemd sockets via a bash script would be greatly appreciated. :)

One thing I have wrong here is that the 0666 is the socket filesystem premissions rather than the port:

SocketMode=

If listening on a file system socket or FIFO, this option specifies the file system access mode used when creating the file node. Takes an access mode in octal notation. Defaults to 0666.

https://www.freedesktop.org/software/systemd/man/systemd.socket.html

I'm also not sure where the http service gets started because as far as I can tell snap.socket only specifies a Unix domain socket:

ListenStream=, ListenDatagram=, ListenSequentialPacket=

Specifies an address to listen on for a stream (SOCK_STREAM), datagram (SOCK_DGRAM), or sequential packet (SOCK_SEQPACKET) socket, respectively. The address can be written in various formats:

If the address starts with a slash ("/"), it is read as file system socket in the AF_UNIX socket family.

... Note that SOCK_SEQPACKET (i.e. ListenSequentialPacket=) is only available for AF_UNIX sockets. SOCK_STREAM (i.e. ListenStream=) when used for IP sockets refers to TCP sockets, SOCK_DGRAM (i.e. ListenDatagram=) to UDP.

These options may be specified more than once, in which case incoming traffic on any of the sockets will trigger service activation, and all listed sockets will be passed to the service, regardless of whether there is incoming traffic on them or not. If the empty string is assigned to any of these options, the list of addresses to listen on is reset, all prior uses of any of these options will have no effect. https://www.freedesktop.org/software/systemd/man/systemd.socket.html

Some other links which may be helpful for understanding this: https://www.linux.com/training-tutorials/end-road-systemds-socket-units/ http://0pointer.de/blog/projects/socket-activation.html