From 155b6876699bcca455b50f52c541aed41c2bf8d3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 15 Oct 2018 12:08:30 +0200 Subject: [PATCH] tree-wide: use sockaddr_un_unlink() whereever appropriate Let's port everything over. --- src/core/dbus.c | 2 +- src/core/manager.c | 2 +- src/import/importd.c | 2 +- src/journal/journald-native.c | 2 +- src/journal/journald-stream.c | 2 +- src/journal/journald-syslog.c | 2 +- src/udev/udev-ctrl.c | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/core/dbus.c b/src/core/dbus.c index bf59176..4b04498 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -1012,7 +1012,7 @@ int bus_init_private(Manager *m) { } (void) mkdir_parents_label(sa.un.sun_path, 0755); - (void) unlink(sa.un.sun_path); + (void) sockaddr_un_unlink(&sa.un); fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); if (fd < 0) diff --git a/src/core/manager.c b/src/core/manager.c index 971faef..e8ade8b 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -970,7 +970,7 @@ static int manager_setup_cgroups_agent(Manager *m) { fd_inc_rcvbuf(fd, CGROUPS_AGENT_RCVBUF_SIZE); - (void) unlink(sa.un.sun_path); + (void) sockaddr_un_unlink(&sa.un); /* Only allow root to connect to this socket */ RUN_WITH_UMASK(0077) diff --git a/src/import/importd.c b/src/import/importd.c index 04563fb..c42b391 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -608,7 +608,7 @@ static int manager_new(Manager **ret) { return -errno; (void) mkdir_parents_label(sa.un.sun_path, 0755); - (void) unlink(sa.un.sun_path); + (void) sockaddr_un_unlink(&sa.un); if (bind(m->notify_fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0) return -errno; diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c index 44610a4..bf1ef64 100644 --- a/src/journal/journald-native.c +++ b/src/journal/journald-native.c @@ -453,7 +453,7 @@ int server_open_native_socket(Server*s) { if (s->native_fd < 0) return log_error_errno(errno, "socket() failed: %m"); - (void) unlink(sa.un.sun_path); + (void) sockaddr_un_unlink(&sa.un); r = bind(s->native_fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)); if (r < 0) diff --git a/src/journal/journald-stream.c b/src/journal/journald-stream.c index 267e63f..502bd6f 100644 --- a/src/journal/journald-stream.c +++ b/src/journal/journald-stream.c @@ -793,7 +793,7 @@ int server_open_stdout_socket(Server *s) { if (s->stdout_fd < 0) return log_error_errno(errno, "socket() failed: %m"); - (void) unlink(sa.un.sun_path); + (void) sockaddr_un_unlink(&sa.un); r = bind(s->stdout_fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)); if (r < 0) diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c index 46cc110..5bf057f 100644 --- a/src/journal/journald-syslog.c +++ b/src/journal/journald-syslog.c @@ -457,7 +457,7 @@ int server_open_syslog_socket(Server *s) { if (s->syslog_fd < 0) return log_error_errno(errno, "socket() failed: %m"); - (void) unlink(sa.un.sun_path); + (void) sockaddr_un_unlink(&sa.un); r = bind(s->syslog_fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)); if (r < 0) diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c index 6402410..df9ceef 100644 --- a/src/udev/udev-ctrl.c +++ b/src/udev/udev-ctrl.c @@ -117,7 +117,7 @@ int udev_ctrl_enable_receiving(struct udev_ctrl *uctrl) { if (!uctrl->bound) { err = bind(uctrl->sock, &uctrl->saddr.sa, uctrl->addrlen); if (err < 0 && errno == EADDRINUSE) { - unlink(uctrl->saddr.un.sun_path); + (void) sockaddr_un_unlink(&uctrl->saddr.un); err = bind(uctrl->sock, &uctrl->saddr.sa, uctrl->addrlen); } @@ -148,7 +148,7 @@ int udev_ctrl_cleanup(struct udev_ctrl *uctrl) { if (uctrl == NULL) return 0; if (uctrl->cleanup_socket) - unlink(uctrl->saddr.un.sun_path); + sockaddr_un_unlink(&uctrl->saddr.un); return 0; } -- 2.7.4