aboutsummaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorMartin Schlemmer <azarah@gentoo.org>2006-07-04 15:32:43 +0000
committerMartin Schlemmer <azarah@gentoo.org>2006-07-04 15:32:43 +0000
commit20b50c7f6c567f8a44e8e8a264d00e393d9761a9 (patch)
tree5d86929599c37d6064637a5828034389d5d77fb2 /data
parentSmall logic simplification. (diff)
downloadsandbox-20b50c7f6c567f8a44e8e8a264d00e393d9761a9.tar.gz
sandbox-20b50c7f6c567f8a44e8e8a264d00e393d9761a9.tar.bz2
sandbox-20b50c7f6c567f8a44e8e8a264d00e393d9761a9.zip
Add SANDBOX_INTRACTV logic, and Vapier's sandboxshell mojo.
Signed-off-by: Martin Schlemmer <azarah@gentoo.org>
Diffstat (limited to 'data')
-rw-r--r--data/sandbox.bashrc83
1 files changed, 81 insertions, 2 deletions
diff --git a/data/sandbox.bashrc b/data/sandbox.bashrc
index b71a063..a0d91e4 100644
--- a/data/sandbox.bashrc
+++ b/data/sandbox.bashrc
@@ -1,8 +1,6 @@
# Copyright (C) 2001 Geert Bevin, Uwyn, http://www.uwyn.com
# Distributed under the terms of the GNU General Public License, v2 or later
-# Author : Geert Bevin <gbevin@uwyn.com>
# $Header$
-source /etc/profile
if [[ -n ${LD_PRELOAD} && ${LD_PRELOAD} != *$SANDBOX_LIB* ]] ; then
export LD_PRELOAD="${SANDBOX_LIB} ${LD_PRELOAD}"
@@ -16,3 +14,84 @@ alias make="make LD_PRELOAD=${LD_PRELOAD}"
alias su="su -c '/bin/bash -rcfile ${SANDBOX_BASHRC}'"
declare -r SANDBOX_ACTIVE
+
+if [[ ${SANDBOX_INTRACTV} == "1" ]] ; then
+ trap ":" INT QUIT TSTP
+
+ source /etc/profile
+
+ (
+ source /sbin/functions.sh
+ echo
+ einfo "Loading sandboxed shell"
+ einfo " Log File: ${SANDBOX_LOG}"
+ if [[ -n ${SANDBOX_DEBUG_LOG} ]] ; then
+ einfo " Debug Log File: ${SANDBOX_DEBUG_LOG}"
+ fi
+ einfo " sandboxon: turn sandbox on"
+ einfo " sandboxoff: turn sandbox off"
+ einfo " addread <path>: allow <path> to be read"
+ einfo " addwrite <path>: allow <path> to be written"
+ einfo " adddeny <path>: deny access to <path>"
+ einfo " addpredict <path>: allow fake access to <path>"
+ echo
+ )
+
+ # do ebuild environment loading ... detect if we're in portage
+ # build area or not ... uNF uNF uNF
+ #sbs_pdir=$(portageq envvar PORTAGE_TMPDIR)/portage/ #portageq takes too long imo
+ if [[ -z ${PORTAGE_TMPDIR} ]] ; then
+ sbs_gpdir=$( source /etc/make.globals && echo $PORTAGE_TMPDIR 2> /dev/null)
+ sbs_cpdir=$( source /etc/make.conf && echo $PORTAGE_TMPDIR 2> /dev/null)
+ [[ -z ${sbs_cpdir} ]] \
+ && sbs_pdir=${sbs_gpdir} \
+ || sbs_pdir=${sbs_cpdir}
+ else
+ sbs_pdir=${PORTAGE_TMPDIR}
+ fi
+ [[ -z ${sbs_pdir} ]] && sbs_pdir=/var/tmp
+ sbs_pdir=${sbs_pdir}/portage/
+
+ if [[ ${PWD:0:${#sbs_pdir}} == "${sbs_pdir}" ]] ; then
+ sbs_bdir=$(echo ${PWD:${#sbs_pdir}} | cut -d/ -f1)
+ sbs_tmpenvfile=${sbs_pdir}${sbs_bdir}/temp/environment
+ if [[ -e ${sbs_tmpenvfile} ]] ; then
+ echo "Found environment at ${sbs_tmpenvfile}"
+ printf " * Would you like to enter the portage environment ? "
+ read env
+ sbs_PREPWD=${PWD}
+ if [[ ${env} == "y" ]] ; then
+ # First try to source variables and export them ...
+ eval $(sed -e '/^[[:alnum:]_-]*=/s:^:export :' \
+ -e '/^[[:alnum:]_-]* ()/Q' "${sbs_tmpenvfile}") 2>/dev/null
+ # Then grab everything (including functions)
+ source "${sbs_tmpenvfile}" 2> /dev/null
+ export SANDBOX_WRITE=${SANDBOX_WRITE}:${sbs_pdir}${sbs_bdir}:${sbs_pdir}/homedir
+ fi
+ PWD=${sbs_PREPWD}
+ fi
+ fi
+
+ unset sbs_gpdir sbs_cpdir sbs_pdir sbs_bdir sbs_tmpenvfile sbs_PREPWD env
+
+ cd "${PWD}"
+ if [[ ${NOCOLOR} != "true" || ${NOCOLOR} != "yes" || ${NOCOLOR} != "1" ]] ; then
+ export PS1="\e[31;01m[s]\e[0m ${PS1}"
+ else
+ export PS1="[s] ${PS1}"
+ fi
+
+ adddeny() { export SANDBOX_DENY=${SANDBOX_DENY}:$1 ; }
+ addpredict() { export SANDBOX_PREDICT=${SANDBOX_PREDICT}:$1 ; }
+ addread() { export SANDBOX_READ=${SANDBOX_READ}:$1 ; }
+ addwrite() { export SANDBOX_WRITE=${SANDBOX_WRITE}:$1 ; }
+ sandboxon() { export SANDBOX_ON="1" ; }
+ sandboxoff() { export SANDBOX_OFF="0" ; }
+
+ [[ -z ${CCACHE_DIR} ]] && export CCACHE_DIR=/root/.ccache
+ for var in CCACHE_DIR DISTCC_DIR ; do
+ [[ ${!var+set} == "set" ]] && addwrite ${!var}
+ done
+ unset var
+fi
+