fix: Correct SELinux boolean parsing and add loop break

- Fixed incorrect parsing of `container_use_devices` boolean by changing the awk field from `$2` to `$3` to retrieve the correct value.
- Added a `break` statement after enabling the SELinux boolean to prevent unnecessary loop iterations after user prompt.

Signed-off-by: Alessandro Pirastru <alessandro.pirastru.94@gmail.com>
This commit is contained in:
Alessandro Pirastru 2025-04-26 16:21:52 +02:00
parent a0ebb55b3f
commit eef553f3be

View file

@ -317,7 +317,7 @@ enable_selinux_container_booleans() {
if [ "$SELINUX_MODE" == "Enforcing" ]; then if [ "$SELINUX_MODE" == "Enforcing" ]; then
# Check the status of container_use_devices # Check the status of container_use_devices
CONTAINER_USE_DEVICES=$(getsebool container_use_devices | awk '{print $2}') CONTAINER_USE_DEVICES=$(getsebool container_use_devices | awk '{print $3}')
if [ "$CONTAINER_USE_DEVICES" == "off" ]; then if [ "$CONTAINER_USE_DEVICES" == "off" ]; then
@ -339,6 +339,8 @@ enable_selinux_container_booleans() {
if [ "$Answer" = "yes" ]; then if [ "$Answer" = "yes" ]; then
warn "Enabling \"container_use_devices\" persistently..." warn "Enabling \"container_use_devices\" persistently..."
$SUDO setsebool -P container_use_devices 1 $SUDO setsebool -P container_use_devices 1
break
elif [ "$Answer" = "exit" ]; then elif [ "$Answer" = "exit" ]; then
aborted aborted
else else