diff --git a/libselinux/src/load_policy.c b/libselinux/src/load_policy.c index e419f1ad..21ee58b2 100644 --- a/libselinux/src/load_policy.c +++ b/libselinux/src/load_policy.c @@ -417,13 +417,15 @@ int selinux_init_load_policy(int *enforce) /* Successfully disabled, so umount selinuxfs too. */ umount(selinux_mnt); fini_selinuxmnt(); + goto noload; + } else { + /* + * It's possible that this failed because policy has + * already been loaded. We can't disable SELinux now, + * so the best we can do is force it to be permissive. + */ + *enforce = 0; } - /* - * If we failed to disable, SELinux will still be - * effectively permissive, because no policy is loaded. - * No need to call security_setenforce(0) here. - */ - goto noload; } /* @@ -442,6 +444,9 @@ int selinux_init_load_policy(int *enforce) } } + if (seconfig == -1) + goto noload; + /* Load the policy. */ return selinux_mkload_policy(0);