mirror of https://github.com/CISOfy/lynis.git
The IsRunning function may have not everything defined early on, so added a fallback
This commit is contained in:
parent
2c4ed62ef6
commit
156f740ff2
|
@ -1546,7 +1546,7 @@
|
||||||
if [ -z "${search}" ]; then ExitFatal "Missing process to search for when using IsRunning function"; fi
|
if [ -z "${search}" ]; then ExitFatal "Missing process to search for when using IsRunning function"; fi
|
||||||
RUNNING=0
|
RUNNING=0
|
||||||
# AIX does not fully support pgrep options, so using ps instead
|
# AIX does not fully support pgrep options, so using ps instead
|
||||||
if [ -n "${PGREPBINARY}" ] && [ "${OS}" != "AIX" ]; then
|
if [ "${OS}" != "AIX" ]; then
|
||||||
# When --user is used, perform a search using the -u option
|
# When --user is used, perform a search using the -u option
|
||||||
# Initialize users for strict mode
|
# Initialize users for strict mode
|
||||||
if [ -n "${users:-}" ]; then
|
if [ -n "${users:-}" ]; then
|
||||||
|
@ -1556,33 +1556,33 @@
|
||||||
if [ -n "${user_uid}" ]; then
|
if [ -n "${user_uid}" ]; then
|
||||||
if [ -z "${FIND}" ]; then
|
if [ -z "${FIND}" ]; then
|
||||||
LogText "Performing pgrep scan using uid ${user_uid}"
|
LogText "Performing pgrep scan using uid ${user_uid}"
|
||||||
FIND=$(${PGREPBINARY} ${pgrep_options} -u "${user_uid}" "${search}" | ${TRBINARY} '\n' ' ')
|
FIND=$(${PGREPBINARY:-pgrep} ${pgrep_options} -u "${user_uid}" "${search}" | ${TRBINARY:-tr} '\n' ' ')
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
LogText "Performing pgrep scan without uid"
|
LogText "Performing pgrep scan without uid"
|
||||||
FIND=$(${PGREPBINARY} ${pgrep_options} "${search}" | ${TRBINARY} '\n' ' ')
|
FIND=$(${PGREPBINARY:-pgrep} ${pgrep_options} "${search}" | ${TRBINARY} '\n' ' ')
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "${SHELL_IS_BUSYBOX}" -eq 1 ]; then
|
if [ "${SHELL_IS_BUSYBOX}" -eq 1 ]; then
|
||||||
# This search is not foolproof
|
# This search is not foolproof
|
||||||
LogText "Performing simple ps scan (busybox)"
|
LogText "Performing simple ps scan (busybox)"
|
||||||
PSOPTIONS=" -o args="
|
PSOPTIONS=" -o args="
|
||||||
FIND=$(${PSBINARY} ${PSOPTIONS} | ${EGREPBINARY} "( |/)${search}" | ${GREPBINARY} -v "grep")
|
FIND=$(${PSBINARY:-ps} ${PSOPTIONS} | ${EGREPBINARY:-egrep} "( |/)${search}" | ${GREPBINARY:-grep} -v "grep")
|
||||||
else
|
else
|
||||||
if [ -n "${users}" ]; then
|
if [ -n "${users}" ]; then
|
||||||
for u in ${users}; do
|
for u in ${users}; do
|
||||||
user_uid=$(getent passwd "${u}" 2> /dev/null | ${AWKBINARY} -F: '{print $3}')
|
user_uid=$(getent passwd "${u}" 2> /dev/null | ${AWKBINARY:-awk} -F: '{print $3}')
|
||||||
# Only perform search if user exists and we had no match yet
|
# Only perform search if user exists and we had no match yet
|
||||||
if [ -n "${user_uid}" ]; then
|
if [ -n "${user_uid}" ]; then
|
||||||
if [ -z "${FIND}" ]; then
|
if [ -z "${FIND}" ]; then
|
||||||
if [ ${PARTIAL_SEARCH} -eq 1 ]; then
|
if [ ${PARTIAL_SEARCH} -eq 1 ]; then
|
||||||
LogText "Performing ps scan using partial match and for uid ${user_uid}"
|
LogText "Performing ps scan using partial match and for uid ${user_uid}"
|
||||||
FIND=$(${PSBINARY} -u "${user_uid}" -o comm= "${search}" | ${AWKBINARY} -v pattern="${search}" '$0 ~ pattern {print}')
|
FIND=$(${PSBINARY:-ps} -u "${user_uid}" -o comm= "${search}" | ${AWKBINARY:-awk} -v pattern="${search}" '$0 ~ pattern {print}')
|
||||||
else
|
else
|
||||||
LogText "Performing ps scan using exact match and for uid ${user_uid}"
|
LogText "Performing ps scan using exact match and for uid ${user_uid}"
|
||||||
FIND=$(${PSBINARY} -u "${user_uid}" -o comm= "${search}" | ${AWKBINARY} -v pattern="^${search}$" '$0 ~ pattern {print}')
|
FIND=$(${PSBINARY:-ps} -u "${user_uid}" -o comm= "${search}" | ${AWKBINARY:-awk} -v pattern="^${search}$" '$0 ~ pattern {print}')
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -1595,10 +1595,10 @@
|
||||||
esac
|
esac
|
||||||
if [ ${PARTIAL_SEARCH} -eq 1 ]; then
|
if [ ${PARTIAL_SEARCH} -eq 1 ]; then
|
||||||
LogText "Performing ps scan using partial match and without uid"
|
LogText "Performing ps scan using partial match and without uid"
|
||||||
FIND=$(${PSBINARY} ${PSOPTIONS} | ${AWKBINARY} -v pattern="${search}" '$0 ~ pattern {print}')
|
FIND=$(${PSBINARY:-ps} ${PSOPTIONS} | ${AWKBINARY:-awk} -v pattern="${search}" '$0 ~ pattern {print}')
|
||||||
else
|
else
|
||||||
LogText "Performing ps scan using exact match and without uid"
|
LogText "Performing ps scan using exact match and without uid"
|
||||||
FIND=$(${PSBINARY} ${PSOPTIONS} | ${AWKBINARY} -v pattern="^${search}$" '$0 ~ pattern {print}')
|
FIND=$(${PSBINARY:-ps} ${PSOPTIONS} | ${AWKBINARY:-awk} -v pattern="^${search}$" '$0 ~ pattern {print}')
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue