mirror of https://github.com/CISOfy/lynis.git
Optimize IsWorldWritable function, with additional debugging data for developers
This commit is contained in:
parent
812a0ea270
commit
216611259e
|
@ -1183,6 +1183,7 @@
|
|||
fi
|
||||
}
|
||||
|
||||
|
||||
################################################################################
|
||||
# Name : IsWorldWritable()
|
||||
# Description : Determines if a file is writable for all users
|
||||
|
@ -1190,19 +1191,25 @@
|
|||
# Usage : if IsWorldWritable /etc/motd; then echo "File is writable"; fi
|
||||
################################################################################
|
||||
|
||||
IsWorldWritable()
|
||||
{
|
||||
IsWorldWritable() {
|
||||
sFILE=$1
|
||||
FileIsWorldWritable=""
|
||||
|
||||
# Only check the file if it isn't a symlink (after previous check)
|
||||
if [ -f ${sFILE} -a ! -L ${sFILE} ]; then
|
||||
FINDVAL=`ls -l ${sFILE} | cut -c 9`
|
||||
if [ "${FINDVAL}" = "w" ]; then return 0; LogText "IsWorldWritable: file ${sFILE} is world-writable"; else return 1; fi
|
||||
# Only check if target is a file or directory
|
||||
if [ -f ${sFILE} -o -d ${sFILE} ]; then
|
||||
FINDVAL=`ls -ld ${sFILE} | cut -c 9`
|
||||
if IsDeveloperMode; then Debug "File mode of ${sFILE} is ${FINDVAL}"; fi
|
||||
if [ "${FINDVAL}" = "w" ]; then
|
||||
if IsDeveloperMode; then LogText "IsWorldWritable: file ${sFILE} is world-writable"; fi
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
return 255
|
||||
fi
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
################################################################################
|
||||
# Name : LogText()
|
||||
|
|
Loading…
Reference in New Issue