summaryrefslogtreecommitdiff
blob: ec87806699adfdc46d03f4d1ceee34337017729e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/eblits/pkg_preinst.eblit,v 1.5 2012/10/02 04:58:30 vapier Exp $

eblit-glibc-pkg_preinst() {
	# nothing to do if just installing headers
	just_headers && return

	# prepare /etc/ld.so.conf.d/ for files
	mkdir -p "${ROOT}"/etc/ld.so.conf.d

	# simple test to make sure our new glibc isnt completely broken.
	# make sure we don't test with statically built binaries since
	# they will fail.  also, skip if this glibc is a cross compiler.
	[[ ${ROOT} != "/" ]] && return 0
	[[ -d ${D}/$(get_libdir) ]] || return 0
	cd / #228809
	local x striptest
	for x in date env ls true uname ; do
		x=$(type -p ${x})
		[[ -z ${x} ]] && continue
		striptest=$(LC_ALL="C" file -L ${x} 2>/dev/null)
		[[ -z ${striptest} ]] && continue
		[[ ${striptest} == *"statically linked"* ]] && continue
		# we enter ${D} so to avoid trouble if the path contains
		# special characters; for instance if the path contains the
		# colon character (:), then the linker will try to split it
		# and look for the libraries in an unexpected place. This can
		# lead to unsafe code execution if the generated prefix is
		# within a world-writable directory
		# (e.g. /var/tmp/portage:${HOSTNAME})
		pushd "${D}"/$(get_libdir) 2>/dev/null
		./ld-*.so --library-path . ${x} > /dev/null \
			|| die "simple run test (${x}) failed"
		popd 2>/dev/null
	done
}