|
Zbigniew Jędrzejewski-Szmek |
436654 |
From 5e6a495495972f748e69d6ec1a8ba2b78aaa7f5a Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
Date: Sun, 24 May 2015 20:20:06 -0400
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
Subject: [PATCH] bus-creds: always set SD_BUS_CREDS_PID when we set pid in the
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
mask
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
Also reorder the code a bit to be easier to parse.
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
(cherry picked from commit 236f83afa935d6e07fcd5c17b5db7b1cf424267a)
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
src/core/selinux-access.c | 2 +-
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
src/libsystemd/sd-bus/bus-creds.c | 13 ++++++-------
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
2 files changed, 7 insertions(+), 8 deletions(-)
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
index 5e9a4a5e02..decd42f95a 100644
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
--- a/src/core/selinux-access.c
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
+++ b/src/core/selinux-access.c
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
@@ -261,7 +261,7 @@ int mac_selinux_generic_access_check(
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
audit_info.path = path;
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
audit_info.cmdline = cl;
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
- r = selinux_check_access((security_context_t) scon, fcon, tclass, permission, &audit_info);
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
+ r = selinux_check_access(scon, fcon, tclass, permission, &audit_info);
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
r = sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "SELinux policy denies access.");
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
index 4d67619cf8..1c365b7fcd 100644
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
--- a/src/libsystemd/sd-bus/bus-creds.c
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
+++ b/src/libsystemd/sd-bus/bus-creds.c
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
@@ -773,11 +773,13 @@ int bus_creds_add_more(sd_bus_creds *c, uint64_t mask, pid_t pid, pid_t tid) {
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
/* Try to retrieve PID from creds if it wasn't passed to us */
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
- if (pid <= 0 && (c->mask & SD_BUS_CREDS_PID))
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
+ if (pid > 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
+ c->pid = pid;
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
+ c->mask |= SD_BUS_CREDS_PID;
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
+ } else if (c->mask & SD_BUS_CREDS_PID)
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
pid = c->pid;
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
- /* Without pid we cannot do much... */
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
- if (pid <= 0)
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
+ else
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
+ /* Without pid we cannot do much... */
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
/* Try to retrieve TID from creds if it wasn't passed to us */
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
@@ -789,9 +791,6 @@ int bus_creds_add_more(sd_bus_creds *c, uint64_t mask, pid_t pid, pid_t tid) {
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
if (missing == 0)
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
return 0;
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
- c->pid = pid;
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
- c->mask |= SD_BUS_CREDS_PID;
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
-
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
if (tid > 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
c->tid = tid;
|
|
Zbigniew Jędrzejewski-Szmek |
436654 |
c->mask |= SD_BUS_CREDS_TID;
|