Ignore file access errors when trying to access them

This commit is contained in:
Michael Boelen 2017-08-17 14:18:29 +02:00
parent 77ebb23320
commit 358dc46b81
No known key found for this signature in database
GPG Key ID: 26141F77A09D7F04

View File

@ -765,24 +765,24 @@
LogText "Result: unclear if we can read this file, as this is a symlink" LogText "Result: unclear if we can read this file, as this is a symlink"
ReportException "FileIsReadable" "Can not determine symlink ${sFILE}" ReportException "FileIsReadable" "Can not determine symlink ${sFILE}"
elif [ -d ${escaped_file} ]; then elif [ -d ${escaped_file} ]; then
OTHERPERMS=$(${LSBINARY} -d -l ${escaped_file} | ${CUTBINARY} -c 8) OTHERPERMS=$(${LSBINARY} -d -l ${escaped_file} 2> /dev/null | ${CUTBINARY} -c 8)
elif [ -f ${escaped_file} ]; then elif [ -f ${escaped_file} ]; then
OTHERPERMS=$(${LSBINARY} -d -l ${escaped_file} | ${CUTBINARY} -c 8) OTHERPERMS=$(${LSBINARY} -d -l ${escaped_file} 2> /dev/null | ${CUTBINARY} -c 8)
else else
OTHERPERMS="-" OTHERPERMS="-"
fi fi
# Also check if we are the actual owner of the file (use -d to get directory itself, if its a directory) # Also check if we are the actual owner of the file (use -d to get directory itself, if its a directory)
FILEOWNER=$(ls -dln ${escaped_file} | ${AWKBINARY} -F" " '{ print $3 }') FILEOWNER=$(ls -dln ${escaped_file} 2> /dev/null | ${AWKBINARY} -F" " '{ print $3 }')
if [ "${FILEOWNER}" = "${MYID}" ]; then if [ "${FILEOWNER}" = "${MYID}" ]; then
LogText "Result: file is owned by our current user ID (${MYID}), checking if it is readable" LogText "Result: file is owned by our current user ID (${MYID}), checking if it is readable"
if [ -L ${sFILE} ]; then if [ -L ${sFILE} ]; then
LogText "Result: unclear if we can read this file, as this is a symlink" LogText "Result: unclear if we can read this file, as this is a symlink"
ReportException "FileIsReadable" "Can not determine symlink ${escaped_file}" ReportException "FileIsReadable" "Can not determine symlink ${escaped_file}"
elif [ -d ${escaped_file} ]; then elif [ -d ${escaped_file} ]; then
OTHERPERMS=$(${LSBINARY} -d -l ${escaped_file} | ${CUTBINARY} -c 2) OTHERPERMS=$(${LSBINARY} -d -l ${escaped_file} 2> /dev/null | ${CUTBINARY} -c 2)
elif [ -f ${escaped_file} ]; then elif [ -f ${escaped_file} ]; then
OTHERPERMS=$(${LSBINARY} -l ${escaped_file} | ${CUTBINARY} -c 2) OTHERPERMS=$(${LSBINARY} -l ${escaped_file} 2> /dev/null | ${CUTBINARY} -c 2)
fi fi
else else
LogText "Result: file is not owned by current user ID (${MYID}), but UID ${FILEOWNER}" LogText "Result: file is not owned by current user ID (${MYID}), but UID ${FILEOWNER}"