valeriyvdovin / rpms / systemd

Forked from rpms/systemd 4 years ago
Clone

Blame SOURCES/0243-selinux-fix-missing-SELinux-unit-access-check.patch

803fb7
From 0b630ecdbfe20ddff9da4f4b6712e80b745b5ab2 Mon Sep 17 00:00:00 2001
803fb7
From: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
803fb7
Date: Wed, 24 Jun 2015 12:01:26 +0900
803fb7
Subject: [PATCH] selinux: fix missing SELinux unit access check
803fb7
803fb7
Currently, SELinux unit access check is not performed if a given unit
803fb7
file has not been registered in a hash table. This is because function
803fb7
manager_get_unit() only tries to pick up a Unit object from a Unit
803fb7
hash table. Instead, we use function manager_load_unit() searching
803fb7
Unit file pathes for the given Unit file.
803fb7
803fb7
Cherry-picked from: 4938696301a914ec26bcfc60bb99a1e9624e378
803fb7
Resolves: #1185120
803fb7
---
803fb7
 src/core/selinux-access.c | 12 ++++++------
803fb7
 1 file changed, 6 insertions(+), 6 deletions(-)
803fb7
803fb7
diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c
803fb7
index 91460b8af..f11247c09 100644
803fb7
--- a/src/core/selinux-access.c
803fb7
+++ b/src/core/selinux-access.c
803fb7
@@ -272,12 +272,12 @@ int mac_selinux_unit_access_check_strv(char **units,
803fb7
         int r;
803fb7
 
803fb7
         STRV_FOREACH(i, units) {
803fb7
-                u = manager_get_unit(m, *i);
803fb7
-                if (u) {
803fb7
-                        r = mac_selinux_unit_access_check(u, message, permission, error);
803fb7
-                        if (r < 0)
803fb7
-                                return r;
803fb7
-                }
803fb7
+                r = manager_load_unit(m, *i, NULL, error, &u);
803fb7
+                if (r < 0)
803fb7
+                        return r;
803fb7
+                r = mac_selinux_unit_access_check(u, message, permission, error);
803fb7
+                if (r < 0)
803fb7
+                        return r;
803fb7
         }
803fb7
 #endif
803fb7
         return 0;