shebang check: ignore symlinks that point outside the prefix
authorMichael Haubenwallner <haubi@gentoo.org>
Sun, 24 Apr 2011 17:18:03 +0000 (19:18 +0200)
committerFabian Groffen <grobian@gentoo.org>
Sun, 24 Apr 2011 17:18:03 +0000 (19:18 +0200)
As documented in bug #282539, we can have symlinks that point outside
the prefix.  The targets of those files need not to be checked for their
shebang, as they are obviously not under our control.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
bin/misc-functions.sh

index 59cc9d45440cc03126fc564e43cbac4d14b373bf..3bf506054dec93ec5456fcc4e3ba0ab91a136bd0 100644 (file)
@@ -800,15 +800,18 @@ install_qa_check_prefix() {
                IFS=${oldIFS}
                [[ ${WHITELIST} == *" ${line[0]} "* ]] && continue
                local fp=${fn#${D}} ; fp=/${fp%/*}
+               # line[0] can be an absolutised path, bug #342929
+               local eprefix=$(canonicalize ${EPREFIX})
                local rf=${fn}
                # in case we deal with a symlink, make sure we don't replace it
                # with a real file (sed -i does that)
                if [[ -L ${fn} ]] ; then
                        rf=$(readlink ${fn})
                        [[ ${rf} != /* ]] && rf=${fn%/*}/${rf}
+                       # ignore symlinks pointing to outside prefix
+                       # as seen in sys-devel/native-cctools
+                       [[ ${rf} != ${EPREFIX}/* && $(canonicalize "${rf}") != ${eprefix}/* ]] && continue
                fi
-               # line[0] can be an absolutised path, bug #342929
-               local eprefix=$(canonicalize ${EPREFIX})
                # does the shebang start with ${EPREFIX}, and does it exist?
                if [[ ${line[0]} == ${EPREFIX}/* || ${line[0]} == ${eprefix}/* ]] ; then
                        if [[ ! -e ${ROOT%/}${line[0]} && ! -e ${D%/}${line[0]} ]] ; then