summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libsystemd-bus/bus-kernel.c13
-rw-r--r--src/libsystemd-bus/bus-message.c10
-rw-r--r--src/libsystemd-bus/test-bus-kernel.c3
3 files changed, 25 insertions, 1 deletions
diff --git a/src/libsystemd-bus/bus-kernel.c b/src/libsystemd-bus/bus-kernel.c
index 712b697b0a..83379d1430 100644
--- a/src/libsystemd-bus/bus-kernel.c
+++ b/src/libsystemd-bus/bus-kernel.c
@@ -224,6 +224,7 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess
_cleanup_free_ int *fds = NULL;
struct bus_header *h = NULL;
size_t total, n_bytes = 0, idx = 0;
+ struct kdbus_creds *creds = NULL;
int r;
assert(bus);
@@ -262,7 +263,9 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess
fds = f;
memcpy(fds + n_fds, d->fds, j);
n_fds += j;
- }
+
+ } else if (d->type == KDBUS_MSG_SRC_CREDS)
+ creds = &d->creds;
}
if (!h)
@@ -301,6 +304,14 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k, sd_bus_mess
idx += l;
}
+ if (creds) {
+ m->uid = creds->uid;
+ m->gid = creds->gid;
+ m->pid = creds->pid;
+ m->tid = creds->tid;
+ m->uid_valid = m->gid_valid = true;
+ }
+
r = bus_message_parse_fields(m);
if (r < 0) {
sd_bus_message_unref(m);
diff --git a/src/libsystemd-bus/bus-message.c b/src/libsystemd-bus/bus-message.c
index eeb1d823e8..092654ff45 100644
--- a/src/libsystemd-bus/bus-message.c
+++ b/src/libsystemd-bus/bus-message.c
@@ -2902,6 +2902,16 @@ int bus_message_dump(sd_bus_message *m) {
strna(m->error.message),
yes_no(m->sealed));
+ if (m->pid != 0)
+ printf("\tpid=%lu\n", (unsigned long) m->pid);
+ if (m->tid != 0)
+ printf("\ttid=%lu\n", (unsigned long) m->tid);
+ if (m->uid_valid)
+ printf("\tuid=%lu\n", (unsigned long) m->uid);
+ if (m->gid_valid)
+ printf("\tgid=%lu\n", (unsigned long) m->gid);
+
+
r = sd_bus_message_rewind(m, true);
if (r < 0) {
log_error("Failed to rewind: %s", strerror(-r));
diff --git a/src/libsystemd-bus/test-bus-kernel.c b/src/libsystemd-bus/test-bus-kernel.c
index 4c599788fe..9b2ee7d5a7 100644
--- a/src/libsystemd-bus/test-bus-kernel.c
+++ b/src/libsystemd-bus/test-bus-kernel.c
@@ -75,6 +75,9 @@ int main(int argc, char *argv[]) {
assert_se(r > 0);
assert_se(m);
+ bus_message_dump(m);
+ assert_se(sd_bus_message_rewind(m, true) >= 0);
+
r = sd_bus_message_read(m, "s", &the_string);
assert_se(r >= 0);
assert_se(streq(the_string, "I am a string"));