]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bus-creds: always set SD_BUS_CREDS_PID when we set pid in the mask
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 25 May 2015 00:20:06 +0000 (20:20 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 9 Jun 2015 13:13:35 +0000 (09:13 -0400)
Also reorder the code a bit to be easier to parse.

src/core/selinux-access.c
src/libsystemd/sd-bus/bus-creds.c

index 5e9a4a5e02c6aaee3537a14e81cdf4bd56943c36..decd42f95a54857745a723a587a76feb5f1a7a42 100644 (file)
@@ -261,7 +261,7 @@ int mac_selinux_generic_access_check(
         audit_info.path = path;
         audit_info.cmdline = cl;
 
-        r = selinux_check_access((security_context_t) scon, fcon, tclass, permission, &audit_info);
+        r = selinux_check_access(scon, fcon, tclass, permission, &audit_info);
         if (r < 0)
                 r = sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "SELinux policy denies access.");
 
index 4d67619cf83e799acb7b8c7c4255eeb6708305af..1c365b7fcd54960da7dfc2e1cae6504882cbe304 100644 (file)
@@ -773,11 +773,13 @@ int bus_creds_add_more(sd_bus_creds *c, uint64_t mask, pid_t pid, pid_t tid) {
                 return 0;
 
         /* Try to retrieve PID from creds if it wasn't passed to us */
-        if (pid <= 0 && (c->mask & SD_BUS_CREDS_PID))
+        if (pid > 0) {
+                c->pid = pid;
+                c->mask |= SD_BUS_CREDS_PID;
+        } else if (c->mask & SD_BUS_CREDS_PID)
                 pid = c->pid;
-
-        /* Without pid we cannot do much... */
-        if (pid <= 0)
+        else
+                /* Without pid we cannot do much... */
                 return 0;
 
         /* Try to retrieve TID from creds if it wasn't passed to us */
@@ -789,9 +791,6 @@ int bus_creds_add_more(sd_bus_creds *c, uint64_t mask, pid_t pid, pid_t tid) {
         if (missing == 0)
                 return 0;
 
-        c->pid = pid;
-        c->mask |= SD_BUS_CREDS_PID;
-
         if (tid > 0) {
                 c->tid = tid;
                 c->mask |= SD_BUS_CREDS_TID;