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:
authorchr0mag <phillips.julian@gmail.com>2019-03-07 12:10:21 +0300
committerMichael Boelen <michael.boelen@cisofy.com>2019-03-07 12:10:21 +0300
commite33ca1ec58ff64376c8bed968b92f2f30dfee153 (patch)
tree994cae72268e1efe9bc7b9b6af15c2dfe3d38ba2 /include/tests_boot_services
parent341612418f004be954b08689b3b640305045c8b1 (diff)
[BOOT 5177] Simplify service filter & support multiple periods in names (#633)
* Handle service names with multiple periods The current awk filter produces truncated output if the service name contains multiple periods. eg. dbus-org.freedesktop.resolve1.service and dbus-org.freedesktop.network1.service both appear as 'dbus-org' in the resulting service list. This change addresses this by filtering on '.service' instead. * Simplify systemd service filtering Added systemctl switches to filter the output based on enabled or running services. This removes the need for one of the awk statements.
Diffstat (limited to 'include/tests_boot_services')
-rw-r--r--include/tests_boot_services4
1 files changed, 2 insertions, 2 deletions
diff --git a/include/tests_boot_services b/include/tests_boot_services
index 2de8d748..77d3cb47 100644
--- a/include/tests_boot_services
+++ b/include/tests_boot_services
@@ -564,7 +564,7 @@
LogText "Result: systemctl binary found, trying that to discover information"
# Running services
LogText "Searching for running services (systemctl services only)"
- FIND=$(${SYSTEMCTLBINARY} --full --type=service | ${AWKBINARY} '{ if ($4=="running") { print $1 } }' | ${AWKBINARY} -F. '{ print $1 }')
+ FIND=$(${SYSTEMCTLBINARY} --no-legend --full --type=service --state=running | ${AWKBINARY} -F.service '{ print $1 }')
COUNT=0
Report "running_service_tool=systemctl"
for ITEM in ${FIND}; do
@@ -579,7 +579,7 @@
# Services at boot
LogText "Searching for enabled services (systemctl services only)"
- FIND=$(${SYSTEMCTLBINARY} list-unit-files --type=service | ${SORTBINARY} -u | ${AWKBINARY} '{ if ($2=="enabled") { print $1 } }' | ${AWKBINARY} -F. '{ print $1 }')
+ FIND=$(${SYSTEMCTLBINARY} list-unit-files --no-legend --type=service --state=enabled | ${SORTBINARY} -u | ${AWKBINARY} -F.service '{ print $1 }')
COUNT=0
Report "boot_service_tool=systemctl"
for ITEM in ${FIND}; do