return 1;
}
+static int patch_sender(sd_bus *a, sd_bus_message *m) {
+ char **well_known = NULL;
+ sd_bus_creds *c;
+ int r;
+
+ assert(a);
+ assert(m);
+
+ if (!a->is_kernel)
+ return 0;
+
+ /* We will change the sender of messages from the bus driver
+ * so that they originate from the bus driver. This is a
+ * speciality originating from dbus1, where the bus driver did
+ * not have a unique id, but only the well-known name. */
+
+ c = sd_bus_message_get_creds(m);
+ if (!c)
+ return 0;
+
+ r = sd_bus_creds_get_well_known_names(c, &well_known);
+ if (r < 0)
+ return r;
+
+ if (strv_contains(well_known, "org.freedesktop.DBus"))
+ m->sender = "org.freedesktop.DBus";
+
+ return 0;
+}
+
int main(int argc, char *argv[]) {
_cleanup_bus_unref_ sd_bus *a = NULL, *b = NULL;
goto finish;
}
+ r = sd_bus_set_name(a, "sd-proxy");
+ if (r < 0) {
+ log_error("Failed to set bus name: %s", strerror(-r));
+ goto finish;
+ }
+
r = sd_bus_set_address(a, arg_address);
if (r < 0) {
log_error("Failed to set address to connect to: %s", strerror(-r));
goto finish;
}
+ patch_sender(a, m);
+
k = sd_bus_send(b, m, NULL);
if (k < 0) {
if (k == -ECONNRESET)
k = process_hello(a, b, m, &got_hello);
if (k < 0) {
r = k;
+ log_error("Failed to process HELLO: %s", strerror(-r));
goto finish;
}
k = process_policy(a, b, m);
if (k < 0) {
r = k;
+ log_error("Failed to process policy: %s", strerror(-r));
goto finish;
}