mirror of https://github.com/CISOfy/lynis.git
Removed local variable assignment to prevent portability issues
This commit is contained in:
parent
a40331aedc
commit
dfce1a770a
|
@ -138,7 +138,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
CheckFilePermissions() {
|
CheckFilePermissions() {
|
||||||
local CHECKFILE=$1
|
CHECKFILE=$1
|
||||||
if [ ! -d ${CHECKFILE} -a ! -f ${CHECKFILE} ]; then
|
if [ ! -d ${CHECKFILE} -a ! -f ${CHECKFILE} ]; then
|
||||||
PERMS="FILE_NOT_FOUND"
|
PERMS="FILE_NOT_FOUND"
|
||||||
else
|
else
|
||||||
|
@ -166,7 +166,7 @@
|
||||||
|
|
||||||
CheckItem() {
|
CheckItem() {
|
||||||
ITEM_FOUND=0
|
ITEM_FOUND=0
|
||||||
local RETVAL=255
|
RETVAL=255
|
||||||
if [ $# -eq 2 ]; then
|
if [ $# -eq 2 ]; then
|
||||||
# Don't search in /dev/null, it's too empty there
|
# Don't search in /dev/null, it's too empty there
|
||||||
if [ ! "${REPORTFILE}" = "/dev/null" ]; then
|
if [ ! "${REPORTFILE}" = "/dev/null" ]; then
|
||||||
|
@ -233,9 +233,9 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ContainsString() {
|
ContainsString() {
|
||||||
local RETVAL=1
|
RETVAL=1
|
||||||
if [ $# -ne 2 ]; then ReportException "ContainsString" "Incorrect number of arguments for ContainsStrings function"; fi
|
if [ $# -ne 2 ]; then ReportException "ContainsString" "Incorrect number of arguments for ContainsStrings function"; fi
|
||||||
local FIND=`echo "$2" | egrep "$1"`
|
FIND=`echo "$2" | egrep "$1"`
|
||||||
if [ ! "${FIND}" = "" ]; then RETVAL=0; fi
|
if [ ! "${FIND}" = "" ]; then RETVAL=0; fi
|
||||||
return ${RETVAL}
|
return ${RETVAL}
|
||||||
}
|
}
|
||||||
|
@ -397,7 +397,7 @@
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! "${TEXT}" = "" ]; then
|
if [ ! "${TEXT}" = "" ]; then
|
||||||
local SHOW=0
|
SHOW=0
|
||||||
if [ ${SHOW_WARNINGS_ONLY} -eq 1 ]; then
|
if [ ${SHOW_WARNINGS_ONLY} -eq 1 ]; then
|
||||||
if [ "${RESULT}" = "WARNING" ]; then SHOW=1; fi
|
if [ "${RESULT}" = "WARNING" ]; then SHOW=1; fi
|
||||||
elif [ ${QUIET} -eq 0 ]; then SHOW=1
|
elif [ ${QUIET} -eq 0 ]; then SHOW=1
|
||||||
|
@ -938,7 +938,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
IsOwnedByRoot() {
|
IsOwnedByRoot() {
|
||||||
local PERMS=""
|
PERMS=""
|
||||||
if [ $# -eq 1 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
FILE="$1"
|
FILE="$1"
|
||||||
case $OS in
|
case $OS in
|
||||||
|
@ -1301,7 +1301,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
ParseTestValues() {
|
ParseTestValues() {
|
||||||
local RETVAL=1
|
RETVAL=1
|
||||||
FOUND=0
|
FOUND=0
|
||||||
CHECK_VALUES_ARRAY=""
|
CHECK_VALUES_ARRAY=""
|
||||||
if [ $# -gt 0 -a ! "${CHECK_OPTION_ARRAY}" = "" ]; then
|
if [ $# -gt 0 -a ! "${CHECK_OPTION_ARRAY}" = "" ]; then
|
||||||
|
@ -1557,13 +1557,13 @@
|
||||||
|
|
||||||
RandomString() {
|
RandomString() {
|
||||||
# Check a (pseudo) random character device
|
# Check a (pseudo) random character device
|
||||||
if [ -c /dev/urandom ]; then local FILE="/dev/urandom"
|
if [ -c /dev/urandom ]; then FILE="/dev/urandom"
|
||||||
elif [ -c /dev/random ]; then local FILE="/dev/random"
|
elif [ -c /dev/random ]; then FILE="/dev/random"
|
||||||
else
|
else
|
||||||
Display "Can not use RandomString function, as there is no random device to be used"
|
Display "Can not use RandomString function, as there is no random device to be used"
|
||||||
fi
|
fi
|
||||||
if [ $# -eq 0 ]; then local SIZE=16; else local SIZE=$1; fi
|
if [ $# -eq 0 ]; then SIZE=16; else SIZE=$1; fi
|
||||||
local CSIZE=$((SIZE / 2))
|
CSIZE=$((SIZE / 2))
|
||||||
RANDOMSTRING=`head -c ${CSIZE} /dev/urandom | od -An -x | tr -d ' ' | cut -c 1-${SIZE}`
|
RANDOMSTRING=`head -c ${CSIZE} /dev/urandom | od -An -x | tr -d ' ' | cut -c 1-${SIZE}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1766,13 +1766,13 @@
|
||||||
|
|
||||||
ReportDetails() {
|
ReportDetails() {
|
||||||
while [ $# -ge 1 ]; do
|
while [ $# -ge 1 ]; do
|
||||||
local TEST_DESCRIPTION=""
|
TEST_DESCRIPTION=""
|
||||||
local TEST_FIELD=""
|
TEST_FIELD=""
|
||||||
local TEST_ID=""
|
TEST_ID=""
|
||||||
local TEST_OTHER=""
|
TEST_OTHER=""
|
||||||
local TEST_PREFERRED_VALUE=""
|
TEST_PREFERRED_VALUE=""
|
||||||
local TEST_SERVICE=""
|
TEST_SERVICE=""
|
||||||
local TEST_VALUE=""
|
TEST_VALUE=""
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
--description)
|
--description)
|
||||||
|
@ -2234,9 +2234,9 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
SkipAtomicTest() {
|
SkipAtomicTest() {
|
||||||
local RETVAL=255
|
RETVAL=255
|
||||||
if [ $# -eq 1 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
local STRING=""
|
STRING=""
|
||||||
RETVAL=1
|
RETVAL=1
|
||||||
# Check if this test is on the list to skip
|
# Check if this test is on the list to skip
|
||||||
for I in ${SKIP_TESTS}; do
|
for I in ${SKIP_TESTS}; do
|
||||||
|
@ -2260,17 +2260,17 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
TestValue() {
|
TestValue() {
|
||||||
local RETVAL=255
|
RETVAL=255
|
||||||
local FIND=""
|
FIND=""
|
||||||
local VALUE=""
|
VALUE=""
|
||||||
local RESULT=""
|
RESULT=""
|
||||||
local SEARCH=""
|
SEARCH=""
|
||||||
local CMP1=""; local CMP2=""
|
CMP1=""; CMP2=""
|
||||||
while [ $# -ge 1 ]; do
|
while [ $# -ge 1 ]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
--function)
|
--function)
|
||||||
shift
|
shift
|
||||||
local FUNCTION=$1
|
FUNCTION=$1
|
||||||
;;
|
;;
|
||||||
--value)
|
--value)
|
||||||
shift
|
shift
|
||||||
|
@ -2362,7 +2362,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
TestCase_Equal() {
|
TestCase_Equal() {
|
||||||
local RETVAL=2
|
RETVAL=2
|
||||||
|
|
||||||
if [ "$#" -lt "2" ]; then
|
if [ "$#" -lt "2" ]; then
|
||||||
ReportException "${TEST_NO}" "Error in function call to ${FUNCNAME}"
|
ReportException "${TEST_NO}" "Error in function call to ${FUNCNAME}"
|
||||||
|
@ -2395,7 +2395,7 @@
|
||||||
# Returns : (0 - SUCCESS; 1 - FAIL)
|
# Returns : (0 - SUCCESS; 1 - FAIL)
|
||||||
################################################################################
|
################################################################################
|
||||||
TestCase_NotEqual() {
|
TestCase_NotEqual() {
|
||||||
local RETVAL=1
|
RETVAL=1
|
||||||
if [ "$#" -ne "2" ]; then
|
if [ "$#" -ne "2" ]; then
|
||||||
ReportException "${TEST_NO}" "Error in function call to ${FUNCNAME}"
|
ReportException "${TEST_NO}" "Error in function call to ${FUNCNAME}"
|
||||||
else
|
else
|
||||||
|
@ -2419,7 +2419,7 @@
|
||||||
# Returns : (0 - SUCCESS; 1 - FAIL)
|
# Returns : (0 - SUCCESS; 1 - FAIL)
|
||||||
################################################################################
|
################################################################################
|
||||||
TestCase_GreaterThan() {
|
TestCase_GreaterThan() {
|
||||||
local RETVAL=1
|
RETVAL=1
|
||||||
if [ "$#" -ne "2" ]; then
|
if [ "$#" -ne "2" ]; then
|
||||||
ReportException "${TEST_NO}" "Error in function call to ${FUNCNAME}"
|
ReportException "${TEST_NO}" "Error in function call to ${FUNCNAME}"
|
||||||
else
|
else
|
||||||
|
@ -2444,7 +2444,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
TestCase_GreaterOrEqual() {
|
TestCase_GreaterOrEqual() {
|
||||||
local RETVAL=1
|
RETVAL=1
|
||||||
if [ "$#" -ne "2" ]; then
|
if [ "$#" -ne "2" ]; then
|
||||||
ReportException "${TEST_NO}" "Error in function call to ${FUNCNAME}"
|
ReportException "${TEST_NO}" "Error in function call to ${FUNCNAME}"
|
||||||
else
|
else
|
||||||
|
@ -2466,7 +2466,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
TestCase_LessThan() {
|
TestCase_LessThan() {
|
||||||
local RETVAL=1
|
RETVAL=1
|
||||||
if [ "$#" -ne "2" ]; then
|
if [ "$#" -ne "2" ]; then
|
||||||
ReportException "${TEST_NO}" "Error in function call to TestCase_GreaterOrEqual"
|
ReportException "${TEST_NO}" "Error in function call to TestCase_GreaterOrEqual"
|
||||||
else
|
else
|
||||||
|
@ -2490,7 +2490,7 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
TestCase_LessOrEqual() {
|
TestCase_LessOrEqual() {
|
||||||
local RETVAL=1
|
RETVAL=1
|
||||||
if [ "$#" -ne "2" ]; then
|
if [ "$#" -ne "2" ]; then
|
||||||
ReportException "${TEST_NO}" "Error in function call to ${FUNCNAME}"
|
ReportException "${TEST_NO}" "Error in function call to ${FUNCNAME}"
|
||||||
else
|
else
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
case ${PAM_CONTROL_FLAG} in
|
case ${PAM_CONTROL_FLAG} in
|
||||||
"optional"|"required"|"requisite"|"sufficient")
|
"optional"|"required"|"requisite"|"sufficient")
|
||||||
#Debug "Found a common control flag: ${PAM_CONTROL_FLAG} for ${PAM_MODULE}"
|
#Debug "Found a common control flag: ${PAM_CONTROL_FLAG} for ${PAM_MODULE}"
|
||||||
local X=0 # do nothing
|
X=0 # do nothing
|
||||||
;;
|
;;
|
||||||
"other")
|
"other")
|
||||||
LogText "Result: brackets used, ignoring control flags"
|
LogText "Result: brackets used, ignoring control flags"
|
||||||
|
|
Loading…
Reference in New Issue