From: Zac Medico Date: Sun, 12 May 2013 20:47:42 +0000 (-0700) Subject: dohtml: safe cwd, bug #469338 X-Git-Tag: v2.2.0_alpha175~10 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e54be5ed25fdd0462aee579364983e6406c22983;p=portage.git dohtml: safe cwd, bug #469338 --- diff --git a/bin/dohtml.py b/bin/dohtml.py index 3af270509..1b6ba89f1 100755 --- a/bin/dohtml.py +++ b/bin/dohtml.py @@ -1,5 +1,5 @@ #!/usr/bin/python -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # @@ -33,6 +33,9 @@ from __future__ import print_function import os import sys +# Change back to original cwd _after_ all imports (bug #469338). +os.chdir(os.environ["__PORTAGE_HELPER_CWD"]) + def dodir(path): os.spawnlp(os.P_WAIT, "install", "install", "-d", path) diff --git a/bin/ebuild-helpers/dohtml b/bin/ebuild-helpers/dohtml index aec5e79bd..4be9bc2eb 100755 --- a/bin/ebuild-helpers/dohtml +++ b/bin/ebuild-helpers/dohtml @@ -6,6 +6,9 @@ source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin} PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym} +# Use safe cwd, avoiding unsafe import for bug #469338. +export __PORTAGE_HELPER_CWD=${PWD} +cd "${PORTAGE_PYM_PATH}" PYTHONPATH=$PORTAGE_PYM_PATH${PYTHONPATH:+:}$PYTHONPATH \ "${PORTAGE_PYTHON:-/usr/bin/python}" "$PORTAGE_BIN_PATH/dohtml.py" "$@"