mirror of https://github.com/CISOfy/lynis.git
Merge pull request #1016 from Jimver/fix_nginx_parser
ParseNginx(): Fix wildcard expansion, absolute path handling and output to stderr
This commit is contained in:
commit
3294e1a9bd
|
@ -2179,7 +2179,8 @@
|
|||
for I in ${FIND}; do
|
||||
I=$(echo ${I} | sed 's/:space:/ /g' | sed 's/;$//' | sed 's/ #.*$//')
|
||||
OPTION=$(echo ${I} | awk '{ print $1 }')
|
||||
VALUE=$(echo ${I}| cut -d' ' -f2-)
|
||||
# Use quotes here to prevent wildcard expansion
|
||||
VALUE=$(echo "${I}"| cut -d' ' -f2-)
|
||||
LogText "Result: found option ${OPTION} in ${CONFIG_FILE} with value '${VALUE}'"
|
||||
STORE_SETTING=1
|
||||
case ${OPTION} in
|
||||
|
@ -2302,10 +2303,25 @@
|
|||
done
|
||||
if [ ${FOUND} -eq 0 ]; then NGINX_CONF_FILES_ADDITIONS="${NGINX_CONF_FILES_ADDITIONS} ${VALUE}"; fi
|
||||
# Check for additional config files included as follows
|
||||
# "include sites-enabled/*.conf"
|
||||
elif [ $(echo ${VALUE} | grep -F -c "*.conf") -gt 0 ]; then
|
||||
if [ "$(echo ${VALUE} | ${CUTBINARY} -c1)" != "/" ]; then VALUE=${CONFIG_FILE%nginx.conf}; fi
|
||||
for FOUND_CONF in $(ls ${VALUE%;*} 2> /dev/null); do
|
||||
# "include sites-enabled/*.conf" (relative path)
|
||||
# "include /etc/nginx/sites-enabled/*.conf" (absolute path)
|
||||
elif [ $(echo "${VALUE}" | grep -F -c "*.conf") -gt 0 ]; then
|
||||
# Check if path is absolute or relative
|
||||
case $VALUE in
|
||||
/*)
|
||||
# Absolute path, so wildcard pattern is already correct
|
||||
CONF_WILDCARD=${VALUE%;*}
|
||||
;;
|
||||
*)
|
||||
# Relative path, so construct absolute path for wildcard pattern
|
||||
CONF_WILDCARD=${CONFIG_FILE%nginx.conf}${VALUE%;*}
|
||||
;;
|
||||
esac
|
||||
for FOUND_CONF in ${CONF_WILDCARD}; do
|
||||
if [ "${FOUND_CONF}" = "${CONF_WILDCARD}" ]; then
|
||||
LogText "Found no match for wildcard pattern: ${CONF_WILDCARD}"
|
||||
break
|
||||
fi
|
||||
FOUND=0
|
||||
for CONF in ${NGINX_CONF_FILES}; do
|
||||
if [ "${CONF}" = "${FOUND_CONF}" ]; then FOUND=1; LogText "Found this file already in our configuration files array, not adding to queue"; fi
|
||||
|
|
Loading…
Reference in New Issue