Summary: | sys-apps/portage runs pkg_preinst and pkg_postinst from python sitedir | ||
---|---|---|---|
Product: | Portage Development | Reporter: | Mike Gilbert <floppym> |
Component: | Core - Ebuild Support | Assignee: | Portage team <dev-portage> |
Status: | RESOLVED FIXED | ||
Severity: | normal | Keywords: | InVCS |
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
See Also: |
https://bugs.gentoo.org/show_bug.cgi?id=574002 https://bugs.gentoo.org/show_bug.cgi?id=595030 https://bugs.gentoo.org/show_bug.cgi?id=585146 |
||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Bug Depends on: | 239560 | ||
Bug Blocks: | 604854 |
Description
Mike Gilbert
![]() I see that WORKDIR is not valid in pkg functions. Maybe ROOT or EROOT would work instead. The current behavior is a result of these lines in ebuild.sh: # Ensure that $PWD is sane whenever possible, to protect against # exploitation of insecure search path for python -c in ebuilds. # See bug #239560 and bug #469338. cd "${PORTAGE_PYM_PATH}" || \ die "PORTAGE_PYM_PATH does not exist: '${PORTAGE_PYM_PATH}'" Since we don't change the working directory before invoking the pkg_* functions, we end up starting them in PORTAGE_PYM_DIR. It has to be a trusted directory for python import security (bug 239560). Maybe create an empty directory for it then? I think $HOME makes sense. It the context of ebuilds, portage creates a temporary $HOME which is an empty directory located at $PORTAGE_BUILDDIR/homedir (it's a sibling of standard directories including $WORKDIR, $T, and $D). Since portage's __save_ebuild_env filters the HOME variable, we can assume that at the beginning of each phase function, it will have the $PORTAGE_BUILDDIR/homedir value that is set by the doebuild_environment function. These are the only commands where $HOME is not guaranteed to be valid: _doebuild_commands_without_builddir = ( 'clean', 'cleanrm', 'depend', 'digest', 'fetch', 'fetchall', 'help', 'manifest' ) For all other commands, $HOME is guaranteed to be created by the prepare_build_dirs function. Patch sent for review: https://archives.gentoo.org/gentoo-portage-dev/message/61e44b4b2e62dd9e4449aac504219447 https://github.com/gentoo/portage/pull/54 In the master branch: https://gitweb.gentoo.org/proj/portage.git/commit/?id=120deae6d7e63a35fc068aa92ff2e4263c98e5b6 Fixed in portage-2.3.3. |