[systemd-commits] src/bus-proxyd

Daniel Mack zonque at kemper.freedesktop.org
Thu Jan 15 05:11:10 PST 2015


 src/bus-proxyd/bus-proxyd.c |   66 -------------------------------------------
 src/bus-proxyd/synthesize.c |   67 ++++++++++++++++++++++++++++++++++++++++++++
 src/bus-proxyd/synthesize.h |    1 
 3 files changed, 68 insertions(+), 66 deletions(-)

New commits:
commit 5e2de0eb1dff7bb86b40c16a0a9c9c4de33e77d1
Author: Daniel Mack <daniel at zonque.org>
Date:   Thu Jan 15 14:10:28 2015 +0100

    bus-proxyd: move synthesize_name_acquired()
    
    Move synthesize_name_acquired() to synthesize.c.

diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c
index 0574eb0..13b27b4 100644
--- a/src/bus-proxyd/bus-proxyd.c
+++ b/src/bus-proxyd/bus-proxyd.c
@@ -587,72 +587,6 @@ static int mac_smack_apply_label_and_drop_cap_mac_admin(pid_t its_pid, const cha
 #endif
 }
 
-static int synthesize_name_acquired(sd_bus *a, sd_bus *b, sd_bus_message *m) {
-        _cleanup_bus_message_unref_ sd_bus_message *n = NULL;
-        const char *name, *old_owner, *new_owner;
-        int r;
-
-        assert(a);
-        assert(b);
-        assert(m);
-
-        /* If we get NameOwnerChanged for our own name, we need to
-         * synthesize NameLost/NameAcquired, since socket clients need
-         * that, even though it is obsoleted on kdbus */
-
-        if (!a->is_kernel)
-                return 0;
-
-        if (!sd_bus_message_is_signal(m, "org.freedesktop.DBus", "NameOwnerChanged") ||
-            !streq_ptr(m->path, "/org/freedesktop/DBus") ||
-            !streq_ptr(m->sender, "org.freedesktop.DBus"))
-                return 0;
-
-        r = sd_bus_message_read(m, "sss", &name, &old_owner, &new_owner);
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_rewind(m, true);
-        if (r < 0)
-                return r;
-
-        if (streq(old_owner, a->unique_name)) {
-
-                r = sd_bus_message_new_signal(
-                                b,
-                                &n,
-                                "/org/freedesktop/DBus",
-                                "org.freedesktop.DBus",
-                                "NameLost");
-
-        } else if (streq(new_owner, a->unique_name)) {
-
-                r = sd_bus_message_new_signal(
-                                b,
-                                &n,
-                                "/org/freedesktop/DBus",
-                                "org.freedesktop.DBus",
-                                "NameAcquired");
-        } else
-                return 0;
-
-        if (r < 0)
-                return r;
-
-        r = sd_bus_message_append(n, "s", name);
-        if (r < 0)
-                return r;
-
-        r = bus_message_append_sender(n, "org.freedesktop.DBus");
-        if (r < 0)
-                return r;
-
-        r = bus_seal_synthetic_message(b, n);
-        if (r < 0)
-                return r;
-
-        return sd_bus_send(b, n, NULL);
-}
 
 int main(int argc, char *argv[]) {
 
diff --git a/src/bus-proxyd/synthesize.c b/src/bus-proxyd/synthesize.c
index e98a97e..ab73d6e 100644
--- a/src/bus-proxyd/synthesize.c
+++ b/src/bus-proxyd/synthesize.c
@@ -144,3 +144,70 @@ int synthetic_reply_return_strv(sd_bus_message *call, char **l) {
 
         return synthetic_driver_send(call->bus, m);
 }
+
+int synthesize_name_acquired(sd_bus *a, sd_bus *b, sd_bus_message *m) {
+        _cleanup_bus_message_unref_ sd_bus_message *n = NULL;
+        const char *name, *old_owner, *new_owner;
+        int r;
+
+        assert(a);
+        assert(b);
+        assert(m);
+
+        /* If we get NameOwnerChanged for our own name, we need to
+         * synthesize NameLost/NameAcquired, since socket clients need
+         * that, even though it is obsoleted on kdbus */
+
+        if (!a->is_kernel)
+                return 0;
+
+        if (!sd_bus_message_is_signal(m, "org.freedesktop.DBus", "NameOwnerChanged") ||
+            !streq_ptr(m->path, "/org/freedesktop/DBus") ||
+            !streq_ptr(m->sender, "org.freedesktop.DBus"))
+                return 0;
+
+        r = sd_bus_message_read(m, "sss", &name, &old_owner, &new_owner);
+        if (r < 0)
+                return r;
+
+        r = sd_bus_message_rewind(m, true);
+        if (r < 0)
+                return r;
+
+        if (streq(old_owner, a->unique_name)) {
+
+                r = sd_bus_message_new_signal(
+                                b,
+                                &n,
+                                "/org/freedesktop/DBus",
+                                "org.freedesktop.DBus",
+                                "NameLost");
+
+        } else if (streq(new_owner, a->unique_name)) {
+
+                r = sd_bus_message_new_signal(
+                                b,
+                                &n,
+                                "/org/freedesktop/DBus",
+                                "org.freedesktop.DBus",
+                                "NameAcquired");
+        } else
+                return 0;
+
+        if (r < 0)
+                return r;
+
+        r = sd_bus_message_append(n, "s", name);
+        if (r < 0)
+                return r;
+
+        r = bus_message_append_sender(n, "org.freedesktop.DBus");
+        if (r < 0)
+                return r;
+
+        r = bus_seal_synthetic_message(b, n);
+        if (r < 0)
+                return r;
+
+        return sd_bus_send(b, n, NULL);
+}
diff --git a/src/bus-proxyd/synthesize.h b/src/bus-proxyd/synthesize.h
index 2bc0be7..c24a8c8 100644
--- a/src/bus-proxyd/synthesize.h
+++ b/src/bus-proxyd/synthesize.h
@@ -28,3 +28,4 @@ int synthetic_reply_method_return(sd_bus_message *call, const char *types, ...);
 int synthetic_reply_return_strv(sd_bus_message *call, char **l);
 int synthetic_reply_method_error(sd_bus_message *call, const sd_bus_error *e);
 int synthetic_reply_method_errno(sd_bus_message *call, int error, const sd_bus_error *p);
+int synthesize_name_acquired(sd_bus *a, sd_bus *b, sd_bus_message *m);



More information about the systemd-commits mailing list