Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CISOfy/lynis.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormboelen <michael@cisofy.com>2016-04-26 14:52:26 +0300
committermboelen <michael@cisofy.com>2016-04-26 14:52:26 +0300
commit216611259edd429088d400ce918713704f0aa906 (patch)
treea5f02f807faebfc4c559e1b28b10f51ba89e630a /include
parent812a0ea270ea421c1690f3c3e448ffa2dba24cca (diff)
Optimize IsWorldWritable function, with additional debugging data for developers
Diffstat (limited to 'include')
-rw-r--r--include/functions21
1 files changed, 14 insertions, 7 deletions
diff --git a/include/functions b/include/functions
index e7fdd97a..7f364410 100644
--- a/include/functions
+++ b/include/functions
@@ -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()