mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 16:35:06 -05:00
socket: add support for systemd sockets
Before opening new IPv4/IPv6 server sockets, chronyd will check for matching reusable sockets passed from the service manager (for example, passed via systemd socket activation: https://www.freedesktop.org/software/systemd/man/latest/sd_listen_fds.html) and use those instead. Aside from IPV6_V6ONLY (which cannot be set on already-bound sockets), the daemon sets the same socket options on reusable sockets as it would on sockets it opens itself. Unit tests test the correct parsing of the LISTEN_FDS environment variable. Add 011-systemd system test to test socket activation for DGRAM and STREAM sockets (both IPv4 and IPv6). The tests use the systemd-socket-activate test tool, which has some limitations requiring workarounds discussed in inline comments.
This commit is contained in:
committed by
Miroslav Lichvar
parent
c063b9e78a
commit
e6a0476eb7
7
main.c
7
main.c
@@ -368,9 +368,9 @@ go_daemon(void)
|
||||
}
|
||||
|
||||
/* Don't keep stdin/out/err from before. But don't close
|
||||
the parent pipe yet. */
|
||||
the parent pipe yet, or reusable file descriptors. */
|
||||
for (fd=0; fd<1024; fd++) {
|
||||
if (fd != pipefd[1])
|
||||
if (fd != pipefd[1] && !SCK_IsReusable(fd))
|
||||
close(fd);
|
||||
}
|
||||
|
||||
@@ -560,6 +560,9 @@ int main
|
||||
if (user_check && getuid() != 0)
|
||||
LOG_FATAL("Not superuser");
|
||||
|
||||
/* Initialise reusable file descriptors before fork */
|
||||
SCK_PreInitialise();
|
||||
|
||||
/* Turn into a daemon */
|
||||
if (!nofork) {
|
||||
go_daemon();
|
||||
|
||||
Reference in New Issue
Block a user