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