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:
authorMichael Boelen <michael.boelen@cisofy.com>2019-11-25 17:28:00 +0300
committerGitHub <noreply@github.com>2019-11-25 17:28:00 +0300
commitcad55d8becf2200239ff473830ec478601b4f57c (patch)
tree9ebacbe525beea69ef83917da4237bc40bb9a840 /include/functions
parent65f88e148b3d5a59e349001da2c4d14f7db1a20d (diff)
parent6dad2f476e3ab5386cf573b962f9af58a20fb60f (diff)
Merge pull request #802 from dvehrs/HCFP
Updated permissions checks
Diffstat (limited to 'include/functions')
-rw-r--r--include/functions18
1 files changed, 14 insertions, 4 deletions
diff --git a/include/functions b/include/functions
index 0c258907..25a74552 100644
--- a/include/functions
+++ b/include/functions
@@ -1282,6 +1282,9 @@
CHECK_PERMISSION=$(echo "-${CHECK_PERMISSION}" | ${AWKBINARY} '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf("%0o",k)}')
fi
+ # Add leading zeros if necessary
+ CHECK_PERMISSION=$(echo "${CHECK_PERMISSION}" | ${AWKBINARY} '{printf "%03d",$1}')
+
# First try stat command
LogText "Test: checking if file ${CHECKFILE} is ${CHECK_PERMISSION}"
if [ -n "${STATBINARY}" ]; then
@@ -1300,7 +1303,11 @@
*)
# Only use find when OS is NOT AIX and binaries are NOT busybox
if [ ${SHELL_IS_BUSYBOX} -eq 0 ]; then
- DATA=$(${FINDBINARY} ${CHECKFILE} -printf "%m")
+ if [ -d ${CHECKFILE} ]; then
+ DATA=$(${FINDBINARY} ${CHECKFILE} -maxdepth 0 -printf "%m")
+ else
+ DATA=$(${FINDBINARY} ${CHECKFILE} -printf "%m")
+ fi
fi
;;
esac
@@ -1318,13 +1325,16 @@
# Convert permissions to octal when needed
case ${DATA} in
- "r"|"w"|"x"|"-")
+ [-r][-w][-x][-r][-w][-x][-r][-w][-x] )
LogText "Converting value ${DATA} to octal"
- DATA=$(echo ${DATA} | ${AWKBINARY} '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf("%0o",k)}')
- if [ "${DATA}" = "0" ]; then DATA="000"; fi
+ # add a dummy character as first character so it looks like output is a normal file
+ DATA=$(echo "-${DATA}" | ${AWKBINARY} '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf("%0o",k)}')
;;
esac
+ # Add leading zeros if necessary
+ DATA=$(echo "${DATA}" | ${AWKBINARY} '{printf "%03d",$1}')
+
if [ -n "${DATA}" ]; then
if [ "${DATA}" = "${CHECK_PERMISSION}" ]; then
LogText "Outcome: correct permissions (${DATA})"