1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-08 11:27:32 +03:00

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.
This commit is contained in:
Daniel Mack 2015-03-02 11:36:35 +01:00
parent 9d3dec15ae
commit 606303a93e
4 changed files with 40 additions and 20 deletions

View 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;

View 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;

View 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;
}

View 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