Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CISOfy/lynis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormboelen <michael@cisofy.com>2016-04-13 17:11:46 +0300
committermboelen <michael@cisofy.com>2016-04-13 17:11:46 +0300
commitc5de5e6a1b21c0fba008f7f3c40303463e6082a5 (patch)
tree514b8529ef34c86117a76645c7224124cf81ac86 /include/functions
parent9192f4bbb8b2cbfd08e345315cdb7030d6f1bf1f (diff)
Added ReportDetails to store values of atomic tests
Diffstat (limited to 'include/functions')
-rw-r--r--include/functions58
1 files changed, 54 insertions, 4 deletions
diff --git a/include/functions b/include/functions
index fbfacbd6..eac79dcb 100644
--- a/include/functions
+++ b/include/functions
@@ -58,6 +58,7 @@
# RemovePIDFile Remove PID file
# RemoveTempFiles Remove temporary files
# Report Add string of data to report file
+# ReportDetails Store details of tests which include smaller atomic tests in report
# ReportException Add an exception to the report file (for debugging purposes)
# ReportSuggestion Add a suggestion to report file
# ReportWarning Add a warning and priority to report file
@@ -611,13 +612,16 @@
OTHERPERMS="-"
fi
- # Also check if we are the actual owner of the file
- FILEOWNER=`ls -ln ${sFILE} | awk -F" " '{ print $3 }'`
+ # Also check if we are the actual owner of the file (use -d to get directory itself, if its a directory)
+ FILEOWNER=`ls -dln ${sFILE} | awk -F" " '{ print $3 }'`
if [ "${FILEOWNER}" = "${MYID}" ]; then
LogText "Result: file is owned by our current user ID (${MYID}), checking if it is readable"
- if [ -d ${sFILE} ]; then
+ if [ -L ${sFILE} ]; then
+ LogText "Result: unclear if we can read this file, as this is a symlink"
+ ReportException "FileIsReadable" "Can not determine symlink ${sFILE}"
+ elif [ -d ${sFILE} ]; then
OTHERPERMS=`ls -d -l ${sFILE} | cut -c 2`
- elif [ -f ${sFILE} ]; then
+ elif [ -f ${sFILE} ]; then
OTHERPERMS=`ls -d -l ${sFILE} | cut -c 2`
fi
else
@@ -1610,6 +1614,52 @@
Report "$1"
}
+ ################################################################################
+ # Name : ReportDetails
+ # Description : Adds specific details to the report, in particular when many
+ # smaller atomic tests are performed. For example sysctl keys,
+ # and SSH settings.
+ # Returns : nothing
+ ################################################################################
+
+ ReportDetails() {
+ while [ $# -ge 1 ]; do
+ case $1 in
+ --description)
+ shift
+ TEST_DESCRIPTION=$1
+ ;;
+ --field)
+ shift
+ TEST_FIELD=$1
+ ;;
+ --key)
+ shift
+ TEST_KEY=$1
+ ;;
+ --preferredvalue|--preferred-value)
+ shift
+ TEST_PREFERRED_VALUE=$1
+ ;;
+ --test)
+ shift
+ TEST_ID=$1
+ ;;
+ --value)
+ shift
+ TEST_VALUE=$1
+ ;;
+
+ *)
+ echo "INVALID OPTION (ReportDetails): $1"
+ ExitFatal
+ ;;
+ esac
+ shift # Go to next parameter
+ done
+ Report "details[]=${TEST_ID}|desc=${TEST_DESCRIPTION},field=${TEST_FIELD},key=${TEST_KEY},prefval=${TEST_PREFERRED_VALUE},value=${TEST_VALUE}|"
+ }
+
# Log exceptions
ReportException()
{