Gentoo Archives: gentoo-commits

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