[systemd-commits] 4 commits - Makefile.am src/dbus1-generator units/busnames.target

Lennart Poettering lennart at kemper.freedesktop.org
Mon Dec 2 16:53:56 PST 2013


 Makefile.am                           |    2 
 src/dbus1-generator/dbus1-generator.c |   73 ++++++++++++++++++++++++----------
 units/busnames.target                 |   10 ++++
 3 files changed, 64 insertions(+), 21 deletions(-)

New commits:
commit dca409bf96497343f7036f76d7034bc7669c7fec
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 3 01:44:24 2013 +0100

    units: create busnames.target for user sessions too

diff --git a/Makefile.am b/Makefile.am
index 0610635..4007d2a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4608,6 +4608,7 @@ SYSTEM_UNIT_ALIASES += \
 USER_UNIT_ALIASES += \
 	$(systemunitdir)/shutdown.target shutdown.target \
 	$(systemunitdir)/sockets.target sockets.target \
+	$(systemunitdir)/busnames.target busnames.target \
 	$(systemunitdir)/timers.target timers.target \
 	$(systemunitdir)/paths.target paths.target \
 	$(systemunitdir)/bluetooth.target bluetooth.target \

commit 5c817d31d9d239421cf9b01a9c06b90f50b18d75
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 3 01:41:02 2013 +0100

    dbus1: hook busnames.target into normal boot if kdbus is enabled

diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c
index 31ec56e..8795e3b 100644
--- a/src/dbus1-generator/dbus1-generator.c
+++ b/src/dbus1-generator/dbus1-generator.c
@@ -43,6 +43,7 @@ static int create_dbus_files(
 
         assert(path);
         assert(name);
+        assert(service || exec);
 
         if (!service) {
                 _cleanup_free_ char *a = NULL;
@@ -64,7 +65,7 @@ static int create_dbus_files(
                 fprintf(f,
                         "# Automatically generated by systemd-dbus1-generator\n\n"
                         "[Unit]\n"
-                        "Source=%s\n"
+                        "SourcePath=%s\n"
                         "Description=DBUS1: %s\n\n"
                         "[Service]\n"
                         "ExecStart=%s\n"
@@ -110,7 +111,7 @@ static int create_dbus_files(
         fprintf(f,
                 "# Automatically generated by systemd-dbus1-generator\n\n"
                 "[Unit]\n"
-                "Source=%s\n"
+                "SourcePath=%s\n"
                 "Description=DBUS1: %s\n\n"
                 "[BusName]\n"
                 "Name=%s\n"
@@ -132,7 +133,7 @@ static int create_dbus_files(
 
         mkdir_parents_label(lnk, 0755);
         if (symlink(b, lnk)) {
-                log_error("Failed to create symlinks %s: %m", lnk);
+                log_error("Failed to create symlink %s: %m", lnk);
                 return -errno;
         }
 
@@ -212,25 +213,15 @@ static int add_dbus(const char *path, const char *fname, const char *type) {
         return create_dbus_files(p, name, service, exec, user, type);
 }
 
-static int parse_dbus_fragments(void) {
+static int parse_dbus_fragments(const char *path, const char *type) {
         _cleanup_closedir_ DIR *d = NULL;
         struct dirent *de;
-        const char *p, *type;
         int r;
 
-        r = cg_pid_get_owner_uid(0, NULL);
-        if (r >= 0) {
-                p = "/usr/share/dbus-1/services";
-                type = "session";
-        } else if (r == -ENOENT) {
-                p = "/usr/share/dbus-1/system-services";
-                type = "system";
-        } else if (r < 0) {
-                log_error("Failed to determine whether we are running as user or system instance: %s", strerror(-r));
-                return r;
-        }
+        assert(path);
+        assert(type);
 
-        d = opendir(p);
+        d = opendir(path);
         if (!d) {
                 if (errno == -ENOENT)
                         return 0;
@@ -246,7 +237,7 @@ static int parse_dbus_fragments(void) {
                 if (!endswith(de->d_name, ".service"))
                         continue;
 
-                q = add_dbus(p, de->d_name, type);
+                q = add_dbus(path, de->d_name, type);
                 if (q < 0)
                         r = q;
         }
@@ -258,8 +249,24 @@ fail:
         return -errno;
 }
 
+static int link_busnames_target(const char *units) {
+        const char *f, *t;
+
+        f = strappenda(units, "/" SPECIAL_BUSNAMES_TARGET);
+        t = strappenda(arg_dest, "/" SPECIAL_BASIC_TARGET ".wants/" SPECIAL_BUSNAMES_TARGET);
+
+        mkdir_parents_label(t, 0755);
+        if (symlink(f, t) < 0) {
+                log_error("Failed to create symlink %s: %m", t);
+                return -errno;
+        }
+
+        return 0;
+}
+
 int main(int argc, char *argv[]) {
-        int r;
+        const char *path, *type, *units;
+        int r, q;
 
         if (argc > 1 && argc != 4) {
                 log_error("This program takes three or no arguments.");
@@ -278,7 +285,26 @@ int main(int argc, char *argv[]) {
         if (access("/dev/kdbus/control", F_OK) < 0)
                 return 0;
 
-        r = parse_dbus_fragments();
+        r = cg_pid_get_owner_uid(0, NULL);
+        if (r >= 0) {
+                path = "/usr/share/dbus-1/services";
+                type = "session";
+                units = USER_DATA_UNIT_PATH;
+        } else if (r == -ENOENT) {
+                path = "/usr/share/dbus-1/system-services";
+                type = "system";
+                units = SYSTEM_DATA_UNIT_PATH;
+        } else if (r < 0) {
+                log_error("Failed to determine whether we are running as user or system instance: %s", strerror(-r));
+                return r;
+        }
+
+        r = parse_dbus_fragments(path, type);
+
+        /* FIXME: One day this should just be pulled in statically from basic.target */
+        q = link_busnames_target(units);
+        if (q < 0)
+                r = q;
 
         return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
 }

commit 4c3a127cb631cf5efe8a6aab3fb2884e9044ef2d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 3 01:24:39 2013 +0100

    bus: skip unit file generation for systemd itself

diff --git a/src/dbus1-generator/dbus1-generator.c b/src/dbus1-generator/dbus1-generator.c
index 93c6392..31ec56e 100644
--- a/src/dbus1-generator/dbus1-generator.c
+++ b/src/dbus1-generator/dbus1-generator.c
@@ -183,6 +183,11 @@ static int add_dbus(const char *path, const char *fname, const char *type) {
                 return 0;
         }
 
+        if (streq(name, "org.freedesktop.systemd1")) {
+                log_debug("Skipping %s, identified as systemd.", p);
+                return 0;
+        }
+
         if (service) {
                 if (!unit_name_is_valid(service, false)) {
                         log_warning("Unit name %s is not valid, ignoring.", service);
@@ -193,7 +198,7 @@ static int add_dbus(const char *path, const char *fname, const char *type) {
                         return 0;
                 }
         } else {
-                if (!exec) {
+                if (streq(exec, "/bin/false") || !exec) {
                         log_warning("Neither service name nor binary path specified, ignoring %s.", p);
                         return 0;
                 }
@@ -219,7 +224,7 @@ static int parse_dbus_fragments(void) {
                 type = "session";
         } else if (r == -ENOENT) {
                 p = "/usr/share/dbus-1/system-services";
-                type = "systemd";
+                type = "system";
         } else if (r < 0) {
                 log_error("Failed to determine whether we are running as user or system instance: %s", strerror(-r));
                 return r;

commit 1b16c75cd2da6741824e9843135f55e3b5d23d9d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 3 01:18:26 2013 +0100

    units: install busnames.target by default

diff --git a/Makefile.am b/Makefile.am
index ce59c04..0610635 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -393,6 +393,7 @@ dist_systemunit_DATA = \
 	units/sigpwr.target \
 	units/sleep.target \
 	units/sockets.target \
+	units/busnames.target \
 	units/timers.target \
 	units/paths.target \
 	units/suspend.target \
diff --git a/units/busnames.target b/units/busnames.target
new file mode 100644
index 0000000..5e866b4
--- /dev/null
+++ b/units/busnames.target
@@ -0,0 +1,10 @@
+#  This file is part of systemd.
+#
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU Lesser General Public License as published by
+#  the Free Software Foundation; either version 2.1 of the License, or
+#  (at your option) any later version.
+
+[Unit]
+Description=Bus Names
+Documentation=man:systemd.special(7)



More information about the systemd-commits mailing list