summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus/bus-control.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-24 16:20:47 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-24 16:20:47 +0100
commit2dc9970bed3cee69e6746b110a649a9285dd6369 (patch)
tree848a91dc350b1d077ee5c98b5ea2bc90cd793a2f /src/libsystemd-bus/bus-control.c
parenteff05270986a13e7de93ae16311f654d3f7c166f (diff)
bus: only accept kdbus creds if they are valid
This allows userspace to fake kdbus creds via struct ucred in the proxy, without making the recieving side choke on the missing fields of the kdbus struct, more precisel pid_starttime and tid
Diffstat (limited to 'src/libsystemd-bus/bus-control.c')
-rw-r--r--src/libsystemd-bus/bus-control.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/libsystemd-bus/bus-control.c b/src/libsystemd-bus/bus-control.c
index 1eed7b9e32..55986f349b 100644
--- a/src/libsystemd-bus/bus-control.c
+++ b/src/libsystemd-bus/bus-control.c
@@ -407,17 +407,25 @@ static int bus_get_owner_kdbus(
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: