|
|
c587ab |
diff -up cronie-1.4.11/src/security.c.selinux-user cronie-1.4.11/src/security.c
|
|
|
c587ab |
--- cronie-1.4.11/src/security.c.selinux-user 2017-03-07 13:52:23.076462218 +0100
|
|
|
c587ab |
+++ cronie-1.4.11/src/security.c 2017-03-07 14:47:32.957371610 +0100
|
|
|
c587ab |
@@ -41,8 +41,6 @@
|
|
|
c587ab |
#ifdef WITH_SELINUX
|
|
|
c587ab |
# include <selinux/selinux.h>
|
|
|
c587ab |
# include <selinux/context.h>
|
|
|
c587ab |
-# include <selinux/flask.h>
|
|
|
c587ab |
-# include <selinux/av_permissions.h>
|
|
|
c587ab |
# include <selinux/get_context_list.h>
|
|
|
c587ab |
#endif
|
|
|
c587ab |
|
|
|
c587ab |
@@ -476,7 +474,9 @@ get_security_context(const char *name, i
|
|
|
c587ab |
security_context_t scontext = NULL;
|
|
|
c587ab |
security_context_t file_context = NULL;
|
|
|
c587ab |
security_context_t rawcontext=NULL;
|
|
|
c587ab |
- int retval = 0;
|
|
|
c587ab |
+ context_t current_context = NULL;
|
|
|
c587ab |
+ int retval;
|
|
|
c587ab |
+ char *current_context_str = NULL;
|
|
|
c587ab |
char *seuser = NULL;
|
|
|
c587ab |
char *level = NULL;
|
|
|
c587ab |
|
|
|
c587ab |
@@ -490,10 +490,29 @@ get_security_context(const char *name, i
|
|
|
c587ab |
log_it(name, getpid(), "getseuserbyname FAILED", name, 0);
|
|
|
c587ab |
return (security_getenforce() > 0);
|
|
|
c587ab |
}
|
|
|
c587ab |
+
|
|
|
c587ab |
+ retval = get_default_context_with_level(seuser, level, NULL, &scontext);
|
|
|
c587ab |
+ }
|
|
|
c587ab |
+ else {
|
|
|
c587ab |
+ if (getcon(¤t_context_str) < 0) {
|
|
|
c587ab |
+ log_it(name, getpid(), "getcon FAILED", "", 0);
|
|
|
c587ab |
+ return (security_getenforce() > 0);
|
|
|
c587ab |
+ }
|
|
|
c587ab |
+
|
|
|
c587ab |
+ current_context = context_new(current_context_str);
|
|
|
c587ab |
+ if (current_context == NULL) {
|
|
|
c587ab |
+ log_it(name, getpid(), "context_new FAILED", current_context_str, 0);
|
|
|
c587ab |
+ freecon(current_context_str);
|
|
|
c587ab |
+ return (security_getenforce() > 0);
|
|
|
c587ab |
+ }
|
|
|
c587ab |
+
|
|
|
c587ab |
+ const char *current_user = context_user_get(current_context);
|
|
|
c587ab |
+ retval = get_default_context_with_level(current_user, level, NULL, &scontext);
|
|
|
c587ab |
+
|
|
|
c587ab |
+ freecon(current_context_str);
|
|
|
c587ab |
+ context_free(current_context);
|
|
|
c587ab |
}
|
|
|
c587ab |
|
|
|
c587ab |
- retval = get_default_context_with_level(name == NULL ? "system_u" : seuser,
|
|
|
c587ab |
- level, NULL, &scontext);
|
|
|
c587ab |
if (selinux_trans_to_raw_context(scontext, &rawcontext) == 0) {
|
|
|
c587ab |
freecon(scontext);
|
|
|
c587ab |
scontext = rawcontext;
|