]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(selinux): shellcheck for modules.d/98selinux
authorHarald Hoyer <harald@redhat.com>
Fri, 26 Mar 2021 09:29:33 +0000 (10:29 +0100)
committerHarald Hoyer <harald@hoyer.xyz>
Mon, 29 Mar 2021 09:19:47 +0000 (11:19 +0200)
modules.d/98selinux/.shchkdir [new file with mode: 0644]
modules.d/98selinux/selinux-loadpolicy.sh

diff --git a/modules.d/98selinux/.shchkdir b/modules.d/98selinux/.shchkdir
new file mode 100644 (file)
index 0000000..e69de29
index 06640200f0f0dc5062d043e51ff77b795ab9f348..0235b8ed45ea9668d561131a8a767097e69ac09e 100755 (executable)
@@ -7,12 +7,13 @@ rd_load_policy() {
     getarg "selinux=0" > /dev/null && return 0
 
     SELINUX="enforcing"
+    # shellcheck disable=SC1090
     [ -e "$NEWROOT/etc/selinux/config" ] && . "$NEWROOT/etc/selinux/config"
 
     # Check whether SELinux is in permissive mode
     permissive=0
-    getarg "enforcing=0" > /dev/null
-    if [ $? -eq 0 -o "$SELINUX" = "permissive" ]; then
+
+    if getarg "enforcing=0" > /dev/null || [ "$SELINUX" = "permissive" ]; then
         permissive=1
     fi
 
@@ -21,20 +22,20 @@ rd_load_policy() {
         local ret=0
         local out
         info "Loading SELinux policy"
-        mount -o bind /sys $NEWROOT/sys
+        mount -o bind /sys "$NEWROOT"/sys
         # load_policy does mount /proc and /sys/fs/selinux in
         # libselinux,selinux_init_load_policy()
         if [ -x "$NEWROOT/sbin/load_policy" ]; then
             out=$(LANG=C chroot "$NEWROOT" /sbin/load_policy -i 2>&1)
             ret=$?
-            info $out
+            info "$out"
         else
             out=$(LANG=C chroot "$NEWROOT" /usr/sbin/load_policy -i 2>&1)
             ret=$?
-            info $out
+            info "$out"
         fi
-        umount $NEWROOT/sys/fs/selinux
-        umount $NEWROOT/sys
+        umount "$NEWROOT"/sys/fs/selinux
+        umount "$NEWROOT"/sys
 
         if [ "$SELINUX" = "disabled" ]; then
             return 0