e17b848
diff -up cronie-1.4.3/src/security.c.old cronie-1.4.3/src/security.c
e17b848
--- cronie-1.4.3/src/security.c.old	2009-09-25 08:23:18.000000000 +0200
e17b848
+++ cronie-1.4.3/src/security.c	2009-11-05 16:43:13.000000000 +0100
e17b848
@@ -486,9 +486,37 @@ void free_security_context(security_cont
e17b848
 
e17b848
 int crontab_security_access(void) {
e17b848
 #ifdef WITH_SELINUX
e17b848
-	if (is_selinux_enabled() > 0)
e17b848
-		if (selinux_check_passwd_access(PASSWD__CRONTAB) != 0)
e17b848
-			return -1;
e17b848
+	int selinux_check_passwd_access = -1;
e17b848
+	if (is_selinux_enabled() > 0) {
e17b848
+		security_context_t user_context;
e17b848
+		if (getprevcon_raw(&user_context) == 0) {
e17b848
+			security_class_t passwd_class;
e17b848
+			struct av_decision avd;
e17b848
+			int retval;
e17b848
+
e17b848
+			passwd_class = string_to_security_class("passwd");
e17b848
+			if (passwd_class == 0) {
e17b848
+				selinux_check_passwd_access = -1;
e17b848
+				fprintf(stderr, "Security class \"passwd\" is not defined in the SELinux policy.\n");
e17b848
+			}
e17b848
+
e17b848
+			retval = security_compute_av_raw(user_context,
e17b848
+							user_context,
e17b848
+							passwd_class,
e17b848
+							PASSWD__CRONTAB,
e17b848
+							&avd);
e17b848
+
e17b848
+			if ((retval == 0) && ((PASSWD__CRONTAB & avd.allowed) == PASSWD__CRONTAB)) {
e17b848
+				selinux_check_passwd_access = 0;
e17b848
+			}
e17b848
+			freecon(user_context);
e17b848
+		}
e17b848
+
e17b848
+		if (selinux_check_passwd_access != 0 && security_getenforce() == 0)
e17b848
+			selinux_check_passwd_access = 0;
e17b848
+
e17b848
+		return selinux_check_passwd_access;
e17b848
+	}
e17b848
 #endif
e17b848
 	return 0;
e17b848
 }