b372458
From 1f866530f5b3c49012c61b299f3c4e1dceff2a71 Mon Sep 17 00:00:00 2001
b372458
From: Tomas Mraz <tmraz@fedoraproject.org>
b372458
Date: Thu, 18 Oct 2018 14:25:58 +0200
b372458
Subject: [PATCH] Use the role from the crond context for system job contexts.
b372458
b372458
New SELinux policy added multiple roles for the system_u user on crond_t.
b372458
The default context returned from get_default_context_with_level() is now
b372458
unconfined_t instead of system_cronjob_t which is incorrect for system cron
b372458
jobs.
b372458
We use the role to limit the default context to system_cronjob_t.
b372458
---
b372458
 src/security.c | 6 ++++--
b372458
 1 file changed, 4 insertions(+), 2 deletions(-)
b372458
b372458
diff --git a/src/security.c b/src/security.c
b372458
index d1bdc7f..5213cf3 100644
b372458
--- a/src/security.c
b372458
+++ b/src/security.c
b372458
@@ -505,6 +505,7 @@ get_security_context(const char *name, int crontab_fd,
b372458
 		retval = get_default_context_with_level(seuser, level, NULL, &scontext);
b372458
 	}
b372458
 	else {
b372458
+		const char *current_user, *current_role;
b372458
 		if (getcon(&current_context_str) < 0) {
b372458
 			log_it(name, getpid(), "getcon FAILED", "", 0);
b372458
 			return (security_getenforce() > 0);
b372458
@@ -517,8 +518,9 @@ get_security_context(const char *name, int crontab_fd,
b372458
 			return (security_getenforce() > 0);
b372458
 		}
b372458
 
b372458
-		const char *current_user = context_user_get(current_context);
b372458
-		retval = get_default_context_with_level(current_user, level, NULL, &scontext);
b372458
+		current_user = context_user_get(current_context);
b372458
+		current_role = context_role_get(current_context);
b372458
+		retval = get_default_context_with_rolelevel(current_user, current_role, level, NULL, &scontext);
b372458
 
b372458
 		freecon(current_context_str);
b372458
 		context_free(current_context);
b372458
-- 
b372458
2.14.5
b372458