summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-24 21:20:53 +0100
committerLennart Poettering <lennart@poettering.net>2014-11-25 14:28:34 +0100
commitdc18cefdc3bdedddeddf05ede7d662ed15cde825 (patch)
tree814293fe495875bd54f64fa850d2eff30bbd5491 /src/libsystemd/sd-bus
parentbdb074a562e358d36590d09daddbf1f0c24e6676 (diff)
sd-bus: don't blindly take incomplete ucred bits from AF_UNIX when constructing message
Diffstat (limited to 'src/libsystemd/sd-bus')
-rw-r--r--src/libsystemd/sd-bus/bus-message.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 9d6647b2c4..6889754a96 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -420,10 +420,20 @@ int bus_message_from_header(
m->n_fds = n_fds;
if (ucred) {
- m->creds.uid = ucred->uid;
m->creds.pid = ucred->pid;
+ m->creds.uid = ucred->uid;
m->creds.gid = ucred->gid;
- m->creds.mask |= SD_BUS_CREDS_UID | SD_BUS_CREDS_PID | SD_BUS_CREDS_GID;
+
+ /* Due to namespace translations some data might be
+ * missing from this ucred record. */
+ if (m->creds.pid > 0)
+ m->creds.mask |= SD_BUS_CREDS_PID;
+
+ if (m->creds.uid != (uid_t) -1)
+ m->creds.mask |= SD_BUS_CREDS_UID;
+
+ if (m->creds.gid != (gid_t) -1)
+ m->creds.mask |= SD_BUS_CREDS_GID;
}
if (label) {