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:
-rw-r--r--include/functions30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/functions b/include/functions
index 86d2fefb..97c8e452 100644
--- a/include/functions
+++ b/include/functions
@@ -29,6 +29,7 @@
# ExitClean Stop the program (cleanly)
# ExitFatal Stop the program (cleanly), with fatal
# FileExists Check if a file exists on the disk
+# FileIsReadable Check if a file is readable or directory accessible
# GetHostID Retrieve an unique ID for this host
# InsertSection Insert a section block
# InsertPluginSection Insert a section block for plugins
@@ -75,6 +76,8 @@
fi
}
+
+
################################################################################
# Name : CheckItem()
# Description : Check if a specific item exists in the report
@@ -242,6 +245,33 @@
fi
}
+
+ ################################################################################
+ # Name : FileIsReadable
+ # Description : Check if a file readable or directory is accessible
+ # Returns : CANREAD (0 or 1)
+ ################################################################################
+
+ FileIsReadable()
+ {
+ CHECKFILE=$1
+ CANREAD=0
+ if [ -d ${CHECKFILE} ]; then
+ OTHERPERMS=`ls -d -l ${CHECKFILE} | cut -c 8`
+ elif [ -f ${CHECKFILE} ]; then
+ OTHERPERMS=`ls -d -l ${CHECKFILE} | cut -c 8`
+ else
+ OTHERPERMS="-"
+ fi
+ # Check if we have the read bit
+ if [ "${OTHERPERMS}" = "r" ]; then
+ CANREAD=1
+ fi
+ }
+
+
+
+
# Get Host ID
GetHostID()
{