/[path-sandbox]/trunk/data/sandbox.bashrc
Gentoo

Contents of /trunk/data/sandbox.bashrc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 284 - (show annotations) (download)
Thu Jul 6 09:27:39 2006 UTC (11 years, 9 months ago) by azarah
File size: 3354 byte(s)
Fixup color handling.

1 # Copyright (C) 2001 Geert Bevin, Uwyn, http://www.uwyn.com
2 # Distributed under the terms of the GNU General Public License, v2 or later
3 # $Header$
4
5 if [[ -n ${LD_PRELOAD} && ${LD_PRELOAD} != *$SANDBOX_LIB* ]] ; then
6 export LD_PRELOAD="${SANDBOX_LIB} ${LD_PRELOAD}"
7 elif [[ -z ${LD_PRELOAD} ]] ; then
8 export LD_PRELOAD="${SANDBOX_LIB}"
9 fi
10
11 export BASH_ENV="${SANDBOX_BASHRC}"
12
13 alias make="make LD_PRELOAD=${LD_PRELOAD}"
14 alias su="su -c '/bin/bash -rcfile ${SANDBOX_BASHRC}'"
15
16 declare -r SANDBOX_ACTIVE
17
18 if [[ ${SANDBOX_INTRACTV} == "1" ]] ; then
19 trap ":" INT QUIT TSTP
20
21 source /etc/profile
22
23 (
24 [[ ${NOCOLOR} == "true" || ${NOCOLOR} == "yes" || ${NOCOLOR} == "1" ]] && \
25 export RC_NOCOLOR="yes"
26 source /sbin/functions.sh
27 echo
28 einfo "Loading sandboxed shell"
29 einfo " Log File: ${SANDBOX_LOG}"
30 if [[ -n ${SANDBOX_DEBUG_LOG} ]] ; then
31 einfo " Debug Log File: ${SANDBOX_DEBUG_LOG}"
32 fi
33 einfo " sandboxon: turn sandbox on"
34 einfo " sandboxoff: turn sandbox off"
35 einfo " addread <path>: allow <path> to be read"
36 einfo " addwrite <path>: allow <path> to be written"
37 einfo " adddeny <path>: deny access to <path>"
38 einfo " addpredict <path>: allow fake access to <path>"
39 echo
40 )
41
42 # do ebuild environment loading ... detect if we're in portage
43 # build area or not ... uNF uNF uNF
44 #sbs_pdir=$(portageq envvar PORTAGE_TMPDIR)/portage/ #portageq takes too long imo
45 if [[ -z ${PORTAGE_TMPDIR} ]] ; then
46 sbs_gpdir=$( source /etc/make.globals && echo $PORTAGE_TMPDIR 2> /dev/null)
47 sbs_cpdir=$( source /etc/make.conf && echo $PORTAGE_TMPDIR 2> /dev/null)
48 [[ -z ${sbs_cpdir} ]] \
49 && sbs_pdir=${sbs_gpdir} \
50 || sbs_pdir=${sbs_cpdir}
51 else
52 sbs_pdir=${PORTAGE_TMPDIR}
53 fi
54 [[ -z ${sbs_pdir} ]] && sbs_pdir=/var/tmp
55 sbs_pdir=${sbs_pdir}/portage/
56
57 if [[ ${PWD:0:${#sbs_pdir}} == "${sbs_pdir}" ]] ; then
58 sbs_bdir=$(echo ${PWD:${#sbs_pdir}} | cut -d/ -f1)
59 sbs_tmpenvfile=${sbs_pdir}${sbs_bdir}/temp/environment
60 if [[ -e ${sbs_tmpenvfile} ]] ; then
61 echo "Found environment at ${sbs_tmpenvfile}"
62 printf " * Would you like to enter the portage environment ? "
63 read env
64 sbs_PREPWD=${PWD}
65 if [[ ${env} == "y" ]] ; then
66 # First try to source variables and export them ...
67 eval $(sed -e '/^[[:alnum:]_-]*=/s:^:export :' \
68 -e '/^[[:alnum:]_-]* ()/Q' "${sbs_tmpenvfile}") 2>/dev/null
69 # Then grab everything (including functions)
70 source "${sbs_tmpenvfile}" 2> /dev/null
71 export SANDBOX_WRITE=${SANDBOX_WRITE}:${sbs_pdir}${sbs_bdir}:${sbs_pdir}/homedir
72 fi
73 PWD=${sbs_PREPWD}
74 fi
75 fi
76
77 unset sbs_gpdir sbs_cpdir sbs_pdir sbs_bdir sbs_tmpenvfile sbs_PREPWD env
78
79 cd "${PWD}"
80 if [[ ${NOCOLOR} != "true" && ${NOCOLOR} != "yes" && ${NOCOLOR} != "1" ]] ; then
81 export PS1="\e[31;01m[s]\e[0m ${PS1}"
82 else
83 export PS1="[s] ${PS1}"
84 fi
85
86 adddeny() { export SANDBOX_DENY=${SANDBOX_DENY}:$1 ; }
87 addpredict() { export SANDBOX_PREDICT=${SANDBOX_PREDICT}:$1 ; }
88 addread() { export SANDBOX_READ=${SANDBOX_READ}:$1 ; }
89 addwrite() { export SANDBOX_WRITE=${SANDBOX_WRITE}:$1 ; }
90 sandboxon() { export SANDBOX_ON="1" ; }
91 sandboxoff() { export SANDBOX_OFF="0" ; }
92
93 [[ -z ${CCACHE_DIR} ]] && export CCACHE_DIR=/root/.ccache
94 for var in CCACHE_DIR DISTCC_DIR ; do
95 [[ ${!var+set} == "set" ]] && addwrite ${!var}
96 done
97 unset var
98 fi

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.20