CISOfy / lynis

Lynis - Security auditing tool for Linux, macOS, and UNIX-based systems. Assists with compliance testing (HIPAA/ISO27001/PCI DSS) and system hardening. Agentless, and installation optional.
https://cisofy.com/lynis/
GNU General Public License v3.0
13.5k stars 1.49k forks source link

unary operator expected in tests_filesystems #1546

Closed gemal closed 1 month ago

gemal commented 1 month ago

Describe the bug I run this as a cronjob: lynis audit system --cronjob --warnings-only this morning I got: /usr/share/lynis/include/tests_filesystems: line 742: [: -eq: unary operator expected

I logged in a reran the command but was unable to reproduce from command line

Version

Expected behavior A clear and concise description of what you expected to happen.

Output If applicable, add output that you get from the tool or the related section of lynis.log

Additional context lynis audit system --cronjob --warnings-only

mboelen commented 1 month ago

Try running it with --debug and/or --verbose to see if it happens again.

Might be something related to the cron environment.

gemal commented 1 month ago

yes I can reproduce running it as cron but not from command line

gemal commented 1 month ago

when running in cron these are the lines from --debug --verbose that I see

[DEBUG] Performing test ID FILE-6394 (Determine level of swappiness.)
[DEBUG] Performing test ID FILE-6398 (Checking if JBD (Journal Block Device) driver is loaded)
/usr/share/lynis/include/tests_filesystems: line 742: [: -eq: unary operator expected
[DEBUG] Performing test ID FILE-6410 (Checking Locate database)
[DEBUG] Performing test ID FILE-6430 (Disable mounting of some filesystems)

How can I provide more info?

mboelen commented 1 month ago

Thanks, that was all information needed. Looks like a related test was not performed that determines the type of the Linux kernel (monolithic or modular). Commit https://github.com/CISOfy/lynis/commit/699ec384d248d4f64e1ce7f2daa1027be9557954 adds a test to see if we determined the kernel type.

Do you have the option to test it on your system to see if this truly fixes it?

gemal commented 1 month ago

Unfortunately I cant test it but it looks like it will fix it

mboelen commented 1 month ago

Then let's consider it resolved for now and close this issue. If in 3.1.3 the issue remains, just let it know.