mirror of
https://github.com/yarrick/iodine.git
synced 2024-11-24 18:45:12 +00:00
Conflicts: src/iodined.c src/osflags
This commit is contained in:
commit
8c831b0436
@ -3,6 +3,8 @@ Description=Iodine socket
|
||||
|
||||
[Socket]
|
||||
ListenDatagram=53
|
||||
ListenDatagram=0.0.0.0:53
|
||||
BindIPv6Only=ipv6-only
|
||||
|
||||
[Install]
|
||||
WantedBy=sockets.target
|
||||
|
@ -555,14 +555,11 @@ main(int argc, char **argv)
|
||||
|
||||
#ifdef HAVE_SYSTEMD
|
||||
nb_fds = sd_listen_fds(0);
|
||||
if (nb_fds > 1) {
|
||||
if (nb_fds < 0) {
|
||||
warnx("Failed to receive file descriptors from systemd: %s", strerror(-nb_fds));
|
||||
retval = 1;
|
||||
warnx("Too many file descriptors received!\n");
|
||||
goto cleanup;
|
||||
} else if (nb_fds == 1) {
|
||||
/* XXX: assume we get IPv4 socket */
|
||||
server.dns_fds.v4fd = SD_LISTEN_FDS_START;
|
||||
} else {
|
||||
} else if (nb_fds == 0) {
|
||||
#endif
|
||||
if ((server.addrfamily == AF_UNSPEC || server.addrfamily == AF_INET) &&
|
||||
(server.dns_fds.v4fd = open_dns(&server.dns4addr, server.dns4addr_len)) < 0) {
|
||||
@ -578,6 +575,25 @@ main(int argc, char **argv)
|
||||
goto cleanup;
|
||||
}
|
||||
#ifdef HAVE_SYSTEMD
|
||||
} else if (nb_fds <= 2) {
|
||||
/* systemd may pass up to two sockets, for ip4 and ip6, try to figure out
|
||||
which is which */
|
||||
for (int i = 0; i < nb_fds; i++) {
|
||||
int fd = SD_LISTEN_FDS_START + i;
|
||||
if (sd_is_socket(fd, AF_INET, SOCK_DGRAM, -1)) {
|
||||
dns_fds.v4fd = fd;
|
||||
} else if (sd_is_socket(fd, AF_INET6, SOCK_DGRAM, -1)) {
|
||||
dns_fds.v6fd = fd;
|
||||
} else {
|
||||
retval = 1;
|
||||
warnx("Unknown socket %d passed to iodined!\n", fd);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
retval = 1;
|
||||
warnx("Too many file descriptors received!\n");
|
||||
goto cleanup;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -19,6 +19,7 @@ link)
|
||||
Linux)
|
||||
FLAGS="";
|
||||
[ -e /usr/include/selinux/selinux.h ] && FLAGS="$FLAGS -lselinux";
|
||||
[ -e /usr/include/systemd/sd-daemon.h ] && FLAGS="$FLAGS $(pkg-config --libs libsystemd-daemon)";
|
||||
[ -e /usr/include/systemd/sd-daemon.h ] && FLAGS="$FLAGS $(pkg-config --libs libsystemd)";
|
||||
echo $FLAGS;
|
||||
;;
|
||||
|
Loading…
Reference in New Issue
Block a user