4
4
# Also re‑wrap any new scripts post installation by pip etc.
5
5
# shellcheck disable=SC2317
6
6
set -eu
7
+ # shellcheck disable=SC3040
8
+ case " $( set -o) " in * pipefail* ) set -o pipefail ;; esac
7
9
8
10
for arg; do case " $arg " in -h| -\? | --help) echo " Usage: ${0##*/ } [VENV_DIR] [BWRAP_OPTS] # Dir defaults to .venv" ; exit ;; esac ; done
9
11
@@ -60,7 +62,8 @@ import shutil
60
62
import subprocess
61
63
import sys
62
64
if __name__ == '__main__':
63
- subprocess.run([shutil.which('/bin/bash') or '/bin/sh', *sys.argv[1:]])
65
+ shell = shutil.which('/bin/bash') or '/bin/sh'
66
+ sys.exit(subprocess.run([shell, *sys.argv[1:]]).returncode)
64
67
EOF
65
68
}
66
69
@@ -101,6 +104,8 @@ exit 0
101
104
# sandbox-venv: Secure container sandbox venv wrapper (GENERATED CODE)
102
105
# pip wrapper: Re-run sandbox-venv after every pip installation
103
106
set -u
107
+ # shellcheck disable=SC3040
108
+ case " $( set -o) " in * pipefail* ) set -o pipefail ;; esac
104
109
alias realpath=' realpath --no-symlinks'
105
110
106
111
venv=" $( realpath " ${0%/* } /.." ) "
@@ -144,7 +149,8 @@ exit $pip_return_status
144
149
#!/bin/sh
145
150
# sandbox-venv: Secure container sandbox venv wrapper (GENERATED CODE)
146
151
set -eu
147
-
152
+ # shellcheck disable=SC3040
153
+ case " $( set -o) " in *pipefail*) set -o pipefail ;; esac
148
154
alias realpath='realpath --no-symlinks'
149
155
warn () { echo " sandbox-venv/wrapper: $* " >&2; }
150
156
@@ -170,18 +176,23 @@ executables="
170
176
/usr/bin/python3
171
177
172
178
/usr/bin/git
179
+ /usr/bin/git-receive-pack
180
+ /usr/bin/git-upload-archive
181
+ /usr/bin/git-upload-pack
173
182
174
183
/bin/bash
175
184
/bin/env
176
185
/bin/ls
177
- /bin/sh"
186
+ /bin/sh
187
+ /bin/uname
188
+ "
178
189
179
190
case $- in *x*) xtrace=-x ;; *) xtrace=+x ;; esac; set +x
180
191
181
192
# Collect binaries' lib dependencies
182
193
lib_deps () {
183
- readelf -l " $1 " | awk '/interpreter/ {print $NF }' | tr -d '[]'
184
- ldd " $1 " | awk '/=>/ { print $3 }' | { grep -E '^/' || true; }
194
+ { readelf -l " $1 " 2>/dev/null || true; } | awk '/interpreter/ {print $NF }' | tr -d '[]'
195
+ { ldd " $1 " 2>/dev/null || true; } | awk '/=>/ { print $3 }' | { grep -E '^/' || true; }
185
196
}
186
197
collect=" $executables "
187
198
for exe in $executables ; do
193
204
root_so_lib_dirs="
194
205
/usr/lib/python3* /lib-dynload
195
206
/usr/lib64/python3* /lib-dynload"
207
+ # XXX: If some ` git` tools are failing, add $( find /usr/lib/git-core -type f)
196
208
for exe in $( find " $venv /lib" $root_so_lib_dirs -name ' *.so' 2> /dev/null || true) ; do
197
209
collect=" $collect
198
210
$( lib_deps " $exe " ) "
@@ -208,9 +220,14 @@ git_libs="
208
220
/usr/lib* /git-core
209
221
"
210
222
ro_bind_extra="
223
+ /etc/hosts
211
224
/etc/resolv.conf
212
- /usr/share/locale/
225
+
226
+ /etc/ld.so.cache
227
+ /etc/os-release
228
+ /usr/share/locale
213
229
/usr/share/zoneinfo
230
+
214
231
/usr/share/ca-certificates*
215
232
/etc/pki
216
233
/etc/ssl
@@ -281,7 +298,7 @@ set -- --bind "$venv/cache" "$home/.cache" \
281
298
--bind " $pip_cache " " $home /.cache/pip" " $@ "
282
299
283
300
# Pass our own redacted copy of env
284
- for var in $( env | grep -E ' ^(USER|LOGNAME|UID|SHLVL|SHELL| TERM|LANG|LC_.*|HOSTNAME)$ ' ) ; do
301
+ for var in $( env | grep -E ' ^(USER|LOGNAME|UID|PATH| TERM|LANGUAGE| LANG|LC_.*? |HOSTNAME)= ' ) ; do
285
302
set -- --setenv " ${var%% =* } " " ${var#* =} " " $@ "
286
303
done
287
304
0 commit comments