#include "bus-control.h"
#include "bus-bloom.h"
#include "bus-util.h"
+#include "cgroup-util.h"
_public_ int sd_bus_get_unique_name(sd_bus *bus, const char **unique) {
int r;
switch (item->type) {
case KDBUS_ITEM_CREDS:
- m = (SD_BUS_CREDS_UID | SD_BUS_CREDS_GID | SD_BUS_CREDS_PID |
- SD_BUS_CREDS_TID | SD_BUS_CREDS_PID_STARTTIME) & mask;
+ m = (SD_BUS_CREDS_UID | SD_BUS_CREDS_GID | SD_BUS_CREDS_PID) & mask;
if (m) {
c->uid = item->creds.uid;
c->pid = item->creds.pid;
c->gid = item->creds.gid;
+ c->mask |= m;
+ }
+
+ if (mask & SD_BUS_CREDS_TID && item->creds.tid > 0) {
c->tid = item->creds.tid;
+ c->mask |= SD_BUS_CREDS_TID;
+ }
+
+ if (mask & SD_BUS_CREDS_PID_STARTTIME && item->creds.starttime > 0) {
c->pid_starttime = item->creds.starttime;
- c->mask |= m;
+ c->mask |= SD_BUS_CREDS_PID_STARTTIME;
}
+
break;
case KDBUS_ITEM_PID_COMM:
goto fail;
}
+ if (!bus->cgroup_root) {
+ r = cg_get_root_path(&bus->cgroup_root);
+ if (r < 0)
+ goto fail;
+ }
+
+ c->cgroup_root = strdup(bus->cgroup_root);
+ if (!c->cgroup_root) {
+ r = -ENOMEM;
+ goto fail;
+ }
+
c->mask |= m;
}
break;
zero(bloom);
- sz = ALIGN8(offsetof(struct kdbus_cmd_match, items) +
- offsetof(struct kdbus_item, id) + sizeof(uint64_t));
+ sz = ALIGN8(offsetof(struct kdbus_cmd_match, items));
for (i = 0; i < n_components; i++) {
struct bus_match_component *c = &components[i];
r = bus_kernel_parse_unique_name(c->value_str, &src_id);
if (r < 0)
return r;
-
- if (r == 0) {
+ else if (r > 0)
+ sz += ALIGN8(offsetof(struct kdbus_item, id) + sizeof(uint64_t));
+ else {
sender = c->value_str;
sender_length = strlen(sender);
sz += ALIGN8(offsetof(struct kdbus_item, str) + sender_length + 1);
m->owner_id = id;
item = m->items;
- item->size = offsetof(struct kdbus_item, id) + sizeof(uint64_t);
- item->type = KDBUS_ITEM_ID;
- item->id = src_id;
- if (using_bloom) {
+ if (src_id != KDBUS_MATCH_ID_ANY) {
+ item->size = offsetof(struct kdbus_item, id) + sizeof(uint64_t);
+ item->type = KDBUS_ITEM_ID;
+ item->id = src_id;
item = KDBUS_ITEM_NEXT(item);
+ }
+
+ if (using_bloom) {
item->size = offsetof(struct kdbus_item, data64) + BLOOM_SIZE;
item->type = KDBUS_ITEM_BLOOM;
memcpy(item->data64, bloom, BLOOM_SIZE);
+ item = KDBUS_ITEM_NEXT(item);
}
if (sender) {
- item = KDBUS_ITEM_NEXT(item);
item->size = offsetof(struct kdbus_item, str) + sender_length + 1;
item->type = KDBUS_ITEM_NAME;
memcpy(item->str, sender, sender_length + 1);