chiark / gitweb /
sd-bus: sync kdbus.h (ABI break)
authorDaniel Mack <daniel@zonque.org>
Mon, 2 Mar 2015 10:36:35 +0000 (11:36 +0100)
committerDaniel Mack <daniel@zonque.org>
Mon, 2 Mar 2015 10:36:35 +0000 (11:36 +0100)
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.

src/libsystemd/sd-bus/bus-control.c
src/libsystemd/sd-bus/bus-creds.c
src/libsystemd/sd-bus/bus-kernel.c
src/libsystemd/sd-bus/kdbus.h

index 43c96726f8200e2f6d11b5b0bb45502ca7aec730..c985b0e14a0f42299a98168594b5f60817eec984 100644 (file)
@@ -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;
index a08391bfc2ae2e47b23743d9e13d8cd1f57a8448..d172dadbfd7388682834f9537c1bcdd9384eec2d 100644 (file)
@@ -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;
index 9e74530a362d4df1aefe856c9597e62c995386ff..2294eac97eb6582427e2af18219039a5603f532a 100644 (file)
@@ -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;
                         }
 
index 6cbd01c5030be5c55d747d06b4f67aa739060ba9..fc1d77dd7c93bbc685bbdd1e5c8bae9865390822 100644 (file)
@@ -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