X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fshared%2Fsocket-label.c;h=144e6fd86edd056ca0f3634add1803bb492b1ccc;hp=6806c51158d0a17ee21f90085f064baadb41a376;hb=d76bb3c179b7a32b109e39aa87ff09c8f5a8c178;hpb=d7b8eec7dc7fe307d3a08b32cf1a9ad4276ce6d5 diff --git a/src/shared/socket-label.c b/src/shared/socket-label.c index 6806c5115..144e6fd86 100644 --- a/src/shared/socket-label.c +++ b/src/shared/socket-label.c @@ -19,24 +19,16 @@ along with systemd; If not, see . ***/ -#include #include #include #include -#include -#include -#include -#include -#include #include #include -#include #include "macro.h" #include "util.h" #include "mkdir.h" #include "missing.h" -#include "label.h" #include "selinux-util.h" #include "socket-util.h" @@ -46,6 +38,7 @@ int socket_address_listen( int backlog, SocketAddressBindIPv6Only only, const char *bind_to_device, + bool reuse_port, bool free_bind, bool transparent, mode_t directory_mode, @@ -91,6 +84,12 @@ int socket_address_listen( if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, bind_to_device, strlen(bind_to_device)+1) < 0) return -errno; + if (reuse_port) { + one = 1; + if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)) < 0) + log_warning_errno(errno, "SO_REUSEPORT failed: %m"); + } + if (free_bind) { one = 1; if (setsockopt(fd, IPPROTO_IP, IP_FREEBIND, &one, sizeof(one)) < 0) @@ -117,9 +116,6 @@ int socket_address_listen( /* Enforce the right access mode for the socket */ old_mask = umask(~ socket_mode); - /* Include the original umask in our mask */ - umask(~socket_mode | old_mask); - r = mac_selinux_bind(fd, &a->sockaddr.sa, a->size); if (r < 0 && errno == EADDRINUSE) { @@ -157,7 +153,7 @@ int make_socket_fd(int log_level, const char* address, int flags) { } fd = socket_address_listen(&a, flags, SOMAXCONN, SOCKET_ADDRESS_DEFAULT, - NULL, false, false, 0755, 0644, NULL); + NULL, false, false, false, 0755, 0644, NULL); if (fd < 0 || log_get_max_level() >= log_level) { _cleanup_free_ char *p = NULL;