chiark / gitweb /
udev: really exclude device-mapper from block device ownership event locking
[elogind.git] / src / dbus1-generator / dbus1-generator.c
index e86fc6e..95962c7 100644 (file)
@@ -66,7 +66,8 @@ static int create_dbus_files(
                         "# Automatically generated by systemd-dbus1-generator\n\n"
                         "[Unit]\n"
                         "SourcePath=%s\n"
                         "# Automatically generated by systemd-dbus1-generator\n\n"
                         "[Unit]\n"
                         "SourcePath=%s\n"
-                        "Description=DBUS1: %s\n\n"
+                        "Description=DBUS1: %s\n"
+                        "Documentation=man:systemd-dbus1-generator(8)\n\n"
                         "[Service]\n"
                         "ExecStart=%s\n"
                         "Type=dbus\n"
                         "[Service]\n"
                         "ExecStart=%s\n"
                         "Type=dbus\n"
@@ -84,9 +85,19 @@ static int create_dbus_files(
                         fprintf(f, "Environment=DBUS_STARTER_BUS_TYPE=%s\n", type);
 
                         if (streq(type, "system"))
                         fprintf(f, "Environment=DBUS_STARTER_BUS_TYPE=%s\n", type);
 
                         if (streq(type, "system"))
-                                fprintf(f, "Environment=DBUS_STARTER_ADDRESS=kernel:/dev/kdbus/0-system\n");
-                        else if (streq(type, "session"))
-                                fprintf(f, "Environment=DBUS_STARTER_ADDRESS=kernel:/dev/kdbus/%lu-user\n", (unsigned long) getuid());
+                                fprintf(f, "Environment=DBUS_STARTER_ADDRESS=" DEFAULT_SYSTEM_BUS_PATH "\n");
+                        else if (streq(type, "session")) {
+                                char *run;
+
+                                run = getenv("XDG_RUNTIME_DIR");
+                                if (!run) {
+                                        log_error("XDG_RUNTIME_DIR not set.");
+                                        return -EINVAL;
+                                }
+
+                                fprintf(f, "Environment=DBUS_STARTER_ADDRESS="KERNEL_USER_BUS_FMT ";" UNIX_USER_BUS_FMT "\n",
+                                        getuid(), run);
+                        }
                 }
 
                 fflush(f);
                 }
 
                 fflush(f);
@@ -112,10 +123,12 @@ static int create_dbus_files(
                 "# Automatically generated by systemd-dbus1-generator\n\n"
                 "[Unit]\n"
                 "SourcePath=%s\n"
                 "# Automatically generated by systemd-dbus1-generator\n\n"
                 "[Unit]\n"
                 "SourcePath=%s\n"
-                "Description=DBUS1: %s\n\n"
+                "Description=DBUS1: %s\n"
+                "Documentation=man:systemd-dbus1-generator(8)\n\n"
                 "[BusName]\n"
                 "Name=%s\n"
                 "[BusName]\n"
                 "Name=%s\n"
-                "Service=%s\n",
+                "Service=%s\n"
+                "AllowWorld=talk\n",
                 path,
                 name,
                 name,
                 path,
                 name,
                 name,
@@ -190,7 +203,7 @@ static int add_dbus(const char *path, const char *fname, const char *type) {
         }
 
         if (service) {
         }
 
         if (service) {
-                if (!unit_name_is_valid(service, false)) {
+                if (!unit_name_is_valid(service, TEMPLATE_INVALID)) {
                         log_warning("Unit name %s is not valid, ignoring.", service);
                         return 0;
                 }
                         log_warning("Unit name %s is not valid, ignoring.", service);
                         return 0;
                 }
@@ -267,15 +280,28 @@ static int link_busnames_target(const char *units) {
 static int link_compatibility(const char *units) {
         const char *f, *t;
 
 static int link_compatibility(const char *units) {
         const char *f, *t;
 
-        f = strappenda(units, "/systemd-socket-proxy.socket");
+        f = strappenda(units, "/systemd-bus-proxyd.socket");
         t = strappenda(arg_dest, "/" SPECIAL_DBUS_SOCKET);
         t = strappenda(arg_dest, "/" SPECIAL_DBUS_SOCKET);
+        mkdir_parents_label(t, 0755);
+        if (symlink(f, t) < 0) {
+                log_error("Failed to create symlink %s: %m", t);
+                return -errno;
+        }
 
 
+        f = strappenda(units, "/systemd-bus-proxyd.socket");
+        t = strappenda(arg_dest, "/" SPECIAL_SOCKETS_TARGET ".wants/systemd-bus-proxyd.socket");
         mkdir_parents_label(t, 0755);
         if (symlink(f, t) < 0) {
                 log_error("Failed to create symlink %s: %m", t);
                 return -errno;
         }
 
         mkdir_parents_label(t, 0755);
         if (symlink(f, t) < 0) {
                 log_error("Failed to create symlink %s: %m", t);
                 return -errno;
         }
 
+        t = strappenda(arg_dest, "/" SPECIAL_DBUS_SERVICE);
+        if (symlink("/dev/null", t) < 0) {
+                log_error("Failed to mask %s: %m", t);
+                return -errno;
+        }
+
         return 0;
 }
 
         return 0;
 }