Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH] ebuild.sh: start phases in temporary HOME if available (bug 595028)
Date: Sun, 25 Sep 2016 01:49:47
Message-Id: 1474768158-16104-1-git-send-email-zmedico@gentoo.org
1 This will avoid undesirable interactions with the python sitedir,
2 as reported in bug 574002. Since the temporary HOME is not guaranteed
3 to exist for some phases, use PORTAGE_PYM_PATH as a fallback. Also,
4 use PORTAGE_PYM_PATH inside __dyn_clean, since HOME is removed there.
5
6 X-Gentoo-Bug: 595028
7 X-Gentoo-Bug-URL: https://bugs.gentoo.org/595028
8 ---
9 bin/ebuild.sh | 11 ++++++++---
10 bin/phase-functions.sh | 8 +++++---
11 2 files changed, 13 insertions(+), 6 deletions(-)
12
13 diff --git a/bin/ebuild.sh b/bin/ebuild.sh
14 index 5b3146d..4a431b4 100755
15 --- a/bin/ebuild.sh
16 +++ b/bin/ebuild.sh
17 @@ -167,9 +167,14 @@ export SANDBOX_ON=0
18
19 # Ensure that $PWD is sane whenever possible, to protect against
20 # exploitation of insecure search path for python -c in ebuilds.
21 -# See bug #239560 and bug #469338.
22 -cd "${PORTAGE_PYM_PATH}" || \
23 - die "PORTAGE_PYM_PATH does not exist: '${PORTAGE_PYM_PATH}'"
24 +# See bug #239560, bug #469338, and bug #595028.
25 +if [[ -d ${HOME} ]] then
26 + # Use portage's temporary HOME directory if available.
27 + cd "${HOME}" || die
28 +else
29 + cd "${PORTAGE_PYM_PATH}" || \
30 + die "PORTAGE_PYM_PATH does not exist: '${PORTAGE_PYM_PATH}'"
31 +fi
32
33 #if no perms are specified, dirs/files will have decent defaults
34 #(not secretive, but not stupid)
35 diff --git a/bin/phase-functions.sh b/bin/phase-functions.sh
36 index d75f43f..50f0fdb 100644
37 --- a/bin/phase-functions.sh
38 +++ b/bin/phase-functions.sh
39 @@ -261,6 +261,11 @@ __dyn_clean() {
40 chflags -R nosunlnk,nouunlnk "${PORTAGE_BUILDDIR}" 2>/dev/null
41 fi
42
43 + # Some kernels, such as Solaris, return EINVAL when an attempt
44 + # is made to remove the current working directory.
45 + cd "${PORTAGE_PYM_PATH}" || \
46 + die "PORTAGE_PYM_PATH does not exist: '${PORTAGE_PYM_PATH}'"
47 +
48 rm -rf "${PORTAGE_BUILDDIR}/image" "${PORTAGE_BUILDDIR}/homedir"
49 rm -f "${PORTAGE_BUILDDIR}/.installed"
50
51 @@ -288,9 +293,6 @@ __dyn_clean() {
52 # result in it wiping the users distfiles directory (bad).
53 rm -rf "${PORTAGE_BUILDDIR}/distdir"
54
55 - # Some kernels, such as Solaris, return EINVAL when an attempt
56 - # is made to remove the current working directory.
57 - cd "$PORTAGE_BUILDDIR"/../..
58 rmdir "$PORTAGE_BUILDDIR" 2>/dev/null
59
60 true
61 --
62 2.7.4

Replies