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

Contents of /trunk/data/sandbox.bashrc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 321 - (show annotations) (download)
Tue Jul 11 09:36:56 2006 UTC (8 years, 4 months ago) by azarah
File size: 3619 byte(s)
Do not source /etc/profile even in interactive mode.

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 # Only do Mike's sandboxshell mojo if we are interactive, and if
19 # we are connected to a terminal (ie, not piped, etc)
20 if [[ ${SANDBOX_INTRACTV} == "1" && -t 1 ]] ; then
21 trap ":" INT QUIT TSTP
22
23 # Make sure this do not get recusively called
24 unset SANDBOX_INTRACTV
25
26 # Do not set this, as user might want to override path, etc ...
27 #source /etc/profile
28
29 (
30 [[ ${NOCOLOR} == "true" || ${NOCOLOR} == "yes" || ${NOCOLOR} == "1" ]] && \
31 export RC_NOCOLOR="yes"
32 source /sbin/functions.sh
33 echo
34 einfo "Loading sandboxed shell"
35 einfo " Log File: ${SANDBOX_LOG}"
36 if [[ -n ${SANDBOX_DEBUG_LOG} ]] ; then
37 einfo " Debug Log File: ${SANDBOX_DEBUG_LOG}"
38 fi
39 einfo " sandboxon: turn sandbox on"
40 einfo " sandboxoff: turn sandbox off"
41 einfo " addread <path>: allow <path> to be read"
42 einfo " addwrite <path>: allow <path> to be written"
43 einfo " adddeny <path>: deny access to <path>"
44 einfo " addpredict <path>: allow fake access to <path>"
45 echo
46 )
47
48 # do ebuild environment loading ... detect if we're in portage
49 # build area or not ... uNF uNF uNF
50 #sbs_pdir=$(portageq envvar PORTAGE_TMPDIR)/portage/ #portageq takes too long imo
51 if [[ -z ${PORTAGE_TMPDIR} ]] ; then
52 sbs_gpdir=$( source /etc/make.globals && echo $PORTAGE_TMPDIR 2> /dev/null)
53 sbs_cpdir=$( source /etc/make.conf && echo $PORTAGE_TMPDIR 2> /dev/null)
54 [[ -z ${sbs_cpdir} ]] \
55 && sbs_pdir=${sbs_gpdir} \
56 || sbs_pdir=${sbs_cpdir}
57 else
58 sbs_pdir=${PORTAGE_TMPDIR}
59 fi
60 [[ -z ${sbs_pdir} ]] && sbs_pdir=/var/tmp
61 sbs_pdir=${sbs_pdir}/portage/
62
63 if [[ ${PWD:0:${#sbs_pdir}} == "${sbs_pdir}" ]] ; then
64 sbs_bdir=$(echo ${PWD:${#sbs_pdir}} | cut -d/ -f1)
65 sbs_tmpenvfile=${sbs_pdir}${sbs_bdir}/temp/environment
66 if [[ -e ${sbs_tmpenvfile} ]] ; then
67 echo "Found environment at ${sbs_tmpenvfile}"
68 printf " * Would you like to enter the portage environment ? "
69 read env
70 sbs_PREPWD=${PWD}
71 if [[ ${env} == "y" ]] ; then
72 # First try to source variables and export them ...
73 eval $(sed -e '/^[[:alnum:]_-]*=/s:^:export :' \
74 -e '/^[[:alnum:]_-]* ()/Q' "${sbs_tmpenvfile}") 2>/dev/null
75 # Then grab everything (including functions)
76 source "${sbs_tmpenvfile}" 2> /dev/null
77 export SANDBOX_WRITE=${SANDBOX_WRITE}:${sbs_pdir}${sbs_bdir}:${sbs_pdir}/homedir
78 fi
79 PWD=${sbs_PREPWD}
80 fi
81 fi
82
83 unset sbs_gpdir sbs_cpdir sbs_pdir sbs_bdir sbs_tmpenvfile sbs_PREPWD env
84
85 cd "${PWD}"
86 if [[ ${NOCOLOR} != "true" && ${NOCOLOR} != "yes" && ${NOCOLOR} != "1" ]] ; then
87 export PS1="\e[31;01m[s]\e[0m ${PS1}"
88 else
89 export PS1="[s] ${PS1}"
90 fi
91
92 adddeny() { export SANDBOX_DENY=${SANDBOX_DENY}:$1 ; }
93 addpredict() { export SANDBOX_PREDICT=${SANDBOX_PREDICT}:$1 ; }
94 addread() { export SANDBOX_READ=${SANDBOX_READ}:$1 ; }
95 addwrite() { export SANDBOX_WRITE=${SANDBOX_WRITE}:$1 ; }
96 sandboxon() { export SANDBOX_ON="1" ; }
97 sandboxoff() { export SANDBOX_OFF="0" ; }
98
99 [[ -z ${CCACHE_DIR} ]] && export CCACHE_DIR=/root/.ccache
100 for var in CCACHE_DIR DISTCC_DIR ; do
101 [[ ${!var+set} == "set" ]] && addwrite ${!var}
102 done
103 unset var
104 fi

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.20