Define default plugin directory after profiles have been parsed

This commit is contained in:
mboelen 2016-04-13 12:09:26 +02:00
parent 13f1373944
commit d3f33a32cd

72
lynis
View File

@ -210,31 +210,6 @@ Make sure to execute ${PROGRAM_NAME} from untarred directory or check your insta
# #
################################################################################# #################################################################################
# #
# Plugins
#
#################################################################################
#
# Plugin directory test
if [ "${PLUGINDIR}" = "" ]; then
#logtext "Result: Searching for plugindir"
tPLUGIN_TARGETS="/usr/local/lynis/plugins /usr/local/share/lynis/plugins /usr/share/lynis/plugins /etc/lynis/plugins ./plugins"
for I in ${tPLUGIN_TARGETS}; do
if [ -d ${I} ]; then
PLUGINDIR=${I}
Debug "Result: found plugindir ${PLUGINDIR}"
fi
done
fi
# Drop out if our plugin directory can't be found
if [ ! -d ${PLUGINDIR} ]; then
echo "Fatal error: can't find plugin directory ${PLUGINDIR}"
echo "Make sure to execute ${PROGRAM_NAME} from untarred directory or check your installation."
exit 1
fi
#
#################################################################################
#
# Program information # Program information
# #
################################################################################# #################################################################################
@ -530,6 +505,42 @@ ${NORMAL}
# #
################################################################################# #################################################################################
# #
# Read profile/template/plugins
#
#################################################################################
#
SafePerms ${INCLUDEDIR}/profiles
. ${INCLUDEDIR}/profiles
#
#################################################################################
#
# Plugins
#
#################################################################################
#
# Plugin directory test
if [ "${PLUGINDIR}" = "" ]; then
#logtext "Result: Searching for plugindir"
tPLUGIN_TARGETS="/usr/local/lynis/plugins /usr/local/share/lynis/plugins /usr/share/lynis/plugins /etc/lynis/plugins ./plugins"
for I in ${tPLUGIN_TARGETS}; do
if [ -d ${I} ]; then
PLUGINDIR=${I}
Debug "Result: found plugindir ${PLUGINDIR}"
fi
done
else
Debug "Plugin was already set before to ${PLUGINDIR} (most likely via program argument or profile)"
fi
# Drop out if our plugin directory can't be found
if [ ! -d ${PLUGINDIR} ]; then
echo "Fatal error: can't find plugin directory ${PLUGINDIR}"
echo "Make sure to execute ${PROGRAM_NAME} from untarred directory or check your installation."
exit 1
fi
#
#################################################################################
#
# Show program information to display # Show program information to display
# #
################################################################################# #################################################################################
@ -577,19 +588,12 @@ ${NORMAL}
logtext "-----------------------------------------------------" logtext "-----------------------------------------------------"
logtext "BusyBox used: ${SHELL_IS_BUSYBOX}" logtext "BusyBox used: ${SHELL_IS_BUSYBOX}"
report "plugin_directory=${PLUGINDIR}"
logtextbreak logtextbreak
# #
################################################################################# #################################################################################
# #
# Read profile/template/plugins
#
#################################################################################
#
SafePerms ${INCLUDEDIR}/profiles
. ${INCLUDEDIR}/profiles
#
#################################################################################
#
# Check for program update (and friendly force people to upgrade) # Check for program update (and friendly force people to upgrade)
# #
################################################################################# #################################################################################