mirror of https://github.com/CISOfy/lynis.git
Added FileIsReadable function
This commit is contained in:
parent
c3494b32d1
commit
691019f9ae
|
@ -29,6 +29,7 @@
|
||||||
# ExitClean Stop the program (cleanly)
|
# ExitClean Stop the program (cleanly)
|
||||||
# ExitFatal Stop the program (cleanly), with fatal
|
# ExitFatal Stop the program (cleanly), with fatal
|
||||||
# FileExists Check if a file exists on the disk
|
# 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
|
# GetHostID Retrieve an unique ID for this host
|
||||||
# InsertSection Insert a section block
|
# InsertSection Insert a section block
|
||||||
# InsertPluginSection Insert a section block for plugins
|
# InsertPluginSection Insert a section block for plugins
|
||||||
|
@ -75,6 +76,8 @@
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Name : CheckItem()
|
# Name : CheckItem()
|
||||||
# Description : Check if a specific item exists in the report
|
# Description : Check if a specific item exists in the report
|
||||||
|
@ -242,6 +245,33 @@
|
||||||
fi
|
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
|
# Get Host ID
|
||||||
GetHostID()
|
GetHostID()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue