libsdsock is an LD_PRELOAD hack that allows (or at least tries to...) many pieces of software that listen for network connections to be started on demand via systemd’s “Socket Activation” feature. TCP, UDP, Unix stream sockets are supported.
The motivating use case was to have SSH dynamic port forwarding that starts (and restarts) on demand. Examples (jump.socket, jump.service and jump.sh) are provided for that, though the tool is generic.
- libsystemd development files
- libdl development files
- gcc
git clone https://github.com/ryancdotorg/libsdsock.git
cd libsdsock
make
make install
Run as root (sudo make install
) to install system-wide.
- Create systemd .socket and .service files as required (see examples)
- Use
systemctl enable
on the .socket unit - this is not required for the corresponding .service unit. - Use
systemctl start
on the .socket unit - again, this is not required for the corresponding .service unit.
Run make debug
to build libsdsock-debug.so version, it will print debug
infomation to stderr.
You can file an issue on GitHub, however I may not respond. This software is being provided without warranty in the hopes that it may be useful.
This software has not been independently audited and may contain bugs. That
said, the exposure surface of the code is minimal, and no untrusted data is
processed. The only functions shimmed are bind
, listen
, close
,
closefrom
and close_range
.
Tests would probably be a good idea.
Ryan Castellucci (@ryancdotorg), Ivan (@vanym)
It’s CC0, do what you want.