From 3867e20c91cd3e0a781c338379e680f61ca11e99 Mon Sep 17 00:00:00 2001
From: CaretakerMushroom <252717426+CaretakerMushroom@users.noreply.github.com>
Date: Tue, 27 Jan 2026 16:43:57 +0100
Subject: [PATCH] Add fixes for Gentoo Linux

---
 include/osdetection     |  2 +-
 include/tests_firewalls | 10 +++++++++-
 include/tests_kernel    |  4 ++--
 3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/include/osdetection b/include/osdetection
index 9386c8f77..9ac9c10a0 100644
--- a/include/osdetection
+++ b/include/osdetection
@@ -153,7 +153,7 @@
             # Generic
             if [ -e /etc/os-release ]; then
                 OS_FULLNAME=$(awk -F= '/^PRETTY_NAME=/ {print substr($2,2,length($2)-2)}' /etc/os-release)
-                OS_ID=$(grep "^ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
+                OS_ID=$(grep "^ID=" /etc/os-release | awk -F= '{print $2}' | tr -d "'\"" )
                 if [ -n "${OS_ID}" ]; then
                     case ${OS_ID} in
                         "almalinux")
diff --git a/include/tests_firewalls b/include/tests_firewalls
index 56f981a62..456a98e64 100644
--- a/include/tests_firewalls
+++ b/include/tests_firewalls
@@ -514,7 +514,15 @@
             NFTABLES_ACTIVE=1
             Report "firewall_software[]=nftables"
         else
-            LogText "Result: no nftables kernel module found"
+            FIND=$(${GREPBINARY} -ioP "(?<=/)nf*_tables(?=\.ko)" "/lib/modules/$(uname -r)/modules.builtin");
+            if [ -n "${FIND}" ]; then
+                LogText "Result: found nftables kernel module"
+                FIREWALL_ACTIVE=1
+                NFTABLES_ACTIVE=1
+                Report "firewall_software[]=nftables"
+            else
+                LogText "Result: no nftables kernel module found"
+            fi
         fi
     fi
 #
diff --git a/include/tests_kernel b/include/tests_kernel
index 7fac8b591..7eebf28da 100644
--- a/include/tests_kernel
+++ b/include/tests_kernel
@@ -748,7 +748,7 @@
                     # Extra current kernel version and replace dashes to allow numeric ${SORTBINARY} later on
                     MYKERNEL=$(${UNAMEBINARY} -r | ${SEDBINARY} 's/\.[a-z].*.//g' | ${SEDBINARY} 's/-[a-z].*.//g' | ${SEDBINARY} 's/-/./g')
                     LogText "Result: using ${MYKERNEL} as my kernel version (stripped)"
-                    FIND=$(ls ${ROOTDIR}boot/vmlinuz* 2> /dev/null)
+                    FIND=$(${FINDBINARY} /boot/ /boot/EFI/Gentoo/ -maxdepth 1 -name "vmlinuz*")
                     if [ -n "${FIND}" ]; then
                         for ITEM in ${FIND}; do
                             LogText "Result: found ${ITEM}"
@@ -757,7 +757,7 @@
                         # Ignore rescue images. Remove generic. and huge. for Slackware machines
                         # TODO: see if this can be simplified using ls -v sorting
                         LogText "Action: checking relevant kernels"
-                        KERNELS=$(${LSBINARY} /boot/vmlinuz* | ${GREPBINARY} -v rescue | ${SEDBINARY} 's/vmlinuz-//' | ${SEDBINARY} 's/generic.//' | ${SEDBINARY} 's/huge.//' | ${SEDBINARY} 's/\.[a-z].*.//g' | ${SEDBINARY} 's/-[a-z].*.//g' | ${SEDBINARY} 's./boot/..' | ${SEDBINARY} 's/-/./g' | ${SORTBINARY} -n -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 -k6,6 -t \.)
+                        KERNELS=$(${FINDBINARY} /boot/ /boot/EFI/Gentoo/ -maxdepth 1 -name "vmlinuz*" | ${GREPBINARY} -v rescue | ${SEDBINARY} 's/vmlinuz-//' | ${SEDBINARY} 's/generic.//' | ${SEDBINARY} 's/huge.//' | ${SEDBINARY} 's/\.[a-z].*.//g' | ${SEDBINARY} 's/-[a-z].*.//g' | ${SEDBINARY} 's./boot/..' | ${SEDBINARY} 's.EFI/Gentoo/..' | ${SEDBINARY} 's/-/./g' | ${SORTBINARY} -n -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 -k6,6 -t \.)
                         KERNELS_ONE_LINE=$(${ECHOCMD} ${KERNELS} | ${TRBINARY} '\n' ' ')
                         LogText "Output: ${KERNELS_ONE_LINE}"
                     elif [ ! "$(ls ${ROOTDIR}boot/kernel* 2> /dev/null)" = "" ]; then
