From 5c0c5217f1fd033a9749a10a3dfa71b3943e6d4d Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 16 Mar 2006 03:30:26 +0000 Subject: Add a new PORTAGE_WORKDIR_MODE config variable so that the mode of WORKDIR is no longer hard coded. See bug #8688. svn path=/main/trunk/; revision=2901 --- bin/ebuild.sh | 6 ++++-- cnf/make.globals | 3 +++ pym/portage.py | 17 +++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/bin/ebuild.sh b/bin/ebuild.sh index 71bb78071..1402f71a4 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -714,8 +714,10 @@ dyn_unpack() { fi fi - install -m0700 -d "${WORKDIR}" || die "Failed to create dir '${WORKDIR}'" - [ -d "$WORKDIR" ] && cd "${WORKDIR}" + if [ ! -d "${WORKDIR}" ]; then + install -m${PORTAGE_WORKDIR_MODE-0700} -d "${WORKDIR}" || die "Failed to create dir '${WORKDIR}'" + fi + cd "${WORKDIR}" || die "Directory change failed: \`cd '${WORKDIR}'\`" echo ">>> Unpacking source..." src_unpack touch "${PORTAGE_BUILDDIR}/.unpacked" || die "IO Failure -- Failed 'touch .unpacked' in ${PORTAGE_BUILDDIR}" diff --git a/cnf/make.globals b/cnf/make.globals index 2586ca2fa..cdcceb198 100644 --- a/cnf/make.globals +++ b/cnf/make.globals @@ -64,6 +64,9 @@ USE_ORDER="env:pkg:conf:defaults" PORTAGE_INST_UID="0" PORTAGE_INST_GID="0" +# Mode bits for ${WORKDIR} (see ebuild.5). +PORTAGE_WORKDIR_MODE="0700" + # ***************************** # ** DO NOT EDIT THIS FILE ** # *************************************************** diff --git a/pym/portage.py b/pym/portage.py index a5350bcde..47308629f 100644 --- a/pym/portage.py +++ b/pym/portage.py @@ -2624,6 +2624,23 @@ def prepare_build_dirs(myroot, mysettings, cleanup): mysettings["WORKDIR"]=mysettings["PORTAGE_BUILDDIR"]+"/work" mysettings["D"]=mysettings["PORTAGE_BUILDDIR"]+"/image/" + workdir_mode = 0700 + try: + workdir_mode = int(eval(mysettings["PORTAGE_WORKDIR_MODE"])) + if workdir_mode & 07777 != workdir_mode: + raise ValueError("Invalid file mode: %s" % mysettings["PORTAGE_WORKDIR_MODE"]) + except KeyError, e: + writemsg("!!! PORTAGE_WORKDIR_MODE is unset, using %s." % oct(workdir_mode)) + except ValueError, e: + writemsg("%s\n" % e) + writemsg("!!! Unable to parse PORTAGE_WORKDIR_MODE='%s', using %s.\n" % \ + (mysettings["PORTAGE_WORKDIR_MODE"], oct(workdir_mode))) + try: + apply_secpass_permissions(mysettings["WORKDIR"], + uid=portage_uid, gid=portage_gid, mode=workdir_mode) + except portage_exception.FileNotFound: + pass # ebuild.sh will create it + if mysettings.has_key("PORT_LOGDIR"): if not os.access(mysettings["PORT_LOGDIR"],os.F_OK): try: -- cgit v1.2.3-1-g7c22