Support spaces in file names (#445)

* Support spaces in file names

File names may contain spaces

* Fixed 2more cases
This commit is contained in:
Bruno Vernay 2017-08-29 14:33:18 +02:00 committed by Michael Boelen
parent 4107d8a461
commit 6cf1c324f8
1 changed files with 12 additions and 12 deletions

View File

@ -754,35 +754,35 @@
LogText "Test: check if we can access ${sFILE} (escaped: ${escaped_file})" LogText "Test: check if we can access ${sFILE} (escaped: ${escaped_file})"
# Check for symlink # Check for symlink
if [ -L ${escaped_file} ]; then if [ -L "${escaped_file}" ]; then
ShowSymlinkPath ${escaped_file} ShowSymlinkPath ${escaped_file}
if [ ! -z "${SYMLINK}" ]; then escaped_file="${SYMLINK}"; fi if [ ! -z "${SYMLINK}" ]; then escaped_file="${SYMLINK}"; fi
fi fi
# Only check the file if it isn't a symlink (after previous check) # Only check the file if it isn't a symlink (after previous check)
if [ -L ${escaped_file} ]; then if [ -L "${escaped_file}" ]; then
OTHERPERMS="-" OTHERPERMS="-"
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} 2> /dev/null | ${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} 2> /dev/null | ${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} 2> /dev/null | ${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} 2> /dev/null | ${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} 2> /dev/null | ${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}"