summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-12-27 16:50:24 +0100
committerLennart Poettering <lennart@poettering.net>2018-01-05 13:55:08 +0100
commit294d46f138e67f9e1bfb18f5ec1b009a4a9d5292 (patch)
tree2b812617089b21407dac56cda1baf26afe555712
parent9e3fa6e82773cb1d8687453ef0ba0ad9e5dda7d2 (diff)
downloadsystemd-294d46f138e67f9e1bfb18f5ec1b009a4a9d5292.tar.gz
socket-label: simplify things a bit by using socket_address_get_path()
Let's make this more generic and descriptive, and let's reuse our existing utility functions.
-rw-r--r--src/basic/socket-label.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/basic/socket-label.c b/src/basic/socket-label.c
index 20be406371..448265b1cd 100644
--- a/src/basic/socket-label.c
+++ b/src/basic/socket-label.c
@@ -29,6 +29,7 @@
#include "alloc-util.h"
#include "fd-util.h"
+#include "fs-util.h"
#include "log.h"
#include "macro.h"
#include "missing.h"
@@ -51,6 +52,7 @@ int socket_address_listen(
const char *label) {
_cleanup_close_ int fd = -1;
+ const char *p;
int r, one;
assert(a);
@@ -112,16 +114,17 @@ int socket_address_listen(
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) < 0)
return -errno;
- if (socket_address_family(a) == AF_UNIX && a->sockaddr.un.sun_path[0] != 0) {
+ p = socket_address_get_path(a);
+ if (p) {
/* Create parents */
- (void) mkdir_parents_label(a->sockaddr.un.sun_path, directory_mode);
+ (void) mkdir_parents_label(p, directory_mode);
/* Enforce the right access mode for the socket */
RUN_WITH_UMASK(~socket_mode) {
r = mac_selinux_bind(fd, &a->sockaddr.sa, a->size);
if (r == -EADDRINUSE) {
/* Unlink and try again */
- unlink(a->sockaddr.un.sun_path);
+ (void) unlink(p);
if (bind(fd, &a->sockaddr.sa, a->size) < 0)
return -errno;
} else if (r < 0)