chiark / gitweb /
sd-bus: unify how we set the sender of synthetic messages
authorLennart Poettering <lennart@poettering.net>
Wed, 7 Jan 2015 19:25:30 +0000 (20:25 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 7 Jan 2015 19:25:30 +0000 (20:25 +0100)
src/libsystemd/sd-bus/bus-kernel.c
src/libsystemd/sd-bus/bus-message.c
src/libsystemd/sd-bus/bus-message.h
src/libsystemd/sd-bus/sd-bus.c

index 4dcea8e..7c946e6 100644 (file)
@@ -379,15 +379,6 @@ fail:
         return r;
 }
 
-static void bus_message_set_sender_driver(sd_bus *bus, sd_bus_message *m) {
-        assert(bus);
-        assert(m);
-
-        m->sender = m->creds.unique_name = (char*) "org.freedesktop.DBus";
-        m->creds.well_known_names_driver = true;
-        m->creds.mask |= (SD_BUS_CREDS_UNIQUE_NAME|SD_BUS_CREDS_WELL_KNOWN_NAMES) & bus->creds_mask;
-}
-
 static void unset_memfds(struct sd_bus_message *m) {
         struct bus_body_part *part;
         unsigned i;
@@ -1274,7 +1265,6 @@ static int translate_reply(
         if (r < 0)
                 return r;
 
-        bus_message_set_sender_driver(bus, m);
         message_set_timestamp(bus, m, ts);
 
         r = bus_seal_synthetic_message(bus, m);
index 0f9334b..f352c72 100644 (file)
@@ -754,6 +754,24 @@ _public_ int sd_bus_message_new_method_errnof(
         return sd_bus_message_new_method_error(call, m, &berror);
 }
 
+void bus_message_set_sender_local(sd_bus *bus, sd_bus_message *m) {
+        assert(bus);
+        assert(m);
+
+        m->sender = m->creds.unique_name = (char*) "org.freedesktop.DBus.Local";
+        m->creds.well_known_names_local = true;
+        m->creds.mask |= (SD_BUS_CREDS_UNIQUE_NAME|SD_BUS_CREDS_WELL_KNOWN_NAMES) & bus->creds_mask;
+}
+
+void bus_message_set_sender_driver(sd_bus *bus, sd_bus_message *m) {
+        assert(bus);
+        assert(m);
+
+        m->sender = m->creds.unique_name = (char*) "org.freedesktop.DBus";
+        m->creds.well_known_names_driver = true;
+        m->creds.mask |= (SD_BUS_CREDS_UNIQUE_NAME|SD_BUS_CREDS_WELL_KNOWN_NAMES) & bus->creds_mask;
+}
+
 int bus_message_new_synthetic_error(
                 sd_bus *bus,
                 uint64_t cookie,
@@ -796,6 +814,8 @@ int bus_message_new_synthetic_error(
 
         t->error._need_free = -1;
 
+        bus_message_set_sender_driver(bus, t);
+
         *m = t;
         return 0;
 
index 4dd280d..b4cdce7 100644 (file)
@@ -235,3 +235,6 @@ int bus_message_new_synthetic_error(sd_bus *bus, uint64_t serial, const sd_bus_e
 int bus_message_remarshal(sd_bus *bus, sd_bus_message **m);
 
 int bus_message_append_sender(sd_bus_message *m, const char *sender);
+
+void bus_message_set_sender_driver(sd_bus *bus, sd_bus_message *m);
+void bus_message_set_sender_local(sd_bus *bus, sd_bus_message *m);
index a8d03b8..4b1c60e 100644 (file)
@@ -2140,8 +2140,6 @@ static int process_timeout(sd_bus *bus) {
         if (r < 0)
                 return r;
 
-        m->sender = "org.freedesktop.DBus";
-
         r = bus_seal_synthetic_message(bus, m);
         if (r < 0)
                 return r;
@@ -2544,15 +2542,6 @@ null_message:
         return r;
 }
 
-static void bus_message_set_sender_local(sd_bus *bus, sd_bus_message *m) {
-        assert(bus);
-        assert(m);
-
-        m->sender = m->creds.unique_name = (char*) "org.freedesktop.DBus.Local";
-        m->creds.well_known_names_local = true;
-        m->creds.mask |= (SD_BUS_CREDS_UNIQUE_NAME|SD_BUS_CREDS_WELL_KNOWN_NAMES) & bus->creds_mask;
-}
-
 static int process_closing(sd_bus *bus, sd_bus_message **ret) {
         _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
         struct reply_callback *c;