summaryrefslogtreecommitdiff
path: root/src/libsystemd
diff options
context:
space:
mode:
authorDaniel Mack <daniel@zonque.org>2015-03-02 11:36:35 +0100
committerDaniel Mack <daniel@zonque.org>2015-03-02 11:36:35 +0100
commit606303a93ea52a70ebba55bb3152820e630f2164 (patch)
treed8f102c6dc42f6a5f81f3ee39639be4e5a872c95 /src/libsystemd
parent9d3dec15ae8ac6153038c9b994e6c4fc22045180 (diff)
sd-bus: sync kdbus.h (ABI break)
After some reconsideration, we decided to move the binary protocol back to 64-bit wide UIDs and GIDs. After all, it should be possible to redefine [gu]id_t to uint64_t and things should continue to work. As we want to avoid such data types in kdbus.h, let's move back to 64-bit values and be safe. In sd-bus, we have to do a translation between uint64_t and gid_t now for supplementary gids. Some inline comments have also been updated in kdbus upstream.
Diffstat (limited to 'src/libsystemd')
-rw-r--r--src/libsystemd/sd-bus/bus-control.c11
-rw-r--r--src/libsystemd/sd-bus/bus-creds.c3
-rw-r--r--src/libsystemd/sd-bus/bus-kernel.c17
-rw-r--r--src/libsystemd/sd-bus/kdbus.h29
4 files changed, 40 insertions, 20 deletions
diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c
index 43c96726f8..c985b0e14a 100644
--- a/src/libsystemd/sd-bus/bus-control.c
+++ b/src/libsystemd/sd-bus/bus-control.c
@@ -583,16 +583,17 @@ static int bus_populate_creds_from_items(
case KDBUS_ITEM_AUXGROUPS:
if (mask & SD_BUS_CREDS_SUPPLEMENTARY_GIDS) {
- size_t n;
+ size_t i, n;
uid_t *g;
- assert_cc(sizeof(gid_t) == sizeof(uint32_t));
-
- n = (item->size - offsetof(struct kdbus_item, data32)) / sizeof(uint32_t);
- g = newdup(gid_t, item->data32, n);
+ n = (item->size - offsetof(struct kdbus_item, data64)) / sizeof(uint64_t);
+ g = new(gid_t, n);
if (!g)
return -ENOMEM;
+ for (i = 0; i < n; i++)
+ g[i] = item->data64[i];
+
free(c->supplementary_gids);
c->supplementary_gids = g;
c->n_supplementary_gids = n;
diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c
index a08391bfc2..d172dadbfd 100644
--- a/src/libsystemd/sd-bus/bus-creds.c
+++ b/src/libsystemd/sd-bus/bus-creds.c
@@ -51,6 +51,7 @@ void bus_creds_done(sd_bus_creds *c) {
free(c->user_unit);
free(c->slice);
free(c->unescaped_description);
+ free(c->supplementary_gids);
free(c->well_known_names); /* note that this is an strv, but
* we only free the array, not the
@@ -100,7 +101,9 @@ _public_ sd_bus_creds *sd_bus_creds_unref(sd_bus_creds *c) {
free(c->unique_name);
free(c->cgroup_root);
free(c->description);
+
free(c->supplementary_gids);
+ c->supplementary_gids = NULL;
strv_free(c->well_known_names);
c->well_known_names = NULL;
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 9e74530a36..2294eac97e 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -748,10 +748,21 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
case KDBUS_ITEM_AUXGROUPS:
if (bus->creds_mask & SD_BUS_CREDS_SUPPLEMENTARY_GIDS) {
- assert_cc(sizeof(gid_t) == sizeof(uint32_t));
+ size_t i, n;
+ gid_t *g;
- m->creds.n_supplementary_gids = (d->size - offsetof(struct kdbus_item, data32)) / sizeof(uint32_t);
- m->creds.supplementary_gids = (gid_t*) d->data32;
+ n = (d->size - offsetof(struct kdbus_item, data64)) / sizeof(uint64_t);
+ g = new(gid_t, n);
+ if (!g) {
+ r = -ENOMEM;
+ goto fail;
+ }
+
+ for (i = 0; i < n; i++)
+ g[i] = d->data64[i];
+
+ m->creds.supplementary_gids = g;
+ m->creds.n_supplementary_gids = n;
m->creds.mask |= SD_BUS_CREDS_SUPPLEMENTARY_GIDS;
}
diff --git a/src/libsystemd/sd-bus/kdbus.h b/src/libsystemd/sd-bus/kdbus.h
index 6cbd01c503..fc1d77dd7c 100644
--- a/src/libsystemd/sd-bus/kdbus.h
+++ b/src/libsystemd/sd-bus/kdbus.h
@@ -70,14 +70,14 @@ struct kdbus_notify_name_change {
* KDBUS_ITEM_CREDS
*/
struct kdbus_creds {
- __u32 uid;
- __u32 euid;
- __u32 suid;
- __u32 fsuid;
- __u32 gid;
- __u32 egid;
- __u32 sgid;
- __u32 fsgid;
+ __u64 uid;
+ __u64 euid;
+ __u64 suid;
+ __u64 fsuid;
+ __u64 gid;
+ __u64 egid;
+ __u64 sgid;
+ __u64 fsgid;
} __attribute__((__aligned__(8)));
/**
@@ -463,8 +463,10 @@ struct kdbus_item {
* cookie identifies the message and the
* respective reply carries the cookie
* in cookie_reply
- * @KDBUS_MSG_NO_AUTO_START: Do not start a service, if the addressed
- * name is not currently active
+ * @KDBUS_MSG_NO_AUTO_START: Do not start a service if the addressed
+ * name is not currently active. This flag is
+ * not looked at by the kernel but only
+ * serves as hint for userspace implementations.
* @KDBUS_MSG_SIGNAL: Treat this message as signal
*/
enum kdbus_msg_flags {
@@ -497,9 +499,12 @@ enum kdbus_payload_type {
* @cookie: Userspace-supplied cookie, for the connection
* to identify its messages
* @timeout_ns: The time to wait for a message reply from the peer.
- * If there is no reply, a kernel-generated message
+ * If there is no reply, and the send command is
+ * executed asynchronously, a kernel-generated message
* with an attached KDBUS_ITEM_REPLY_TIMEOUT item
- * is sent to @src_id. The timeout is expected in
+ * is sent to @src_id. For synchronously executed send
+ * command, the value denotes the maximum time the call
+ * blocks to wait for a reply. The timeout is expected in
* nanoseconds and as absolute CLOCK_MONOTONIC value.
* @cookie_reply: A reply to the requesting message with the same
* cookie. The requesting connection can match its