Skip to contentSkip to conversation

policycoreutils/load_policy: Drop is_selinux_enabled() check

PATCH Applied Luis Ressel 2 participants 2 messages Apr 7, 2017 – Apr 11, 2017 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 policycoreutils/load_policy: Drop is_selinux_enabled() check

This check is a remnant of the libselinux <2.5 era, back when is_selinux_enabled() checked whether a policy had been loaded. Nowadays it only checks whether selinuxfs is mounted, and "load_policy -i" therefore incorrectly refuses operation when selinuxfs is mounted, but no policy has been loaded yet.

While it doesn't make much sense to call selinux_init_load_policy() twice, there's no harm in doing so either, so let's just drop this safeguard instead of fixing it.

---
 policycoreutils/load_policy/load_policy.c | 7 -------
 1 file changed, 7 deletions(-)
policycoreutils/load_policy/load_policy.c +0 -7
index 7c2c2a7..2707d6f 100644
@@ -65,13 +65,6 @@ int main(int argc, char **argv)
 			argv[0], argv[optind++]);
 	}
 	if (init) {
-		if (is_selinux_enabled() == 1) {
-			/* SELinux is already enabled, we should not do an initial load again */
-			fprintf(stderr,
-					_("%s:  Policy is already loaded and initial load requested\n"),
-					argv[0]);
-			exit(2);
-		}
 		ret = selinux_init_load_policy(&enforce);
 		if (ret != 0 ) {
 			if (enforce > 0) {
Signature · 1 line
2.12.2
#1 lore raw
Quoted 11 lines · Luis Ressel

This check is a remnant of the libselinux <2.5 era, back when is_selinux_enabled() checked whether a policy had been loaded. Nowadays
it only checks whether selinuxfs is mounted, and "load_policy -i" therefore incorrectly refuses operation when selinuxfs is mounted, but
no policy has been loaded yet.

While it doesn't make much sense to call selinux_init_load_policy() twice, there's no harm in doing so either, so let's just drop this safeguard instead of fixing it.

Thanks, applied.

Quoted 25 lines

---
 policycoreutils/load_policy/load_policy.c | 7 -------

 1 file changed, 7 deletions(-)
policycoreutils/load_policy/load_policy.c +0 -2
index 7c2c2a7..2707d6f 100644
@@ -65,13 +65,6 @@ int main(int argc, char **argv)
  			argv[0], argv[optind++]);
  	}
  	if (init) {
-		if (is_selinux_enabled() == 1) {
-			/* SELinux is already enabled, we should not

do an initial load again */

policycoreutils/load_policy/load_policy.c +0 -2
-			fprintf(stderr,
-					_("%s:  Policy is already

loaded and initial load requested\n"),

policycoreutils/load_policy/load_policy.c +0 -3
-					argv[0]);
-			exit(2);
-		}

  ret = selinux_init_load_policy(&enforce); if (ret != 0 ) {
  if (enforce > 0) {