Minor fixes for embedded Linux. (#406)

* Check if the "locale" binary is available before using it.

This is no functional change as it will still fall back to english
when the locale can't be determined. This fix gets rid of the
following error when running on systems without the locale binary:

./lynis: line 112: locale: command not found

Signed-off-by: Daniel Romell <daro@hms.se>

* tests_kernel: KRNL-5677: Fix invalid use of shell test.

This fixes an issue (syntax error) triggered on systems with no PAE or
NX extensions:

- Checking CPU support (NX/PAE)
/usr/libexec/lynis/include/tests_kernel: line 126: [: too many arguments
/usr/libexec/lynis/include/tests_kernel: line 132: [: too many arguments

No need to use [] when only looking at function return values.

Signed-off-by: Daniel Romell <daro@hms.se>
This commit is contained in:
Daniel Romell 2017-06-21 14:17:49 +02:00 committed by Michael Boelen
parent ac2c83870b
commit 5b12f17e3f
2 changed files with 5 additions and 3 deletions

View File

@ -123,13 +123,13 @@
Report "cpu_nx=1"
FOUND=1
else
if [ HasData "${FIND_PAE}" -a IsEmpty "${FIND_NX}" ]; then
if HasData "${FIND_PAE}" && IsEmpty "${FIND_NX}"; then
Report "cpu_pae=1"
LogText "Result: found PAE"
CPU_PAE=1
FOUND=1
else
if [ HasData "${FIND_NX}" -a IsEmpty "${FIND_PAE}" ]; then
if HasData "${FIND_NX}" && IsEmpty "${FIND_PAE}"; then
Report "cpu_nx=1"
LogText "Result: found No eXecute"
CPU_NX=1

4
lynis
View File

@ -109,7 +109,9 @@ Make sure to execute ${PROGRAM_NAME} from untarred directory or check your insta
fi
# Auto detection of language based on locale (first two characters). Set to English when nothing found.
LANGUAGE=$(locale | egrep "^LANG=" | cut -d= -f2 | cut -d_ -f1 | egrep "^[a-z]{2}$")
if [ -x "$(command -v locale)" ]; then
LANGUAGE=$(locale | egrep "^LANG=" | cut -d= -f2 | cut -d_ -f1 | egrep "^[a-z]{2}$")
fi
if [ -z "${LANGUAGE}" ]; then
#Debug "Result: no (valid) language found, setting to default language (en)"
LANGUAGE="en"