Added FileIsReadable function

This commit is contained in:
mboelen 2014-09-08 21:30:54 +02:00
parent c3494b32d1
commit 691019f9ae
1 changed files with 30 additions and 0 deletions

View File

@ -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()
{