diff mbox series

[2/2] policycoreutils/fixfiles: Force full relabel when SELinux is disabled

Message ID 20190924190854.245105-2-plautrba@redhat.com (mailing list archive)
State Accepted
Headers show
Series [1/2] policycoreutils/fixfiles: Fix [-B] [-F] onboot | expand

Commit Message

Petr Lautrbach Sept. 24, 2019, 7:08 p.m. UTC
The previous check used getfilecon to check whether / slash contains a label,
but getfilecon fails only when SELinux is disabled. Therefore it's better to
check this using selinuxenabled.

Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
---
 policycoreutils/scripts/fixfiles | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stephen Smalley Sept. 26, 2019, 12:54 p.m. UTC | #1
On 9/24/19 3:08 PM, Petr Lautrbach wrote:
> The previous check used getfilecon to check whether / slash contains a label,
> but getfilecon fails only when SELinux is disabled. Therefore it's better to
> check this using selinuxenabled.

Thanks, applied both patches.

> 
> Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
> ---
>   policycoreutils/scripts/fixfiles | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/policycoreutils/scripts/fixfiles b/policycoreutils/scripts/fixfiles
> index 678fca40..ab0848ff 100755
> --- a/policycoreutils/scripts/fixfiles
> +++ b/policycoreutils/scripts/fixfiles
> @@ -313,8 +313,8 @@ case "$1" in
>   	> /.autorelabel || exit $?
>   	[ -z "$FORCEFLAG" ] || echo -n "$FORCEFLAG " >> /.autorelabel
>   	[ -z "$BOOTTIME" ] || echo -N $BOOTTIME >> /.autorelabel
> -	# Force full relabel if / does not have a label on it
> -	getfilecon / > /dev/null 2>&1  || echo -F >/.autorelabel
> +	# Force full relabel if SELinux is not enabled
> +	selinuxenabled || echo -F > /.autorelabel
>   	echo "System will relabel on next boot"
>   	;;
>       *)
>
diff mbox series

Patch

diff --git a/policycoreutils/scripts/fixfiles b/policycoreutils/scripts/fixfiles
index 678fca40..ab0848ff 100755
--- a/policycoreutils/scripts/fixfiles
+++ b/policycoreutils/scripts/fixfiles
@@ -313,8 +313,8 @@  case "$1" in
 	> /.autorelabel || exit $?
 	[ -z "$FORCEFLAG" ] || echo -n "$FORCEFLAG " >> /.autorelabel
 	[ -z "$BOOTTIME" ] || echo -N $BOOTTIME >> /.autorelabel
-	# Force full relabel if / does not have a label on it
-	getfilecon / > /dev/null 2>&1  || echo -F >/.autorelabel
+	# Force full relabel if SELinux is not enabled
+	selinuxenabled || echo -F > /.autorelabel
 	echo "System will relabel on next boot"
 	;;
     *)