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

Exception found! [KRNL-5730] _ReportException_ should have _GREPTOOL_ passed in and not _GREPBINARY_ #1484

Open
fullofentropy opened this issue Apr 15, 2024 · 1 comment

Comments

@fullofentropy
Copy link

Describe the bug
Function/test: [KRNL-5730] produces an exception.
Error message from exception is incorrect: Message: No valid /bin/grep tool found to search kernel settings

A valid /bin/grep tool does exist on the system. When looking at the source searching "KRNL-5730" the following flow is done incorrectly:

  • @ line 269 LINUXCONFIGFILE_ZIPPED does eq to 1 (in my case) and sets GREPTOOL to ZGREPBINARY but when the ReportException is called @ line 282 it passes in GREPBINARY. It should pass in GREPTOOL.
#
    # Test        : KRNL-5730
    # Description : Checking default I/O kernel scheduler
    # Notes       : This test could be extended with testing some of the specific devices like disks
    #               cat /sys/block/sda/queue/scheduler
    PREQS_MET="NO"
    if HasData "${LINUXCONFIGFILE}"; then
        if [ -f ${LINUXCONFIGFILE} ]; then PREQS_MET="YES"; fi
    fi
    Register --test-no KRNL-5730 --os Linux --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Checking disk I/O kernel scheduler"
    if [ ${SKIPTEST} -eq 0 ]; then
        if [ ${LINUXCONFIGFILE_ZIPPED} -eq 1 ]; then GREPTOOL="${ZGREPBINARY}"; else GREPTOOL="${GREPBINARY}"; fi
        if [ -n "${GREPTOOL}" ]; then
            LogText "Test: Checking the default I/O kernel scheduler"
            LINUX_KERNEL_IOSCHED=$(${GREPTOOL} "CONFIG_DEFAULT_IOSCHED" ${LINUXCONFIGFILE} | ${AWKBINARY} -F= '{ print $2 }' | ${SEDBINARY} s/\"//g)
            if [ -n "${LINUX_KERNEL_IOSCHED}" ]; then
                LogText "Result: found IO scheduler '${LINUX_KERNEL_IOSCHED}'"
                Display --indent 2 --text "- Checking default I/O kernel scheduler" --result "${STATUS_FOUND}" --color GREEN
                Report "linux_kernel_io_scheduler[]=${LINUX_KERNEL_IOSCHED}"
            else
                LogText "Result: no default I/O kernel scheduler found"
                Display --indent 2 --text "- Checking default I/O kernel scheduler" --result "${STATUS_NOT_FOUND}" --color WHITE
            fi
        else
            ReportException "${TEST_NO}" "No valid ${GREPBINARY} tool found to search kernel settings"
        fi
   fi
#

Version

  • Distribution; Buildroot 2021.02.12; Linux BSP: 3.47
  • Lynis version Lynis 3.0.9

Expected behavior
No exception expected, error should be properly handled.

Output
If applicable, add output that you get from the tool or the related section of lynis.log
18:26:05 [+] Kernel
18:26:05 ------------------------------------
18:26:05 - Checking default run level [ 3 ]
18:26:05 - Checking kernel version and release [ DONE ]
18:26:06 - Checking kernel type [ DONE ]
18:26:06 - Checking loaded kernel modules [ DONE ]
18:26:06 - Checking Linux kernel configuration file [ FOUND ]
18:26:06
18:26:06 =================================================================
18:26:06
18:26:06 Exception found!
18:26:06
18:26:06 Function/test: [KRNL-5730]
18:26:06 Message: No valid /bin/grep tool found to search kernel settings
18:26:06

Additional context

@mboelen
Copy link
Member

mboelen commented May 15, 2024

Thanks for reporting.

So in your case:

  • LINUXCONFIGFILE_ZIPPED = 1
  • GREPTOOL is set

Is that correct?

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

No branches or pull requests

2 participants