OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
2 # Copyright 1999-2011 Gentoo Foundation | 2 # Copyright 1999-2011 Gentoo Foundation |
3 # Distributed under the terms of the GNU General Public License v2 | 3 # Distributed under the terms of the GNU General Public License v2 |
4 # | 4 # |
5 # Miscellaneous shell functions that make use of the ebuild env but don't need | 5 # Miscellaneous shell functions that make use of the ebuild env but don't need |
6 # to be included directly in ebuild.sh. | 6 # to be included directly in ebuild.sh. |
7 # | 7 # |
8 # We're sourcing ebuild.sh here so that we inherit all of it's goodness, | 8 # We're sourcing ebuild.sh here so that we inherit all of it's goodness, |
9 # including bashrc trickery. This approach allows us to do our miscellaneous | 9 # including bashrc trickery. This approach allows us to do our miscellaneous |
10 # shell work withing the same env that ebuild.sh has, but without polluting | 10 # shell work withing the same env that ebuild.sh has, but without polluting |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 if type -P scanelf > /dev/null && ! hasq binchecks ${RESTRICT}; then | 178 if type -P scanelf > /dev/null && ! hasq binchecks ${RESTRICT}; then |
179 local qa_var insecure_rpath=0 tmp_quiet=${PORTAGE_QUIET} | 179 local qa_var insecure_rpath=0 tmp_quiet=${PORTAGE_QUIET} |
180 local x | 180 local x |
181 | 181 |
182 # display warnings when using stricter because we die afterwards | 182 # display warnings when using stricter because we die afterwards |
183 if has stricter ${FEATURES} ; then | 183 if has stricter ${FEATURES} ; then |
184 unset PORTAGE_QUIET | 184 unset PORTAGE_QUIET |
185 fi | 185 fi |
186 | 186 |
187 » » # Make sure we disallow insecure RUNPATH/RPATHs | 187 » » # Make sure we disallow insecure RUNPATH/RPATHs. |
188 » » # Don't want paths that point to the tree where the package was
built | 188 » » # 1) References to PORTAGE_BUILDDIR are banned because it's a |
189 » » # (older, broken libtools would do this). Also check for null p
aths | 189 » » # security risk. We don't want to load files from a |
190 » » # because the loader will search $PWD when it finds null paths. | 190 » » # temporary directory. |
191 » » f=$(scanelf -qyRF '%r %p' "${D}" | grep -E "(${PORTAGE_BUILDDIR}
|: |::|^:|^ )") | 191 » » # 2) If ROOT != "/", references to ROOT are banned because |
| 192 » » # that directory won't exist on the target system. |
| 193 » » # 3) Null paths are banned because the loader will search $PWD
when |
| 194 » » # it finds null paths. |
| 195 » » local forbidden_dirs="${PORTAGE_BUILDDIR}" |
| 196 » » if [[ -n "$ROOT" ]] && [[ "$ROOT" != "/" ]]; then |
| 197 » » » forbidden_dirs="${forbidden_dirs} ${ROOT}" |
| 198 » » fi |
| 199 » » local dir="" rpath_files=$(scanelf -F '%F:%r' -qBR "${D}") |
| 200 » » f="" |
| 201 » » for dir in ${forbidden_dirs}; do |
| 202 » » » for l in $(echo "${rpath_files}" | grep -E ":${dir}|::|:
"); do |
| 203 » » » » f+=" ${l%%:*}\n" |
| 204 » » » » if ! has stricter ${FEATURES}; then |
| 205 » » » » » vecho "Auto fixing rpaths for ${l%%:*}" |
| 206 » » » » » TMPDIR="${dir}" scanelf -BXr "${l%%:*}"
-o /dev/null |
| 207 » » » » fi |
| 208 » » » done |
| 209 » » done |
| 210 |
192 # Reject set*id binaries with $ORIGIN in RPATH #260331 | 211 # Reject set*id binaries with $ORIGIN in RPATH #260331 |
193 x=$( | 212 x=$( |
194 find "${D}" -type f \( -perm -u+s -o -perm -g+s \) -prin
t0 | \ | 213 find "${D}" -type f \( -perm -u+s -o -perm -g+s \) -prin
t0 | \ |
195 xargs -0 scanelf -qyRF '%r %p' | grep '$ORIGIN' | 214 xargs -0 scanelf -qyRF '%r %p' | grep '$ORIGIN' |
196 ) | 215 ) |
| 216 |
| 217 # Print QA notice. |
197 if [[ -n ${f}${x} ]] ; then | 218 if [[ -n ${f}${x} ]] ; then |
198 vecho -ne '\n' | 219 vecho -ne '\n' |
199 eqawarn "QA Notice: The following files contain insecure
RUNPATHs" | 220 eqawarn "QA Notice: The following files contain insecure
RUNPATHs" |
200 eqawarn " Please file a bug about this at http://bugs.ge
ntoo.org/" | 221 eqawarn " Please file a bug about this at http://bugs.ge
ntoo.org/" |
201 eqawarn " with the maintaining herd of the package." | 222 eqawarn " with the maintaining herd of the package." |
202 eqawarn "${f}${f:+${x:+\n}}${x}" | 223 eqawarn "${f}${f:+${x:+\n}}${x}" |
203 vecho -ne '\n' | 224 vecho -ne '\n' |
204 if [[ -n ${x} ]] || has stricter ${FEATURES} ; then | 225 if [[ -n ${x} ]] || has stricter ${FEATURES} ; then |
205 insecure_rpath=1 | 226 insecure_rpath=1 |
206 else | |
207 vecho "Auto fixing rpaths for ${f}" | |
208 TMPDIR=${PORTAGE_BUILDDIR} scanelf -BXr ${f} -o
/dev/null | |
209 fi | 227 fi |
210 fi | 228 fi |
211 | 229 |
212 # TEXTRELs are baaaaaaaad | 230 # TEXTRELs are baaaaaaaad |
213 # Allow devs to mark things as ignorable ... e.g. things that ar
e | 231 # Allow devs to mark things as ignorable ... e.g. things that ar
e |
214 # binary-only and upstream isn't cooperating (nvidia-glx) ... we | 232 # binary-only and upstream isn't cooperating (nvidia-glx) ... we |
215 # allow ebuild authors to set QA_TEXTRELS_arch and QA_TEXTRELS .
.. | 233 # allow ebuild authors to set QA_TEXTRELS_arch and QA_TEXTRELS .
.. |
216 # the former overrides the latter ... regexes allowed ! :) | 234 # the former overrides the latter ... regexes allowed ! :) |
217 qa_var="QA_TEXTRELS_${ARCH/-/_}" | 235 qa_var="QA_TEXTRELS_${ARCH/-/_}" |
218 [[ -n ${!qa_var} ]] && QA_TEXTRELS=${!qa_var} | 236 [[ -n ${!qa_var} ]] && QA_TEXTRELS=${!qa_var} |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
980 done | 998 done |
981 unset x | 999 unset x |
982 [[ -n $PORTAGE_EBUILD_EXIT_FILE ]] && > "$PORTAGE_EBUILD_EXIT_FILE" | 1000 [[ -n $PORTAGE_EBUILD_EXIT_FILE ]] && > "$PORTAGE_EBUILD_EXIT_FILE" |
983 if [[ -n $PORTAGE_IPC_DAEMON ]] ; then | 1001 if [[ -n $PORTAGE_IPC_DAEMON ]] ; then |
984 [[ ! -s $SANDBOX_LOG ]] | 1002 [[ ! -s $SANDBOX_LOG ]] |
985 "$PORTAGE_BIN_PATH"/ebuild-ipc exit $? | 1003 "$PORTAGE_BIN_PATH"/ebuild-ipc exit $? |
986 fi | 1004 fi |
987 fi | 1005 fi |
988 | 1006 |
989 : | 1007 : |
OLD | NEW |