chiark / gitweb /
systemctl: fix parsing of DBus reply in 'dot'
[elogind.git] / src / socket-util.c
index 442abfe1affb2bd8615f1739913fbacc64190f98..2af85639657916fe903d998101575ff1d0c740e8 100644 (file)
@@ -305,7 +305,7 @@ int socket_address_listen(
                 bool free_bind,
                 mode_t directory_mode,
                 mode_t socket_mode,
-                /* FIXME SELINUX: pass SELinux context object here */
+                const char *label,
                 int *ret) {
 
         int r, fd, one;
@@ -315,11 +315,17 @@ int socket_address_listen(
         if ((r = socket_address_verify(a)) < 0)
                 return r;
 
-        /* FIXME SELINUX: The socket() here should be done with the
-         * right SELinux context set */
+        r = label_socket_set(label);
+        if (r < 0)
+                return r;
+
+        fd = socket(socket_address_family(a), a->type | SOCK_NONBLOCK | SOCK_CLOEXEC, 0);
+        r = fd < 0 ? -errno : 0;
 
-        if ((fd = socket(socket_address_family(a), a->type | SOCK_NONBLOCK | SOCK_CLOEXEC, 0)) < 0)
-                return -errno;
+        label_socket_clear();
+
+        if (r < 0)
+                return r;
 
         if (socket_address_family(a) == AF_INET6 && only != SOCKET_ADDRESS_DEFAULT) {
                 int flag = only == SOCKET_ADDRESS_IPV6_ONLY;