***/
#include <endian.h>
-#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
-#include <sys/poll.h>
-#include <byteswap.h>
+#include <poll.h>
#include <sys/mman.h>
#include <pthread.h>
#include "util.h"
#include "macro.h"
#include "strv.h"
-#include "set.h"
#include "missing.h"
#include "def.h"
#include "cgroup-util.h"
#include "bus-socket.h"
#include "bus-kernel.h"
#include "bus-control.h"
-#include "bus-introspect.h"
-#include "bus-signature.h"
#include "bus-objects.h"
#include "bus-util.h"
#include "bus-container.h"
return free_and_strdup(&bus->description, description);
}
+_public_ int sd_bus_set_allow_interactive_authorization(sd_bus *bus, int b) {
+ assert_return(bus, -EINVAL);
+ assert_return(!bus_pid_changed(bus), -ECHILD);
+
+ bus->allow_interactive_authorization = !!b;
+ return 0;
+}
+
+_public_ int sd_bus_get_allow_interactive_authorization(sd_bus *bus) {
+ assert_return(bus, -EINVAL);
+ assert_return(!bus_pid_changed(bus), -ECHILD);
+
+ return bus->allow_interactive_authorization;
+}
+
static int hello_callback(sd_bus *bus, sd_bus_message *reply, void *userdata, sd_bus_error *error) {
const char *s;
int r;
if (!e)
return -ENOMEM;
- c = strappenda(",argv4=--machine=", m);
+ c = strjoina(",argv4=--machine=", m);
}
}
assert(b);
assert(m);
+ /* Fake some timestamps, if they were requested, and not
+ * already initialized */
+ if (b->attach_flags & KDBUS_ATTACH_TIMESTAMP) {
+ if (m->realtime <= 0)
+ m->realtime = now(CLOCK_REALTIME);
+
+ if (m->monotonic <= 0)
+ m->monotonic = now(CLOCK_MONOTONIC);
+ }
+
/* The bus specification says the serial number cannot be 0,
* hence let's fill something in for synthetic messages. Since
* synthetic messages might have a fake sender and we don't
* pick a fixed, artificial one. We use (uint32_t) -1 rather
* than (uint64_t) -1 since dbus1 only had 32bit identifiers,
* even though kdbus can do 64bit. */
-
return bus_message_seal(m, 0xFFFFFFFFULL, 0);
}
/* If this is a reply and no reply was requested, then let's
* suppress this, if we can */
- if (m->dont_send && !cookie)
- return 1;
+ if (m->dont_send)
+ goto finish;
if ((bus->state == BUS_RUNNING || bus->state == BUS_HELLO) && bus->wqueue_size <= 0) {
size_t idx = 0;
}
return r;
- } else if (!bus->is_kernel && idx < BUS_MESSAGE_SIZE(m)) {
+ }
+
+ if (!bus->is_kernel && idx < BUS_MESSAGE_SIZE(m)) {
/* Wasn't fully written. So let's remember how
* much was written. Note that the first entry
* of the wqueue array is always allocated so
bus->wqueue_size = 1;
bus->windex = idx;
}
+
} else {
/* Just append it to the queue. */
bus->wqueue[bus->wqueue_size ++] = sd_bus_message_ref(m);
}
+finish:
if (cookie)
*cookie = BUS_MESSAGE_COOKIE(m);
if (r < 0)
return r;
- m->sender = "org.freedesktop.DBus";
-
r = bus_seal_synthetic_message(bus, m);
if (r < 0)
return r;
if (r < 0)
return r;
+ /* Copy over original timestamp */
+ synthetic_reply->realtime = m->realtime;
+ synthetic_reply->monotonic = m->monotonic;
+ synthetic_reply->seqnum = m->seqnum;
+
r = bus_seal_synthetic_message(bus, synthetic_reply);
if (r < 0)
return r;
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;