mirror of
https://github.com/CISOfy/lynis.git
synced 2025-09-22 09:27:46 +02:00
Improved ShowSymlinkPath function and optimized FileIsReadable function
This commit is contained in:
parent
7bbc8023bf
commit
f3a7921a3d
@ -289,28 +289,30 @@
|
|||||||
|
|
||||||
# Check for symlink
|
# Check for symlink
|
||||||
if [ -L ${sFILE} ]; then
|
if [ -L ${sFILE} ]; then
|
||||||
if [ ! "${READLINKBINARY}" = "" ]; then
|
ShowSymlinkPath ${sFILE}
|
||||||
tFILE=`${READLINKBINARY} ${sFILE}`
|
if [ ! "${SYMLINK}" = "" ]; then sFILE="${SYMLINK}"; fi
|
||||||
# Check if we can find the file now
|
#if [ ! "${READLINKBINARY}" = "" ]; then
|
||||||
if [ -f ${tFILE} ]; then
|
# tFILE=`${READLINKBINARY} ${sFILE}`
|
||||||
sFILE="${tFILE}"
|
# # Check if we can find the file now
|
||||||
logtext "Result: symlink found, pointing to file ${sFILE}"
|
# if [ -f ${tFILE} ]; then
|
||||||
elif [ -d ${tFILE} ]; then
|
# sFILE="${tFILE}"
|
||||||
sFILE="${tFILE}"
|
# logtext "Result: symlink found, pointing to file ${sFILE}"
|
||||||
logtext "Result: symlink found, pointing to directory ${sFILE}"
|
# elif [ -d ${tFILE} ]; then
|
||||||
else
|
# sFILE="${tFILE}"
|
||||||
# Check the full path of the symlink, strip the filename, copy the path and linked filename together
|
# logtext "Result: symlink found, pointing to directory ${sFILE}"
|
||||||
tDIR=`echo ${sFILE} | awk '{match($1, "^.*/"); print substr($1, 1, RLENGTH-1)}'`
|
# else
|
||||||
tFILE="${tDIR}/${tFILE}"
|
# # Check the full path of the symlink, strip the filename, copy the path and linked filename together
|
||||||
if [ -f ${tFILE} ]; then
|
# tDIR=`echo ${sFILE} | awk '{match($1, "^.*/"); print substr($1, 1, RLENGTH-1)}'`
|
||||||
sFILE="${tFILE}"
|
# tFILE="${tDIR}/${tFILE}"
|
||||||
logtext "Result: symlink found, seems to be file ${sFILE}"
|
# if [ -f ${tFILE} ]; then
|
||||||
elif [ -d ${tFILE} ]; then
|
# sFILE="${tFILE}"
|
||||||
sFILE="${tFILE}"
|
# logtext "Result: symlink found, seems to be file ${sFILE}"
|
||||||
logtext "Result: symlink found, seems to be directory ${sFILE}"
|
# elif [ -d ${tFILE} ]; then
|
||||||
fi
|
# sFILE="${tFILE}"
|
||||||
fi
|
# logtext "Result: symlink found, seems to be directory ${sFILE}"
|
||||||
fi
|
# fi
|
||||||
|
# fi
|
||||||
|
#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 ${sFILE} ]; then
|
if [ -L ${sFILE} ]; then
|
||||||
@ -1194,16 +1196,31 @@
|
|||||||
# Check the full path of the symlink, strip the filename, copy the path and linked filename together
|
# Check the full path of the symlink, strip the filename, copy the path and linked filename together
|
||||||
tDIR=`echo ${sFILE} | awk '{match($1, "^.*/"); print substr($1, 1, RLENGTH-1)}'`
|
tDIR=`echo ${sFILE} | awk '{match($1, "^.*/"); print substr($1, 1, RLENGTH-1)}'`
|
||||||
tFILE="${tDIR}/${tFILE}"
|
tFILE="${tDIR}/${tFILE}"
|
||||||
if [ -f ${tFILE} ]; then
|
if [ -L ${tFILE} ]; then
|
||||||
|
logtext "Result: this symlink links to another symlink"
|
||||||
|
# Trying it with -f option
|
||||||
|
tFILE=`${READLINKBINARY} -f ${tFILE}`
|
||||||
|
if [ -f ${tFILE} ]; then
|
||||||
|
sFILE="${tFILE}"
|
||||||
|
logtext "Result: symlink finally found, seems to be file ${sFILE}"
|
||||||
|
FOUNDPATH=1
|
||||||
|
elif [ -d ${tFILE} ]; then
|
||||||
|
sFILE="${tFILE}"
|
||||||
|
logtext "Result: symlink found, seems to be directory ${sFILE}"
|
||||||
|
FOUNDPATH=1
|
||||||
|
else
|
||||||
|
logtext "Result: could not find file ${tFILE}, most likely too complicated symlink or too often linked"
|
||||||
|
fi
|
||||||
|
elif [ -f ${tFILE} ]; then
|
||||||
sFILE="${tFILE}"
|
sFILE="${tFILE}"
|
||||||
logtext "Result: symlink found, seems to be file ${sFILE}"
|
logtext "Result: symlink found, seems to be file ${sFILE}"
|
||||||
FOUNDPATH=1
|
FOUNDPATH=1
|
||||||
elif [ -d ${tFILE} ]; then
|
elif [ -d ${tFILE} ]; then
|
||||||
sFILE="${tFILE}"
|
sFILE="${tFILE}"
|
||||||
logtext "Result: symlink found, seems to be directory ${sFILE}"
|
logtext "Result: symlink found, seems to be directory ${sFILE}"
|
||||||
FOUNDPATH=1
|
FOUNDPATH=1
|
||||||
else
|
else
|
||||||
logtext "Result: path ${sFILE} not found"
|
logtext "Result: file ${tFILE} in ${tDIR} not found"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -1213,6 +1230,11 @@
|
|||||||
logtext "Result: unable to determine symlink, or location ${sFILE} is just another symlink"
|
logtext "Result: unable to determine symlink, or location ${sFILE} is just another symlink"
|
||||||
FOUNDPATH=0
|
FOUNDPATH=0
|
||||||
fi
|
fi
|
||||||
|
if [ ${FOUNDPATH} -eq 1 ]; then
|
||||||
|
SYMLINK="${sFILE}"
|
||||||
|
else
|
||||||
|
SYMLINK=""
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
ViewCategories()
|
ViewCategories()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user