Skip to content

Commit 4ae604f

Browse files
committed
lynis: add package
Lynis is a security auditing tool for Unix/Linux systems. It performs an in-depth security scan to detect software and security issues, installed packages, and configuration errors. This commit includes pending PRs which provide basic support for OpenWrt version 23.05 --> SNAPSHOT thanks to issue 1600[1] which includes five pending PRs[2-6]. 1. CISOfy/lynis#1600 2. CISOfy/lynis#1601 3. CISOfy/lynis#1602 4. CISOfy/lynis#1620 5. CISOfy/lynis#1621 6. CISOfy/lynis#1748 Build system: x86/64 Build-tested: x86/64-glibc Run-tested: x86/64-glibc Signed-off-by: John Audia <therealgraysky@proton.me>
1 parent 3979576 commit 4ae604f

12 files changed

Lines changed: 565 additions & 0 deletions

admin/lynis/Makefile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
include $(TOPDIR)/rules.mk
2+
3+
PKG_NAME:=lynis
4+
PKG_VERSION:=3.1.6
5+
PKG_RELEASE:=1
6+
7+
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
8+
PKG_SOURCE_URL:=https://downloads.cisofy.com/lynis/
9+
PKG_HASH:=0513f62ba5ab615c4333827b804237d58cf7bd623d09e1b4918d3fc85f08fc70
10+
11+
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
12+
13+
PKG_MAINTAINER:=John Audia <therealgraysky@proton.me>
14+
PKG_LICENSE:=GPL-3.0-only
15+
PKG_LICENSE_FILES:=LICENSE
16+
17+
include $(INCLUDE_DIR)/package.mk
18+
19+
define Package/lynis
20+
SECTION:=admin
21+
CATEGORY:=Administration
22+
TITLE:=Security and system auditing tool
23+
URL:=https://cisofy.com/lynis/
24+
PKGARCH:=all
25+
DEPENDS:=+bind-dig +file +net-tools-netstat +net-tools-route
26+
endef
27+
28+
define Package/lynis/description
29+
Lynis is a security auditing tool for Unix/Linux systems. It performs
30+
an in-depth security scan to detect software and security issues,
31+
installed packages, and possible configuration errors.
32+
endef
33+
34+
define Package/lynis/conffiles
35+
/etc/lynis/default.prf
36+
endef
37+
38+
define Build/Configure
39+
endef
40+
41+
define Build/Compile
42+
endef
43+
44+
define Package/lynis/install
45+
$(INSTALL_DIR) $(1)/usr/bin
46+
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lynis $(1)/usr/bin/lynis
47+
48+
$(INSTALL_DIR) $(1)/etc/lynis
49+
$(INSTALL_DATA) $(PKG_BUILD_DIR)/default.prf $(1)/etc/lynis/default.prf
50+
51+
$(INSTALL_DIR) $(1)/usr/share/lynis
52+
$(CP) $(PKG_BUILD_DIR)/db $(1)/usr/share/lynis/
53+
$(CP) $(PKG_BUILD_DIR)/include $(1)/usr/share/lynis/
54+
$(CP) $(PKG_BUILD_DIR)/plugins $(1)/usr/share/lynis/
55+
endef
56+
57+
$(eval $(call BuildPackage,lynis))
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
From dc26caa98a7c77e9f1b5b2f02bdeba5174d98167 Mon Sep 17 00:00:00 2001
2+
From: macie <macie@users.noreply.github.com>
3+
Date: Sat, 8 Feb 2025 12:35:41 +0100
4+
Subject: [PATCH 1/9] feat: Detect OpenWrt OS
5+
6+
HARDWARE value is a name of compilation target
7+
(SoC type). This will simplify selection of proper installer
8+
version for OS upgrade.
9+
---
10+
include/osdetection | 6 ++++++
11+
1 file changed, 6 insertions(+)
12+
13+
--- a/include/osdetection
14+
+++ b/include/osdetection
15+
@@ -434,6 +434,12 @@
16+
OS_VERSION=$(grep "^VERSION_ID=" /etc/os-release | awk -F= '{print $2}' | tr -d '"')
17+
OS_NAME="openSUSE"
18+
;;
19+
+ "openwrt")
20+
+ LINUX_VERSION='OpenWrt'
21+
+ HARDWARE=$(grep '^OPENWRT_BOARD=' /etc/os-release | awk -F= '{print $2}' | tr -d '"')
22+
+ OS_NAME=$(grep '^NAME=' /etc/os-release | awk -F= '{print $2}' | tr -d '"')
23+
+ OS_VERSION=$(grep '^VERSION=' /etc/os-release | awk -F= '{print $2}' | tr -d '"')
24+
+ ;;
25+
"osmc")
26+
LINUX_VERSION="OSMC"
27+
LINUX_VERSION_LIKE="Debian"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
From 44b1c4da3162e2573e1329feec65b7d3480239a8 Mon Sep 17 00:00:00 2001
2+
From: macie <macie@users.noreply.github.com>
3+
Date: Sat, 8 Feb 2025 13:00:17 +0100
4+
Subject: [PATCH 2/9] feat: Add EOL dates for OpenWrt
5+
6+
Historically, updates were released up to the end of the month, see:
7+
<https://en.wikipedia.org/wiki/OpenWrt#Releases>.
8+
---
9+
db/software-eol.db | 11 +++++++++++
10+
1 file changed, 11 insertions(+)
11+
12+
--- a/db/software-eol.db
13+
+++ b/db/software-eol.db
14+
@@ -283,6 +283,17 @@ os:OpenBSD 7.4:2024-10-08:1728338400:
15+
os:OpenBSD 7.5:2025-05-31:1748642400:
16+
os:OpenBSD 7.6:2025-10-31:1761865200:
17+
#
18+
+# OpenWrt - https://openwrt.org/docs/guide-developer/security#support_status
19+
+#
20+
+os:OpenWrt 15.05:2016-03-31:1459375200:
21+
+os:OpenWrt 17.01:2018-09-30:1538258400:
22+
+os:OpenWrt 18.06:2020-12-31:1609369200:
23+
+os:OpenWrt 19.07:2022-04-30:1651269600:
24+
+os:OpenWrt 21.02:2023-05-31:1685484000:
25+
+os:OpenWrt 22.03:2024-07-31:1722376800:
26+
+os:OpenWrt 23.05:2025-07-31:1753912800:
27+
+os:OpenWrt 24.10:2026-02-28:1772233200:
28+
+#
29+
# Red Hat Enterprise Linux - https://access.redhat.com/labs/plcc/
30+
#
31+
os:Red Hat Enterprise Linux Server release 6:2020-11-30:1606690800:
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
From 5ff39b5ffba427c75394b7c7b7f5fcd0b3fb13d2 Mon Sep 17 00:00:00 2001
2+
From: macie <macie@users.noreply.github.com>
3+
Date: Sat, 8 Feb 2025 17:16:37 +0100
4+
Subject: [PATCH 3/9] refactor: Specify linux HOSTNAME detection
5+
6+
This is the first step to fix error on OpenWrt without changing current
7+
behavior.
8+
---
9+
lynis | 25 +++++++++++++++----------
10+
1 file changed, 15 insertions(+), 10 deletions(-)
11+
12+
--- a/lynis
13+
+++ b/lynis
14+
@@ -514,22 +514,27 @@ ${NORMAL}
15+
. ${INCLUDEDIR}/osdetection
16+
Display --indent 2 --text "- Detecting OS... " --result "${STATUS_DONE}" --color GREEN
17+
18+
- # Check hostname and get timestamp
19+
+ # Detect hostname and domain
20+
+ FQDN=$(hostname 2> /dev/null)
21+
case ${OS} in
22+
HP-UX)
23+
- HOSTNAME=$(hostname) ;;
24+
+ HOSTNAME=$(hostname) ;;
25+
+ Linux)
26+
+ HOSTNAME=$(hostname -s 2> /dev/null)
27+
+ if [ -z "${HOSTNAME}" ]; then
28+
+ HOSTNAME="${FQDN:-no-hostname}"
29+
+ fi
30+
+ if [ "${HOSTNAME}" = "${FQDN}" ]; then
31+
+ FQDN=$(hostname -f 2> /dev/null)
32+
+ fi
33+
+ ;;
34+
Solaris)
35+
- HOSTNAME=$(uname -n) ;;
36+
+ HOSTNAME=$(uname -n) ;;
37+
*)
38+
- HOSTNAME=$(hostname -s 2> /dev/null) ;;
39+
+ HOSTNAME=$(hostname -s 2> /dev/null) ;;
40+
esac
41+
if [ -z "${HOSTNAME}" ]; then
42+
- HOSTNAME=$(hostname 2> /dev/null)
43+
- if [ -z "${HOSTNAME}" ]; then HOSTNAME="no-hostname"; fi
44+
- fi
45+
- FQDN=$(hostname 2> /dev/null)
46+
- if [ "${OS}" = "Linux" -a "${HOSTNAME}" = "${FQDN}" ]; then
47+
- FQDN=$(hostname -f 2> /dev/null)
48+
+ HOSTNAME="${FQDN:-no-hostname}"
49+
fi
50+
#
51+
#################################################################################
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
From dcbd67cb795758bf1c2becbe8281970953b63ec3 Mon Sep 17 00:00:00 2001
2+
From: macie <macie@users.noreply.github.com>
3+
Date: Sat, 8 Feb 2025 16:32:38 +0100
4+
Subject: [PATCH 4/9] fix: Detect HOSTNAME on OpenWrt
5+
6+
OpenWrt can be run on devices with little resource, so it can miss some BusyBox
7+
commands (eg. hostname). The standard way of gathering info about OpenWrt is by
8+
the `uci` command, see: <https://openwrt.org/docs/guide-user/base-system/uci>.
9+
---
10+
lynis | 17 +++++++++++------
11+
1 file changed, 11 insertions(+), 6 deletions(-)
12+
13+
--- a/lynis
14+
+++ b/lynis
15+
@@ -520,12 +520,17 @@ ${NORMAL}
16+
HP-UX)
17+
HOSTNAME=$(hostname) ;;
18+
Linux)
19+
- HOSTNAME=$(hostname -s 2> /dev/null)
20+
- if [ -z "${HOSTNAME}" ]; then
21+
- HOSTNAME="${FQDN:-no-hostname}"
22+
- fi
23+
- if [ "${HOSTNAME}" = "${FQDN}" ]; then
24+
- FQDN=$(hostname -f 2> /dev/null)
25+
+ if [ "${LINUX_VERSION}" = "OpenWrt" ]; then
26+
+ HOSTNAME=$(uname -n)
27+
+ FQDN="${HOSTNAME:+$HOSTNAME.}$(uci -q get dhcp.@dnsmasq[0].domain)"
28+
+ else
29+
+ HOSTNAME=$(hostname -s 2> /dev/null)
30+
+ if [ -z "${HOSTNAME}" ]; then
31+
+ HOSTNAME="${FQDN:-no-hostname}"
32+
+ fi
33+
+ if [ "${HOSTNAME}" = "${FQDN}" ]; then
34+
+ FQDN=$(hostname -f 2> /dev/null)
35+
+ fi
36+
fi
37+
;;
38+
Solaris)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From 7a410ee5fd4323c6f6db116c3060ff6ffc5a53fd Mon Sep 17 00:00:00 2001
2+
From: macie <macie@users.noreply.github.com>
3+
Date: Sat, 8 Feb 2025 16:38:52 +0100
4+
Subject: [PATCH 5/9] fix: False positive NETW-2400 on OpenWrt
5+
6+
To save resources, BusyBox for OpenWrt is compiled without support for
7+
character classes in `tr` command (FEATURE_TR_CLASSES). In that case `tr`
8+
treats `[:alnum:]` like a group of single characters, so it misses all numbers
9+
and most of letters.
10+
---
11+
include/tests_networking | 3 ++-
12+
1 file changed, 2 insertions(+), 1 deletion(-)
13+
14+
--- a/include/tests_networking
15+
+++ b/include/tests_networking
16+
@@ -69,7 +69,8 @@
17+
LogText "Result: hostnamed is defined and not longer than 63 characters"
18+
fi
19+
# Test valid characters (normally a dot should not be in the name, but we can't be 100% sure we have short name)
20+
- FIND=$(echo "${HOSTNAME}" | ${TRBINARY} -d '[:alnum:]\.\-')
21+
+ # (we are NOT using [:alnum:] to support BusyBox's tr on devices with limited resources)
22+
+ FIND=$(echo "${HOSTNAME}" | ${TRBINARY} -d '[a-zA-Z0-9]\.\-')
23+
if [ -z "${FIND}" ]; then
24+
LogText "Result: good, no unexpected characters discovered in hostname"
25+
if IsVerbose; then Display --indent 2 --text "- Hostname (allowed characters)" --result "${STATUS_OK}" --color GREEN; fi
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
From 1ac0704e57fd351d3fa6ae75c515af5e93eaa09c Mon Sep 17 00:00:00 2001
2+
From: macie <macie@users.noreply.github.com>
3+
Date: Sun, 23 Mar 2025 20:32:52 +0100
4+
Subject: [PATCH 6/9] refactor: Indent with spaces
5+
6+
Most of the file has spaces for indentation.
7+
---
8+
include/tests_boot_services | 4 ++--
9+
1 file changed, 2 insertions(+), 2 deletions(-)
10+
11+
--- a/include/tests_boot_services
12+
+++ b/include/tests_boot_services
13+
@@ -111,7 +111,7 @@
14+
runit)
15+
SERVICE_MANAGER="runit"
16+
;;
17+
- openrc-init)
18+
+ openrc-init)
19+
SERVICE_MANAGER="openrc"
20+
;;
21+
*)
22+
@@ -280,7 +280,7 @@
23+
BOOT_LOADER_SEARCHED=1
24+
CURRENT_BOOT_LOADER=$(${BOOTCTLBINARY} status --no-pager 2>/dev/null | ${AWKBINARY} '/Current Boot Loader/{ getline; print $2 }')
25+
if [ "${CURRENT_BOOT_LOADER}" = "systemd-boot" ]; then
26+
- Display --indent 2 --text "- Checking systemd-boot presence" --result "${STATUS_FOUND}" --color GREEN
27+
+ Display --indent 2 --text "- Checking systemd-boot presence" --result "${STATUS_FOUND}" --color GREEN
28+
LogText "Result: found systemd-boot"
29+
BOOT_LOADER="systemd-boot"
30+
BOOT_LOADER_FOUND=1
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
From 2e0f28695e97908d4c7928f7348b812583ef9488 Mon Sep 17 00:00:00 2001
2+
From: macie <macie@users.noreply.github.com>
3+
Date: Sun, 23 Mar 2025 20:39:16 +0100
4+
Subject: [PATCH 7/9] fix: Define service manager for OpenWrt
5+
6+
OpenWrt uses `procd` as a service manager (see: <https://openwrt.org/docs/techref/procd>).
7+
8+
This fixes exception "Unknown service manager" returned by BOOT-5104 test.
9+
---
10+
include/tests_boot_services | 4 ++++
11+
1 file changed, 4 insertions(+)
12+
13+
--- a/include/tests_boot_services
14+
+++ b/include/tests_boot_services
15+
@@ -65,6 +65,7 @@
16+
# runit - Used by Artix, Devuan, Dragora and Void
17+
# systemd - Common option with more Linux distros implementing it
18+
# upstart - Used by Debian/Ubuntu
19+
+ # procd - Used by OpenWrt
20+
Register --test-no BOOT-5104 --weight L --network NO --category security --description "Determine service manager"
21+
if [ ${SKIPTEST} -eq 0 ]; then
22+
BOOT_LOADER_SEARCHED=1
23+
@@ -114,6 +115,9 @@
24+
openrc-init)
25+
SERVICE_MANAGER="openrc"
26+
;;
27+
+ procd)
28+
+ SERVICE_MANAGER="procd"
29+
+ ;;
30+
*)
31+
CONTAINS_SYSTEMD=$(echo ${SHORTNAME} | ${GREPBINARY} "systemd")
32+
if [ -n "${CONTAINS_SYSTEMD}" ]; then
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
From 9f25b293a639be7b9f92cb41b4a0fa50e2678a58 Mon Sep 17 00:00:00 2001
2+
From: macie <macie@users.noreply.github.com>
3+
Date: Sun, 23 Mar 2025 21:38:41 +0100
4+
Subject: [PATCH 8/9] refactor: Use IsRunning instead of `ps | grep`
5+
6+
Command `ps ax | grep '<WORD1>|<WORD2>' | grep -v 'grep'` can be directly
7+
transformed to `IsRunning '<WORD1>' || IsRunning '<WORD2>'`.
8+
9+
`IsRunning` supports BusyBox `ps` (without `-ax` option, see: <https://github.com/mirror/busybox/blob/master/procps/ps.c>).
10+
---
11+
include/tests_databases | 6 ++----
12+
include/tests_logging | 3 +--
13+
include/tests_squid | 3 +--
14+
include/tests_storage_nfs | 3 +--
15+
include/tests_time | 3 +--
16+
5 files changed, 6 insertions(+), 12 deletions(-)
17+
18+
--- a/include/tests_databases
19+
+++ b/include/tests_databases
20+
@@ -44,8 +44,7 @@
21+
# Description : Check if MySQL is being used
22+
Register --test-no DBS-1804 --weight L --network NO --category security --description "Checking active MySQL process"
23+
if [ ${SKIPTEST} -eq 0 ]; then
24+
- FIND=$(${PSBINARY} ax | ${GREPBINARY} -E "mariadb|mysqld|mysqld_safe" | ${GREPBINARY} -v "grep")
25+
- if [ -z "${FIND}" ]; then
26+
+ if ! IsRunning 'mariadb' && ! IsRunning 'mysqld' && ! IsRunning 'mysqld_safe'; then
27+
if [ ${DEBUG} -eq 1 ]; then Display --indent 2 --text "- MySQL process status" --result "${STATUS_NOT_FOUND}" --color WHITE --debug; fi
28+
LogText "Result: MySQL process not active"
29+
else
30+
@@ -248,8 +247,7 @@
31+
# reco: recovery (optional)
32+
Register --test-no DBS-1840 --weight L --network NO --category security --description "Checking active Oracle processes"
33+
if [ ${SKIPTEST} -eq 0 ]; then
34+
- FIND=$(${PSBINARY} ax | ${GREPBINARY} -E "ora_pmon|ora_smon|tnslsnr" | ${GREPBINARY} -v "grep")
35+
- if [ -z "${FIND}" ]; then
36+
+ if ! IsRunning 'ora_pmon' && ! IsRunning 'ora_smon' && ! IsRunning 'tnslsnr'; then
37+
if [ ${DEBUG} -eq 1 ]; then Display --indent 2 --text "- Oracle processes status" --result "${STATUS_NOT_FOUND}" --color WHITE --debug; fi
38+
LogText "Result: Oracle process(es) not active"
39+
else
40+
--- a/include/tests_logging
41+
+++ b/include/tests_logging
42+
@@ -45,8 +45,7 @@
43+
Register --test-no LOGG-2130 --weight L --network NO --category security --description "Check for running syslog daemon"
44+
if [ ${SKIPTEST} -eq 0 ]; then
45+
LogText "Test: Searching for a logging daemon"
46+
- FIND=$(${PSBINARY} ax | ${GREPBINARY} -E "syslogd|syslog-ng|metalog|systemd-journal" | ${GREPBINARY} -v "grep")
47+
- if [ -z "${FIND}" ]; then
48+
+ if ! IsRunning 'syslogd' && ! IsRunning 'syslog-ng' && ! IsRunning 'metalog' && ! IsRunning 'systemd-journal'; then
49+
Display --indent 2 --text "- Checking for a running log daemon" --result "${STATUS_WARNING}" --color RED
50+
LogText "Result: Could not find a syslog daemon like syslog, syslog-ng, rsyslog, metalog, systemd-journal"
51+
ReportSuggestion "${TEST_NO}" "Check if any syslog daemon is running and correctly configured."
52+
--- a/include/tests_squid
53+
+++ b/include/tests_squid
54+
@@ -41,8 +41,7 @@
55+
LogText "Test: Searching for a Squid daemon"
56+
FOUND=0
57+
# Check running processes
58+
- FIND=$(${PSBINARY} ax | ${GREPBINARY} -E "(squid|squid3) " | ${GREPBINARY} -v "grep")
59+
- if [ -n "${FIND}" ]; then
60+
+ if IsRunning 'squid' || IsRunning 'squid3'; then
61+
SQUID_DAEMON_RUNNING=1
62+
LogText "Result: Squid daemon is running"
63+
Display --indent 2 --text "- Checking running Squid daemon" --result "${STATUS_FOUND}" --color GREEN
64+
--- a/include/tests_storage_nfs
65+
+++ b/include/tests_storage_nfs
66+
@@ -93,8 +93,7 @@
67+
Register --test-no STRG-1920 --weight L --network NO --category security --description "Checking NFS daemon"
68+
if [ ${SKIPTEST} -eq 0 ]; then
69+
LogText "Test: Checking running NFS daemon"
70+
- FIND=$(${PSBINARY} ax | ${GREPBINARY} "nfsd" | ${GREPBINARY} -v "grep")
71+
- if [ -z "${FIND}" ]; then
72+
+ if ! IsRunning 'nfsd'; then
73+
LogText "Output: NFS daemon is not running"
74+
Display --indent 2 --text "- Check running NFS daemon" --result "${STATUS_NOT_FOUND}" --color WHITE
75+
else
76+
--- a/include/tests_time
77+
+++ b/include/tests_time
78+
@@ -122,8 +122,7 @@
79+
fi
80+
81+
# Check timedate daemon (systemd)
82+
- FIND=$(${PSBINARY} ax | ${GREPBINARY} "systemd-timesyncd" | ${GREPBINARY} -v "grep")
83+
- if [ -n "${FIND}" ]; then
84+
+ if IsRunning 'systemd-timesyncd'; then
85+
FOUND=1; NTP_DAEMON_RUNNING=1; NTP_CONFIG_TYPE_DAEMON=1; NTP_DAEMON="systemd-timesyncd"
86+
Display --indent 2 --text "- NTP daemon found: systemd (timesyncd)" --result "${STATUS_FOUND}" --color GREEN
87+
LogText "Result: Found running systemd-timesyncd in process list"

0 commit comments

Comments
 (0)