Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CISOfy/lynis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormboelen <michael@cisofy.com>2016-03-16 14:10:10 +0300
committermboelen <michael@cisofy.com>2016-03-16 14:10:10 +0300
commit237c0f87a78a9b5730e640b57a871185c7704f61 (patch)
tree4d7eb6686c9620eabb99904d92403c58c1a4d170
parent488c08c3f3e7975b5fc1a81dc91c45e32dc50c64 (diff)
BOOT-5104: Rewrote test to detect service manager
-rw-r--r--include/tests_boot_services49
1 files changed, 22 insertions, 27 deletions
diff --git a/include/tests_boot_services b/include/tests_boot_services
index a14a522c..d4d4494f 100644
--- a/include/tests_boot_services
+++ b/include/tests_boot_services
@@ -70,34 +70,28 @@
case ${OS} in
"Linux")
if [ -f /proc/1/cmdline ]; then
- FILE=`awk '/^\// { print $1 }' /proc/1/cmdline`
- if [ ! "${FILE}" = "" ]; then
- if [ -L ${FILE} ]; then
- ShowSymlinkPath ${FILE}
- if [ -f ${sFILE} ]; then
- SHORTNAME=`echo ${sFILE} | awk -F/ '{ print $NF }'`
- case ${SHORTNAME} in
- upstart)
- SERVICE_MANAGER="upstart"
- ;;
- systemd)
- SERVICE_MANAGER="systemd"
- ;;
- *)
- LogText "Found ${SHORTNAME} but unclear what service manager this is"
- ;;
- esac
- else
- LogText "Result: Could not find linked file ${sFILE}"
- fi
- else
- FIND=`echo ${FILE} | grep "/systemd"`
- if [ ! "${FIND}" = "" ]; then
+ FIND=`awk '/^\// { print $1 }' /proc/1/cmdline`
+ if [ ! "${FIND}" = "" ]; then
+ SHORTNAME=`echo ${FIND} | awk -F/ '{ print $NF }'`
+ LogText "Found: ${SHORTNAME}"
+ case ${SHORTNAME} in
+ "init")
+ SERVICE_MANAGER="SysV Init"
+ ;;
+ systemd)
SERVICE_MANAGER="systemd"
- fi
- fi
+ ;;
+ upstart)
+ SERVICE_MANAGER="upstart"
+ ;;
+ *)
+ LogText "Found ${SHORTNAME}. Unclear what service manager this is"
+ ReportException "${TEST_NO}:001" "Unknown service manager"
+ ;;
+ esac
else
- LogText "Result: /proc/1/cmdline does not link to a binary on disk"
+ LogText "Result: /proc/1/cmdline seems to be empty"
+ ReportException "${TEST_NO}:002" "No data found in /proc/1/cmdline"
fi
fi
# Continue testing if we didn't find it yet
@@ -113,7 +107,8 @@
*)
LogText "Result: unknown service manager"
esac
- if [ "${SERVICE_MANAGER}" = "unknown" ]; then
+ LogText "Result: service manager found = ${SERVICE_MANAGER}"
+ if [ "${SERVICE_MANAGER}" = "" -o "${SERVICE_MANAGER}" = "unknown" ]; then
Display --indent 2 --text "- Service Manager" --result "UNKNOWN" --color YELLOW
else
Display --indent 2 --text "- Service Manager" --result "${SERVICE_MANAGER}" --color GREEN