Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't dereference argv[0] when launching a script through a symlink.
Reported-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> Ref: https://bugs.gentoo.org/show_bug.cgi?id=517496 Also, don't complain about non-regular or non-executable files that are not explicitely candidates.
- Loading branch information
1 parent
205c4fa
commit 520fa36
Showing
3 changed files
with
64 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
if [ -z `which mcookie` ] || [ -z `which rm` ] || [ -z `which cat` ] || [ -z `which chmod` ] || [ -z `which ln` ] || [ -z `which grep` ] || [ -z `which mkdir` ] || [ ! -x ${ROOTFS}/bin/readlink ]; then | ||
exit 125; | ||
fi | ||
|
||
###################################################################### | ||
|
||
TMP1=/tmp/$(mcookie) | ||
TMP2=/tmp/$(mcookie) | ||
TMP3=/tmp/$(mcookie) | ||
TMP4=/tmp/$(mcookie) | ||
|
||
rm -fr ${TMP1} ${TMP2} ${TMP3} ${TMP4} | ||
|
||
###################################################################### | ||
|
||
cat > ${TMP1} <<'EOF' | ||
#!/bin/sh | ||
echo $0 | ||
EOF | ||
|
||
chmod +x ${TMP1} | ||
ln -s ${TMP1} ${TMP2} | ||
|
||
${PROOT} ${TMP2} | grep -v ${TMP1} | ||
${PROOT} ${TMP2} | grep ${TMP2} | ||
|
||
###################################################################### | ||
|
||
mkdir -p ${TMP3} | ||
cd ${TMP3} | ||
|
||
ln -s $(which true) false | ||
! ${PROOT} false | ||
|
||
echo "#!$(which false)" > true | ||
chmod a-x true | ||
${PROOT} true | ||
|
||
###################################################################### | ||
|
||
ln -s ${ROOTFS}/bin/readlink ${TMP4} | ||
|
||
TEST1=$(${PROOT} ${ROOTFS}/bin/readlink /proc/self/exe) | ||
TEST2=$(${PROOT} ${TMP4} /proc/self/exe) | ||
|
||
test "${TEST1}" = "${TEST2}" | ||
|
||
###################################################################### | ||
|
||
cd / | ||
rm -fr ${TMP1} ${TMP2} ${TMP3} ${TMP4} |