bus-kernel.c   bus-kernel.c 
skipping to change at line 545 skipping to change at line 545
case KDBUS_ITEM_CMDLINE: case KDBUS_ITEM_CMDLINE:
m->creds.cmdline = d->str; m->creds.cmdline = d->str;
m->creds.cmdline_size = l; m->creds.cmdline_size = l;
m->creds.mask |= SD_BUS_CREDS_CMDLINE & bus->creds_ mask; m->creds.mask |= SD_BUS_CREDS_CMDLINE & bus->creds_ mask;
break; break;
case KDBUS_ITEM_CGROUP: case KDBUS_ITEM_CGROUP:
m->creds.cgroup = d->str; m->creds.cgroup = d->str;
m->creds.mask |= (SD_BUS_CREDS_CGROUP|SD_BUS_CREDS_ UNIT|SD_BUS_CREDS_USER_UNIT|SD_BUS_CREDS_SLICE|SD_BUS_CREDS_SESSION|SD_BUS_ CREDS_OWNER_UID) & bus->creds_mask; m->creds.mask |= (SD_BUS_CREDS_CGROUP|SD_BUS_CREDS_ UNIT|SD_BUS_CREDS_USER_UNIT|SD_BUS_CREDS_SLICE|SD_BUS_CREDS_SESSION|SD_BUS_ CREDS_OWNER_UID) & bus->creds_mask;
if (!bus->cgroup_root) { r = bus_get_root_path(bus);
r = cg_get_root_path(&bus->cgroup_root); if (r < 0)
if (r < 0) goto fail;
goto fail;
}
m->creds.cgroup_root = bus->cgroup_root; m->creds.cgroup_root = bus->cgroup_root;
break; break;
case KDBUS_ITEM_AUDIT: case KDBUS_ITEM_AUDIT:
m->creds.audit_session_id = (uint32_t) d->audit.ses sionid; m->creds.audit_session_id = (uint32_t) d->audit.ses sionid;
m->creds.audit_login_uid = (uid_t) d->audit.loginui d; m->creds.audit_login_uid = (uid_t) d->audit.loginui d;
m->creds.mask |= (SD_BUS_CREDS_AUDIT_SESSION_ID|SD_ BUS_CREDS_AUDIT_LOGIN_UID) & bus->creds_mask; m->creds.mask |= (SD_BUS_CREDS_AUDIT_SESSION_ID|SD_ BUS_CREDS_AUDIT_LOGIN_UID) & bus->creds_mask;
break; break;
skipping to change at line 1114 skipping to change at line 1112
assert(mapped); assert(mapped);
assert(allocated); assert(allocated);
if (!bus || !bus->is_kernel) if (!bus || !bus->is_kernel)
return -ENOTSUP; return -ENOTSUP;
assert_se(pthread_mutex_lock(&bus->memfd_cache_mutex) >= 0); assert_se(pthread_mutex_lock(&bus->memfd_cache_mutex) >= 0);
if (bus->n_memfd_cache <= 0) { if (bus->n_memfd_cache <= 0) {
_cleanup_free_ char *g = NULL; _cleanup_free_ char *g = NULL;
struct kdbus_cmd_memfd_make *cmd;
struct kdbus_item *item;
size_t l, sz;
int r; int r;
assert_se(pthread_mutex_unlock(&bus->memfd_cache_mutex) >= 0); assert_se(pthread_mutex_unlock(&bus->memfd_cache_mutex) >= 0);
assert(bus->connection_name); assert(bus->connection_name);
g = bus_label_escape(bus->connection_name); g = bus_label_escape(bus->connection_name);
if (!g) if (!g)
return -ENOMEM; return -ENOMEM;
l = strlen(g); r = memfd_create(g, MFD_ALLOW_SEALING);
sz = ALIGN8(offsetof(struct kdbus_cmd_memfd_make, items)) +
ALIGN8(offsetof(struct kdbus_item, str)) +
l + 1;
cmd = alloca0(sz);
cmd->size = sz;
item = cmd->items;
item->size = ALIGN8(offsetof(struct kdbus_item, str)) + l +
1;
item->type = KDBUS_ITEM_MEMFD_NAME;
memcpy(item->str, g, l + 1);
r = ioctl(bus->input_fd, KDBUS_CMD_MEMFD_NEW, cmd);
if (r < 0) if (r < 0)
return -errno; return -errno;
*address = NULL; *address = NULL;
*mapped = 0; *mapped = 0;
*allocated = 0; *allocated = 0;
return cmd->fd; return r;
} }
c = &bus->memfd_cache[--bus->n_memfd_cache]; c = &bus->memfd_cache[--bus->n_memfd_cache];
assert(c->fd >= 0); assert(c->fd >= 0);
assert(c->mapped == 0 || c->address); assert(c->mapped == 0 || c->address);
*address = c->address; *address = c->address;
*mapped = c->mapped; *mapped = c->mapped;
*allocated = c->allocated; *allocated = c->allocated;
skipping to change at line 1198 skipping to change at line 1181
close_and_munmap(fd, address, mapped); close_and_munmap(fd, address, mapped);
return; return;
} }
c = &bus->memfd_cache[bus->n_memfd_cache++]; c = &bus->memfd_cache[bus->n_memfd_cache++];
c->fd = fd; c->fd = fd;
c->address = address; c->address = address;
/* If overly long, let's return a bit to the OS */ /* If overly long, let's return a bit to the OS */
if (mapped > max_mapped) { if (mapped > max_mapped) {
assert_se(ioctl(fd, KDBUS_CMD_MEMFD_SIZE_SET, &max_mapped) >= 0); assert_se(ftruncate(fd, max_mapped) >= 0);
assert_se(munmap((uint8_t*) address + max_mapped, PAGE_ALIG N(mapped - max_mapped)) >= 0); assert_se(munmap((uint8_t*) address + max_mapped, PAGE_ALIG N(mapped - max_mapped)) >= 0);
c->mapped = c->allocated = max_mapped; c->mapped = c->allocated = max_mapped;
} else { } else {
c->mapped = mapped; c->mapped = mapped;
c->allocated = allocated; c->allocated = allocated;
} }
assert_se(pthread_mutex_unlock(&bus->memfd_cache_mutex) >= 0); assert_se(pthread_mutex_unlock(&bus->memfd_cache_mutex) >= 0);
} }
skipping to change at line 1405 skipping to change at line 1388
default: default:
assert_not_reached("Unknown policy type"); assert_not_reached("Unknown policy type");
} }
item->policy_access.access = bus_kernel_translate_access(policy->ac cess); item->policy_access.access = bus_kernel_translate_access(policy->ac cess);
return 0; return 0;
} }
int bus_kernel_open_bus_fd(const char *bus) { int bus_kernel_open_bus_fd(const char *bus, char **path) {
char *p; char *p;
int fd; int fd;
size_t len;
len = strlen("/dev/kdbus/") + DECIMAL_STR_MAX(uid_t) + 1 + strlen(b
us) + strlen("/bus") + 1;
p = alloca(strlen("/dev/kdbus/") + DECIMAL_STR_MAX(uid_t) + 1 + str if (path) {
len(bus) + strlen("/bus") + 1); p = malloc(len);
if (!p)
return -ENOMEM;
*path = p;
} else
p = alloca(len);
sprintf(p, "/dev/kdbus/" UID_FMT "-%s/bus", getuid(), bus); sprintf(p, "/dev/kdbus/" UID_FMT "-%s/bus", getuid(), bus);
fd = open(p, O_RDWR|O_NOCTTY|O_CLOEXEC); fd = open(p, O_RDWR|O_NOCTTY|O_CLOEXEC);
if (fd < 0) if (fd < 0)
return -errno; return -errno;
return fd; return fd;
} }
int bus_kernel_make_starter( int bus_kernel_make_starter(
skipping to change at line 1552 skipping to change at line 1544
return fd; return fd;
} }
int bus_kernel_create_monitor(const char *bus) { int bus_kernel_create_monitor(const char *bus) {
struct kdbus_cmd_hello *hello; struct kdbus_cmd_hello *hello;
int fd; int fd;
assert(bus); assert(bus);
fd = bus_kernel_open_bus_fd(bus); fd = bus_kernel_open_bus_fd(bus, NULL);
if (fd < 0) if (fd < 0)
return fd; return fd;
hello = alloca0(sizeof(struct kdbus_cmd_hello)); hello = alloca0(sizeof(struct kdbus_cmd_hello));
hello->size = sizeof(struct kdbus_cmd_hello); hello->size = sizeof(struct kdbus_cmd_hello);
hello->conn_flags = KDBUS_HELLO_ACTIVATOR; hello->conn_flags = KDBUS_HELLO_ACTIVATOR;
hello->pool_size = KDBUS_POOL_SIZE; hello->pool_size = KDBUS_POOL_SIZE;
if (ioctl(fd, KDBUS_CMD_HELLO, hello) < 0) { if (ioctl(fd, KDBUS_CMD_HELLO, hello) < 0) {
safe_close(fd); safe_close(fd);
 End of changes. 9 change blocks. 
28 lines changed or deleted 19 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/