diff options
author | mboelen <michael@cisofy.com> | 2014-09-08 23:30:54 +0400 |
---|---|---|
committer | mboelen <michael@cisofy.com> | 2014-09-08 23:30:54 +0400 |
commit | 691019f9ae13ea4fdcbf9891a7005ff3f976324d (patch) | |
tree | 7a3b32f947fb8822eb41286a01a797bd83fa4b9d | |
parent | c3494b32d180bd6406f3614d4bb1ac59009b2031 (diff) |
Added FileIsReadable function
-rw-r--r-- | include/functions | 30 |
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() { |