memzero(m->kdbus, sz);
m->kdbus->flags =
- ((m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) ? 0 : KDBUS_MSG_FLAGS_EXPECT_REPLY) |
- ((m->header->flags & BUS_MESSAGE_NO_AUTO_START) ? KDBUS_MSG_FLAGS_NO_AUTO_START : 0);
+ ((m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) ? 0 : KDBUS_MSG_EXPECT_REPLY) |
+ ((m->header->flags & BUS_MESSAGE_NO_AUTO_START) ? KDBUS_MSG_NO_AUTO_START : 0);
if (well_known)
/* verify_destination_id will usually be 0, which makes the kernel driver only look
case KDBUS_ITEM_PIDS:
- /* The PID starttime/TID might be missing,
- * when the data is faked by some data bus
- * proxy and it lacks that information about
- * the real client since SO_PEERCRED is used
- * for that. */
+ /* The PID/TID might be missing, when the data
+ * is faked by some data bus proxy and it
+ * lacks that information about the real
+ * client since SO_PEERCRED is used for
+ * that. */
if (d->pids.pid > 0) {
m->creds.pid = (pid_t) d->pids.pid;
m->creds.mask |= SD_BUS_CREDS_PID & bus->creds_mask;
}
- if (d->pids.starttime > 0) {
- m->creds.pid_starttime = d->pids.starttime / NSEC_PER_USEC;
- m->creds.mask |= SD_BUS_CREDS_PID_STARTTIME & bus->creds_mask;
- }
-
if (d->pids.tid > 0) {
m->creds.tid = (pid_t) d->pids.tid;
m->creds.mask |= SD_BUS_CREDS_TID & bus->creds_mask;
}
/* Refuse messages where the reply flag doesn't match up */
- if (!(m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) != !!(k->flags & KDBUS_MSG_FLAGS_EXPECT_REPLY)) {
+ if (!(m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) != !!(k->flags & KDBUS_MSG_EXPECT_REPLY)) {
r = -EBADMSG;
goto fail;
}
}
/* Refuse messages where the autostart flag doesn't match up */
- if (!(m->header->flags & BUS_MESSAGE_NO_AUTO_START) != !(k->flags & KDBUS_MSG_FLAGS_NO_AUTO_START)) {
+ if (!(m->header->flags & BUS_MESSAGE_NO_AUTO_START) != !(k->flags & KDBUS_MSG_NO_AUTO_START)) {
r = -EBADMSG;
goto fail;
}
}
int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call) {
+ struct kdbus_cmd_send cmd = { };
int r;
assert(bus);
if (r < 0)
return r;
+ cmd.size = sizeof(cmd);
+ cmd.msg_address = (uintptr_t)m->kdbus;
+
/* If this is a synchronous method call, then let's tell the
* kernel, so that it can pass CPU time/scheduling to the
* destination for the time, if it wants to. If we
* synchronously wait for the result anyway, we won't need CPU
* anyway. */
- if (hint_sync_call)
- m->kdbus->flags |= KDBUS_MSG_FLAGS_EXPECT_REPLY|KDBUS_MSG_FLAGS_SYNC_REPLY;
+ if (hint_sync_call) {
+ m->kdbus->flags |= KDBUS_MSG_EXPECT_REPLY;
+ cmd.flags |= KDBUS_SEND_SYNC_REPLY;
+ }
- r = ioctl(bus->output_fd, KDBUS_CMD_MSG_SEND, m->kdbus);
+ r = ioctl(bus->output_fd, KDBUS_CMD_SEND, &cmd);
if (r < 0) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
sd_bus_message *reply;
} else if (hint_sync_call) {
struct kdbus_msg *k;
- k = (struct kdbus_msg *)((uint8_t *)bus->kdbus_buffer + m->kdbus->offset_reply);
+ k = (struct kdbus_msg *)((uint8_t *)bus->kdbus_buffer + cmd.reply.offset);
assert(k);
if (k->payload_type == KDBUS_PAYLOAD_DBUS) {
}
int bus_kernel_read_message(sd_bus *bus, bool hint_priority, int64_t priority) {
- struct kdbus_cmd_recv recv = {};
+ struct kdbus_cmd_recv recv = { .size = sizeof(recv) };
struct kdbus_msg *k;
int r;
recv.priority = priority;
}
- r = ioctl(bus->input_fd, KDBUS_CMD_MSG_RECV, &recv);
+ r = ioctl(bus->input_fd, KDBUS_CMD_RECV, &recv);
if (r < 0) {
if (errno == EAGAIN)
return 0;
return -errno;
}
- k = (struct kdbus_msg *)((uint8_t *)bus->kdbus_buffer + recv.offset);
+ k = (struct kdbus_msg *)((uint8_t *)bus->kdbus_buffer + recv.reply.offset);
if (k->payload_type == KDBUS_PAYLOAD_DBUS) {
r = bus_kernel_make_message(bus, k);
SD_BUS_CREDS_GID|SD_BUS_CREDS_EGID|SD_BUS_CREDS_SGID|SD_BUS_CREDS_FSGID))
m |= KDBUS_ATTACH_CREDS;
- if (mask & (SD_BUS_CREDS_PID|SD_BUS_CREDS_PID_STARTTIME|SD_BUS_CREDS_TID))
+ if (mask & (SD_BUS_CREDS_PID|SD_BUS_CREDS_TID))
m |= KDBUS_ATTACH_PIDS;
if (mask & SD_BUS_CREDS_COMM)
int bus_kernel_drop_one(int fd) {
struct kdbus_cmd_recv recv = {
- .flags = KDBUS_RECV_DROP
+ .size = sizeof(recv),
+ .flags = KDBUS_RECV_DROP,
};
assert(fd >= 0);
- if (ioctl(fd, KDBUS_CMD_MSG_RECV, &recv) < 0)
+ if (ioctl(fd, KDBUS_CMD_RECV, &recv) < 0)
return -errno;
return 0;
r = write_string_file("/sys/module/kdbus/parameters/attach_flags_mask", buf);
if (r < 0)
return log_full_errno(
- r == -EROFS ? LOG_DEBUG : LOG_WARNING, r,
+ IN_SET(r, -ENOENT, -EROFS) ? LOG_DEBUG : LOG_WARNING, r,
"Failed to write kdbus attach mask: %m");
return 0;