diff options
Diffstat (limited to 'src/core/dbus.c')
-rw-r--r-- | src/core/dbus.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/core/dbus.c b/src/core/dbus.c index d4b74bbd3b..3ffb53cb6e 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -974,12 +974,9 @@ int bus_init_system(Manager *m) { int bus_init_private(Manager *m) { _cleanup_close_ int fd = -1; - union sockaddr_union sa = { - .un.sun_family = AF_UNIX - }; + union sockaddr_union sa = {}; sd_event_source *s; - socklen_t salen; - int r; + int r, salen; assert(m); @@ -992,12 +989,9 @@ int bus_init_private(Manager *m) { if (getpid_cached() != 1) return 0; - strcpy(sa.un.sun_path, "/run/systemd/private"); - salen = SOCKADDR_UN_LEN(sa.un); + salen = sockaddr_un_set_path(&sa.un, "/run/systemd/private"); } else { - size_t left = sizeof(sa.un.sun_path); - char *p = sa.un.sun_path; - const char *e; + const char *e, *joined; e = secure_getenv("XDG_RUNTIME_DIR"); if (!e) { @@ -1005,11 +999,11 @@ int bus_init_private(Manager *m) { return -EHOSTDOWN; } - left = strpcpy(&p, left, e); - left = strpcpy(&p, left, "/systemd/private"); - - salen = sizeof(sa.un) - left; + joined = strjoina(e, "/systemd/private"); + salen = sockaddr_un_set_path(&sa.un, joined); } + if (salen < 0) + return log_error_errno(salen, "Can't set path for AF_UNIX socket to bind to: %m"); (void) mkdir_parents_label(sa.un.sun_path, 0755); (void) sockaddr_un_unlink(&sa.un); |