summaryrefslogtreecommitdiff
path: root/src/core/manager.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-07 16:32:06 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-07 16:36:14 +0100
commitf0e62e89970b8c38eb07a9beebd277ce13a5fcc2 (patch)
tree73f7e0463a8c80779c4b188c9aaf3c89ff96e46a /src/core/manager.c
parentd48b7bd271b1e70924c8485d2f95c2f5a1ae77cb (diff)
core: unify how we create the notify and private dbus socket
Use the same robust logic of mkdir + unlink of any existing AF_UNIX socket, ignoring the return value, right before bind().
Diffstat (limited to 'src/core/manager.c')
-rw-r--r--src/core/manager.c17
1 files changed, 2 insertions, 15 deletions
diff --git a/src/core/manager.c b/src/core/manager.c
index e596494646..350f2f3882 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -679,26 +679,13 @@ static int manager_setup_notify(Manager *m) {
return log_oom();
(void) mkdir_parents_label(m->notify_socket, 0755);
+ (void) unlink(m->notify_socket);
strncpy(sa.un.sun_path, m->notify_socket, sizeof(sa.un.sun_path)-1);
r = bind(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path));
if (r < 0) {
log_error("bind(%s) failed: %m", sa.un.sun_path);
- if (errno == EADDRINUSE) {
- log_notice("Removing %s socket and trying again.", m->notify_socket);
- r = unlink(m->notify_socket);
- if (r < 0) {
- log_error("Failed to remove %s: %m", m->notify_socket);
- return -EADDRINUSE;
- }
-
- r = bind(fd, &sa.sa, offsetof(struct sockaddr_un, sun_path) + strlen(sa.un.sun_path));
- if (r < 0) {
- log_error("bind(%s) failed: %m", sa.un.sun_path);
- return -errno;
- }
- } else
- return -errno;
+ return -errno;
}
r = setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));