chiark / gitweb /
manager: Ensure user's systemd runtime directory exists.
authorColin Guthrie <colin@mageia.org>
Sun, 2 Nov 2014 13:33:16 +0000 (13:33 +0000)
committerColin Guthrie <colin@mageia.org>
Wed, 5 Nov 2014 14:49:06 +0000 (14:49 +0000)
This mirrors code in dbus.c when creating the private socket and
avoids error messages like:

systemd[1353]: bind(/run/user/603/systemd/notify) failed: No such file or directory
systemd[1353]: Failed to fully start up daemon: No such file or directory

src/core/manager.c

index ef1e3eac5fba78e20d3f5127b3bb4c3098689e5d..129f6dd3a851263cbaa2538ba2666665694edc92 100644 (file)
@@ -662,9 +662,11 @@ static int manager_setup_notify(Manager *m) {
                         return -errno;
                 }
 
-                if (m->running_as == SYSTEMD_SYSTEM)
+                if (m->running_as == SYSTEMD_SYSTEM) {
                         m->notify_socket = strdup("/run/systemd/notify");
-                else {
+                        if (!m->notify_socket)
+                                return log_oom();
+                } else {
                         const char *e;
 
                         e = getenv("XDG_RUNTIME_DIR");
@@ -674,9 +676,11 @@ static int manager_setup_notify(Manager *m) {
                         }
 
                         m->notify_socket = strappend(e, "/systemd/notify");
+                        if (!m->notify_socket)
+                                return log_oom();
+
+                        mkdir_parents_label(m->notify_socket, 0755);
                 }
-                if (!m->notify_socket)
-                        return log_oom();
 
                 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));