Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BOOT-5180 Determine runlevel and services at startup, Ubuntu Bionic 18.04 #1238

Open
mbtreetime opened this issue Nov 22, 2021 · 0 comments
Open

Comments

@mbtreetime
Copy link

Describe the bug
Ubuntu 18.04 is using systemd for controlling services.

On a default AWS EC2 instance the runlevel command returns 'N 5' which causes the BOOT-5180 test to fail

Version

Expected behavior
It's unclear if I should just disable this test, or if it should still function correctly at 'runlevel 5'

Additional context
I'm not sure when I started seeing this message, I'm running Lynis on Ubuntu 18.04 I run the audit system from a cronjob and then grep the lynis-report.dat for suggestion entries.

Performing test ID BOOT-5180 (Check for Linux boot services (Debian style))

suggestion[]=BOOT-5180|Determine runlevel and services at startup|-|-|

The code is different now, but the result is similar. The runlevel returns 'N 5' which results in the "Determine runlevel and services at startup" message.

--- tests_boot_services.orig	2021-04-05 13:07:46.697907005 -0600
+++ tests_boot_services	2021-04-05 13:26:55.320215347 -0600
@@ -724,7 +724,7 @@
         # Runlevel check
         sRUNLEVEL=$(${RUNLEVELBINARY} | ${GREPBINARY} "N [0-9]" | ${AWKBINARY} '{ print $2} ')
         LogText "Result: found runlevel ${sRUNLEVEL}"
-        if [ "${sRUNLEVEL}" = "2" ]; then
+        if [ "${sRUNLEVEL}" = "2" ] || [ "${sRUNLEVEL}" = "5" ]; then
             LogText "Result: performing find in /etc/rc2.d as runlevel 2 is found"
             FIND=$(${FINDBINARY} ${ROOTDIR}etc/rc2.d -type l -print | ${CUTBINARY} -d '/' -f4 | ${SEDBINARY} "s/S[0-9][0-9]//g" | sort)
             if [ -n "${FIND}" ]; then

or:

--- tests_boot_services.orig	2021-04-05 13:07:46.697907005 -0600
+++ tests_boot_services	2021-04-05 13:07:25.322033166 -0600
@@ -724,16 +724,16 @@
         # Runlevel check
         sRUNLEVEL=$(${RUNLEVELBINARY} | ${GREPBINARY} "N [0-9]" | ${AWKBINARY} '{ print $2} ')
         LogText "Result: found runlevel ${sRUNLEVEL}"
-        if [ "${sRUNLEVEL}" = "2" ]; then
-            LogText "Result: performing find in /etc/rc2.d as runlevel 2 is found"
-            FIND=$(${FINDBINARY} ${ROOTDIR}etc/rc2.d -type l -print | ${CUTBINARY} -d '/' -f4 | ${SEDBINARY} "s/S[0-9][0-9]//g" | sort)
+        if [ "${sRUNLEVEL}" = "2" ] || [ "${sRUNLEVEL}" = "5" ]; then
+            LogText "Result: performing find in /etc/rc${sRUNLEVEL}.d as runlevel ${sRUNLEVEL} is found"
+            FIND=$(${FINDBINARY} ${ROOTDIR}etc/rc${sRUNLEVEL}.d -type l -print | ${CUTBINARY} -d '/' -f4 | ${SEDBINARY} "s/S[0-9][0-9]//g" | sort)
             if [ -n "${FIND}" ]; then
                 COUNT=0
                 for SERVICE in ${FIND}; do
-                    LogText "Found service (at boot, runlevel 2): ${SERVICE}"
+                    LogText "Found service (at boot, runlevel ${sRUNLEVEL}): ${SERVICE}"
                     COUNT=$((COUNT + 1))
                 done
-                Display --indent 2 --text "- Check services at startup (rc2.d)" --result "${STATUS_DONE}" --color WHITE
+                Display --indent 2 --text "- Check services at startup (rc${sRUNLEVEL}.d)" --result "${STATUS_DONE}" --color WHITE
                 Display --indent 4 --text "Result: found ${COUNT} services"
                 LogText "Result: found ${COUNT} services"
             fi

Originally posted by @arcticlinux in #61 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant