Merge pull request #792 from Aresius423/master

Correctly split lines of /etc/passwd
This commit is contained in:
Michael Boelen 2019-12-06 15:36:00 +01:00 committed by GitHub
commit 04e11d3e09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -57,7 +57,8 @@
if [ ${SKIPTEST} -eq 0 ]; then
# Check if users' home directories permissions are 750 or more restrictive
FOUND=0
for LINE in $(${EGREPBINARY} -v '^(daemon|git|halt|root|shutdown|sync)' ${ROOTDIR}etc/passwd | ${AWKBINARY} -F: '($7 !~ "/(false|nologin)$") { print $1 ":" $6}'); do
USERDATA=$(${EGREPBINARY} -v '^(daemon|git|halt|root|shutdown|sync)' ${ROOTDIR}etc/passwd | ${AWKBINARY} -F: '($7 !~ "/(false|nologin)$") { print }')
while read -r LINE; do
USER=$(echo ${LINE} | ${CUTBINARY} -d: -f1)
DIR=$(echo ${LINE} | ${CUTBINARY} -d: -f2)
if [ -d "${DIR}" ]; then
@ -70,7 +71,9 @@
LogText "Result: permissions of home directory ${DIR} of user ${USER} are fine"
fi
fi
done
done << EOF
${USERDATA}
EOF
if [ ${FOUND} -eq 1 ]; then
Display --indent 2 --text "- Permissions of home directories" --result "${STATUS_WARNING}" --color RED
@ -89,7 +92,8 @@
if [ ${SKIPTEST} -eq 0 ]; then
# Check if users own their home directories
FOUND=0
for LINE in $(${EGREPBINARY} -v '^(daemon|git|halt|root|shutdown|sync)' ${ROOTDIR}etc/passwd | ${AWKBINARY} -F: '($7 !~ "/(false|nologin)$") { print $1 ":" $6}'); do
USERDATA=$(${EGREPBINARY} -v '^(daemon|git|halt|root|shutdown|sync)' ${ROOTDIR}etc/passwd | ${AWKBINARY} -F: '($7 !~ "/(false|nologin)$") { print }')
while read -r LINE; do
USER=$(echo ${LINE} | ${CUTBINARY} -d: -f1)
DIR=$(echo ${LINE} | ${CUTBINARY} -d: -f2)
if [ -d ${DIR} ]; then
@ -101,7 +105,9 @@
LogText "Result: ownership of home directory ${DIR} for user ${USER} looks to be correct"
fi
fi
done
done << EOF
${USERDATA}
EOF
if [ ${FOUND} -eq 1 ]; then
Display --indent 2 --text "- Ownership of home directories" --result "${STATUS_WARNING}" --color RED