| @@ -1,16 +1,16 @@ | | | @@ -1,16 +1,16 @@ |
1 | #! /bin/sh | | 1 | #! /bin/sh |
2 | | | 2 | |
3 | # $NetBSD: mksandbox,v 1.53 2012/01/15 13:34:28 ryoon Exp $ | | 3 | # $NetBSD: mksandbox,v 1.54 2012/07/03 12:05:40 jperkin Exp $ |
4 | # | | 4 | # |
5 | # | | 5 | # |
6 | # Copyright (c) 2002 Alistair G. Crooks. All rights reserved. | | 6 | # Copyright (c) 2002 Alistair G. Crooks. All rights reserved. |
7 | # | | 7 | # |
8 | # Redistribution and use in source and binary forms, with or without | | 8 | # Redistribution and use in source and binary forms, with or without |
9 | # modification, are permitted provided that the following conditions | | 9 | # modification, are permitted provided that the following conditions |
10 | # are met: | | 10 | # are met: |
11 | # 1. Redistributions of source code must retain the above copyright | | 11 | # 1. Redistributions of source code must retain the above copyright |
12 | # notice, this list of conditions and the following disclaimer. | | 12 | # notice, this list of conditions and the following disclaimer. |
13 | # 2. Redistributions in binary form must reproduce the above copyright | | 13 | # 2. Redistributions in binary form must reproduce the above copyright |
14 | # notice, this list of conditions and the following disclaimer in the | | 14 | # notice, this list of conditions and the following disclaimer in the |
15 | # documentation and/or other materials provided with the distribution. | | 15 | # documentation and/or other materials provided with the distribution. |
16 | # 3. All advertising materials mentioning features or use of this software | | 16 | # 3. All advertising materials mentioning features or use of this software |
| @@ -41,54 +41,57 @@ | | | @@ -41,54 +41,57 @@ |
41 | | | 41 | |
42 | pkgsrc=/usr/pkgsrc | | 42 | pkgsrc=/usr/pkgsrc |
43 | src=/usr/src | | 43 | src=/usr/src |
44 | xsrc=/usr/xsrc | | 44 | xsrc=/usr/xsrc |
45 | with_x=yes | | 45 | with_x=yes |
46 | | | 46 | |
47 | kernel="" | | 47 | kernel="" |
48 | sandboxMountDirs="/bin /sbin /lib /libexec /usr/X11R7 /usr/bin /usr/games /usr/include /usr/lib /usr/libdata /usr/libexec /usr/lkm /usr/share /usr/sbin /var/mail" | | 48 | sandboxMountDirs="/bin /sbin /lib /libexec /usr/X11R7 /usr/bin /usr/games /usr/include /usr/lib /usr/libdata /usr/libexec /usr/lkm /usr/share /usr/sbin /var/mail" |
49 | sandboxEmptyDirs="/var/run /var/log /var/spool/lock /var/spool/mqueue" | | 49 | sandboxEmptyDirs="/var/run /var/log /var/spool/lock /var/spool/mqueue" |
50 | sandboxEmptyFiles="/var/run/utmp /var/run/utmpx /var/log/wtmp /var/log/wtmpx /var/log/lastlog /var/log/lastlogx" | | 50 | sandboxEmptyFiles="/var/run/utmp /var/run/utmpx /var/log/wtmp /var/log/wtmpx /var/log/lastlog /var/log/lastlogx" |
51 | | | 51 | |
52 | usage() | | 52 | usage() |
53 | { | | 53 | { |
54 | echo "Usage: mksandbox [--pkgsrc=dir] [--src=srcdir] [--xsrc=xsrcdir] [--without-x] [--verbose] sandbox-dir" | | 54 | echo "Usage: mksandbox [--mounthost=host] [--pkgsrc=dir] [--src=srcdir] [--xsrc=xsrcdir] [--without-x] [--verbose] sandbox-dir" |
55 | exit 1 | | 55 | exit 1 |
56 | } | | 56 | } |
57 | | | 57 | |
58 | err() | | 58 | err() |
59 | { | | 59 | { |
60 | echo "error: $1" | | 60 | echo "error: $1" |
61 | exit 1 | | 61 | exit 1 |
62 | } | | 62 | } |
63 | | | 63 | |
64 | # by default, don't require src and xsrc to be available | | 64 | # by default, don't require src and xsrc to be available |
65 | need_src=no | | 65 | need_src=no |
66 | need_xsrc=no | | 66 | need_xsrc=no |
67 | | | 67 | |
68 | opsys=`uname -s` | | 68 | opsys=`uname -s` |
69 | case "$opsys" in | | 69 | case "$opsys" in |
70 | Darwin) | | 70 | Darwin) |
71 | bmakeprog=bmake | | 71 | bmakeprog=bmake |
72 | chmodprog=/bin/chmod | | 72 | chmodprog=/bin/chmod |
73 | chownprog=/usr/sbin/chown | | 73 | chownprog=/usr/sbin/chown |
74 | cpprog=/bin/cp | | 74 | cpprog=/bin/cp |
75 | gtarprog=/usr/bin/gnutar | | 75 | gtarprog=/usr/bin/gnutar |
76 | idprog=/usr/bin/id | | 76 | idprog=/usr/bin/id |
77 | mkdirprog="/bin/mkdir -p" | | 77 | mkdirprog="/bin/mkdir -p" |
78 | mountflags="-t null" | | 78 | mountflags="-t nfs" |
| | | 79 | mounthost="localhost" |
79 | mountprog=/sbin/mount | | 80 | mountprog=/sbin/mount |
80 | paxprog=/bin/pax | | 81 | paxprog=/bin/pax |
81 | sedprog=/usr/bin/sed | | 82 | sedprog=/usr/bin/sed |
| | | 83 | sandboxEmptyDirs="$sandboxEmptyDirs /var/root" |
| | | 84 | sandboxMountDirs="$sandboxMountDirs /usr/llvm-gcc-4.2 /System/Library /Library" |
82 | ;; | | 85 | ;; |
83 | FreeBSD) | | 86 | FreeBSD) |
84 | bmakeprog=bmake | | 87 | bmakeprog=bmake |
85 | chmodprog=/bin/chmod | | 88 | chmodprog=/bin/chmod |
86 | chownprog=/usr/sbin/chown | | 89 | chownprog=/usr/sbin/chown |
87 | cpprog=/bin/cp | | 90 | cpprog=/bin/cp |
88 | gtarprog=/usr/bin/tar | | 91 | gtarprog=/usr/bin/tar |
89 | idprog=/usr/bin/id | | 92 | idprog=/usr/bin/id |
90 | mkdirprog="/bin/mkdir -p" | | 93 | mkdirprog="/bin/mkdir -p" |
91 | mountflags="-t nullfs" | | 94 | mountflags="-t nullfs" |
92 | mountprog=/sbin/mount | | 95 | mountprog=/sbin/mount |
93 | paxprog=/bin/pax | | 96 | paxprog=/bin/pax |
94 | sedprog=/usr/bin/sed | | 97 | sedprog=/usr/bin/sed |
| @@ -155,75 +158,82 @@ SunOS) | | | @@ -155,75 +158,82 @@ SunOS) |
155 | cpprog=cp | | 158 | cpprog=cp |
156 | gtarprog="tar" | | 159 | gtarprog="tar" |
157 | idprog="id" | | 160 | idprog="id" |
158 | mkdirprog="mkdir -p" | | 161 | mkdirprog="mkdir -p" |
159 | mountflags="-t null" | | 162 | mountflags="-t null" |
160 | mountprog=mount | | 163 | mountprog=mount |
161 | paxprog=pax | | 164 | paxprog=pax |
162 | sedprog=sed | | 165 | sedprog=sed |
163 | ;; | | 166 | ;; |
164 | esac | | 167 | esac |
165 | | | 168 | |
166 | while [ $# -gt 0 ]; do | | 169 | while [ $# -gt 0 ]; do |
167 | case "$1" in | | 170 | case "$1" in |
| | | 171 | --mounthost=*) mounthost=`echo $1 | $sedprog -e 's|^--mounthost=||'` ;; |
168 | --pkgsrc=*) pkgsrc=`echo $1 | $sedprog -e 's|^--pkgsrc=||'` ;; | | 172 | --pkgsrc=*) pkgsrc=`echo $1 | $sedprog -e 's|^--pkgsrc=||'` ;; |
169 | --src=*) src=`echo $1 | $sedprog -e 's|^--src=||'` ;; | | 173 | --src=*) src=`echo $1 | $sedprog -e 's|^--src=||'` ;; |
170 | --xsrc=*) xsrc=`echo $1 | $sedprog -e 's|^--xsrc=||'` ;; | | 174 | --xsrc=*) xsrc=`echo $1 | $sedprog -e 's|^--xsrc=||'` ;; |
171 | --without-x) with_x=no ;; | | 175 | --without-x) with_x=no ;; |
172 | --verbose) set -x ;; | | 176 | --verbose) set -x ;; |
173 | -*) usage ;; | | 177 | -*) usage ;; |
174 | *) break ;; | | 178 | *) break ;; |
175 | esac | | 179 | esac |
176 | shift | | 180 | shift |
177 | done | | 181 | done |
178 | | | 182 | |
179 | if [ $# -ne 1 ]; then | | 183 | if [ $# -ne 1 ]; then |
180 | usage | | 184 | usage |
181 | fi | | 185 | fi |
182 | | | 186 | |
183 | if [ "$with_x" = "no" ]; then | | 187 | if [ "$with_x" = "no" ]; then |
184 | need_xsrc=no | | 188 | need_xsrc=no |
185 | fi | | 189 | fi |
186 | | | 190 | |
187 | if [ `$idprog -u` -ne 0 ]; then | | 191 | if [ `$idprog -u` -ne 0 ]; then |
188 | err "You must be root to run this script." | | 192 | err "You must be root to run this script." |
189 | fi | | 193 | fi |
190 | | | 194 | |
| | | 195 | if [ -n "$mounthost" ]; then |
| | | 196 | mounthost="$mounthost:" |
| | | 197 | fi |
| | | 198 | |
191 | if [ ! -d $pkgsrc ]; then | | 199 | if [ ! -d $pkgsrc ]; then |
192 | err "pkgsrc directory $pkgsrc does not exist." | | 200 | err "pkgsrc directory $pkgsrc does not exist." |
193 | fi | | 201 | fi |
194 | | | 202 | |
195 | if [ ! -d $src -a "$need_src" = "yes" ]; then | | 203 | if [ ! -d $src -a "$need_src" = "yes" ]; then |
196 | err "source directory $src does not exist." | | 204 | err "source directory $src does not exist." |
197 | fi | | 205 | fi |
198 | | | 206 | |
199 | if [ ! -d $xsrc -a "$need_xsrc" = "yes" ]; then | | 207 | if [ ! -d $xsrc -a "$need_xsrc" = "yes" ]; then |
200 | err "xsrc directory $xsrc does not exist." | | 208 | err "xsrc directory $xsrc does not exist." |
201 | fi | | 209 | fi |
202 | | | 210 | |
203 | sandbox=$1 | | 211 | sandbox=$1 |
204 | sandbox_script="$sandbox/sandbox" | | 212 | sandbox_script="$sandbox/sandbox" |
205 | | | 213 | |
206 | packages=`(cd $pkgsrc/pkgtools/lintpkgsrc; $bmakeprog show-var VARNAME=PACKAGES)` | | 214 | packages=`(cd $pkgsrc/pkgtools/lintpkgsrc; $bmakeprog show-var VARNAME=PACKAGES)` |
207 | distfiles=`(cd $pkgsrc/pkgtools/lintpkgsrc; $bmakeprog show-var VARNAME=DISTDIR)` | | 215 | distfiles=`(cd $pkgsrc/pkgtools/lintpkgsrc; $bmakeprog show-var VARNAME=DISTDIR)` |
208 | localbase=`(cd $pkgsrc/pkgtools/lintpkgsrc; $bmakeprog show-var VARNAME=LOCALBASE)` | | 216 | localbase=`(cd $pkgsrc/pkgtools/lintpkgsrc; $bmakeprog show-var VARNAME=LOCALBASE)` |
209 | pkg_dbdir=`(cd $pkgsrc/pkgtools/lintpkgsrc; $bmakeprog show-var VARNAME=PKG_DBDIR)` | | 217 | pkg_dbdir=`(cd $pkgsrc/pkgtools/lintpkgsrc; $bmakeprog show-var VARNAME=PKG_DBDIR)` |
210 | localpatches=`(cd $pkgsrc/pkgtools/lintpkgsrc; $bmakeprog show-var VARNAME=LOCALPATCHES)` | | 218 | localpatches=`(cd $pkgsrc/pkgtools/lintpkgsrc; $bmakeprog show-var VARNAME=LOCALPATCHES)` |
211 | | | 219 | |
212 | test -d "$localpatches" || echo "WARNING: LOCALPATCHES directory does not exist - ignoring" | | 220 | test -d "$localpatches" || echo "WARNING: LOCALPATCHES directory does not exist - ignoring" |
213 | | | 221 | |
214 | $mkdirprog $sandbox | | 222 | $mkdirprog $sandbox |
215 | cat > $sandbox_script <<EOS | | 223 | cat > $sandbox_script <<EOS |
216 | #! /bin/sh - | | 224 | #! /bin/sh - |
| | | 225 | mounthost=$mounthost |
| | | 226 | opsys=$opsys |
217 | sandbox=$sandbox | | 227 | sandbox=$sandbox |
218 | | | 228 | |
219 | r3() { | | 229 | r3() { |
220 | _R= | | 230 | _R= |
221 | while [ \$# -ge 3 ] | | 231 | while [ \$# -ge 3 ] |
222 | do | | 232 | do |
223 | _R="\$1 \$2 \$3 \$_R" | | 233 | _R="\$1 \$2 \$3 \$_R" |
224 | shift; shift; shift | | 234 | shift; shift; shift |
225 | done | | 235 | done |
226 | echo "\$_R" | | 236 | echo "\$_R" |
227 | } | | 237 | } |
228 | | | 238 | |
229 | fses="\\ | | 239 | fses="\\ |
| @@ -231,38 +241,38 @@ EOS | | | @@ -231,38 +241,38 @@ EOS |
231 | | | 241 | |
232 | if [ ! -z "$kernel" ]; then | | 242 | if [ ! -z "$kernel" ]; then |
233 | echo "Copying the kernel" | | 243 | echo "Copying the kernel" |
234 | $cpprog $kernel $sandbox | | 244 | $cpprog $kernel $sandbox |
235 | fi | | 245 | fi |
236 | | | 246 | |
237 | echo "Checking package hierarchy in $localbase and package database in $pkg_dbdir exist" | | 247 | echo "Checking package hierarchy in $localbase and package database in $pkg_dbdir exist" |
238 | $mkdirprog $sandbox/$localbase $sandbox/$pkg_dbdir | | 248 | $mkdirprog $sandbox/$localbase $sandbox/$pkg_dbdir |
239 | | | 249 | |
240 | echo "Make and populate $sandbox/dev" | | 250 | echo "Make and populate $sandbox/dev" |
241 | $mkdirprog $sandbox/dev | | 251 | $mkdirprog $sandbox/dev |
242 | | | 252 | |
243 | case "$opsys" in | | 253 | case "$opsys" in |
| | | 254 | Darwin|FreeBSD) |
| | | 255 | $mountprog -t devfs devfs $sandbox/dev |
| | | 256 | ;; |
244 | SunOS) | | 257 | SunOS) |
245 | /usr/sbin/devfsadm -r $sandbox | | 258 | /usr/sbin/devfsadm -r $sandbox |
246 | if [ -f /usr/ucblib/ucblinks.awk -a -x /usr/ucb/ucblinks ]; then | | 259 | if [ -f /usr/ucblib/ucblinks.awk -a -x /usr/ucb/ucblinks ]; then |
247 | /usr/ucb/ucblinks -r $sandbox | | 260 | /usr/ucb/ucblinks -r $sandbox |
248 | fi | | 261 | fi |
249 | ;; | | 262 | ;; |
250 | Linux) | | 263 | Linux) |
251 | $mountprog $mountflags /dev $sandbox/dev | | 264 | $mountprog $mountflags /dev $sandbox/dev |
252 | ;; | | 265 | ;; |
253 | FreeBSD) | | | |
254 | $mountprog -t devfs devfs $sandbox/dev | | | |
255 | ;; | | | |
256 | *) | | 266 | *) |
257 | $cpprog /dev/MAKEDEV* $sandbox/dev | | 267 | $cpprog /dev/MAKEDEV* $sandbox/dev |
258 | (cd $sandbox/dev; ./MAKEDEV all) | | 268 | (cd $sandbox/dev; ./MAKEDEV all) |
259 | esac | | 269 | esac |
260 | | | 270 | |
261 | echo "Make and populate $sandbox/etc" | | 271 | echo "Make and populate $sandbox/etc" |
262 | $mkdirprog $sandbox/etc | | 272 | $mkdirprog $sandbox/etc |
263 | case "$paxprog" in | | 273 | case "$paxprog" in |
264 | "") (cd /etc; $gtarprog -cf - . | (cd $sandbox/etc; $gtarprog xf - )) ;; | | 274 | "") (cd /etc; $gtarprog -cf - . | (cd $sandbox/etc; $gtarprog xf - )) ;; |
265 | *) (cd /etc; $paxprog -rwpe . $sandbox/etc) ;; | | 275 | *) (cd /etc; $paxprog -rwpe . $sandbox/etc) ;; |
266 | esac | | 276 | esac |
267 | rm -f $sandbox/etc/localtime | | 277 | rm -f $sandbox/etc/localtime |
268 | | | 278 | |
| @@ -272,28 +282,28 @@ SunOS) | | | @@ -272,28 +282,28 @@ SunOS) |
272 | ;; | | 282 | ;; |
273 | *) | | 283 | *) |
274 | $cpprog /usr/share/zoneinfo/GMT $sandbox/etc/localtime | | 284 | $cpprog /usr/share/zoneinfo/GMT $sandbox/etc/localtime |
275 | ;; | | 285 | ;; |
276 | esac | | 286 | esac |
277 | | | 287 | |
278 | echo "Make empty dirs upon which to mount the null mounts" | | 288 | echo "Make empty dirs upon which to mount the null mounts" |
279 | for d in $sandboxMountDirs; do | | 289 | for d in $sandboxMountDirs; do |
280 | test -d $d || continue; | | 290 | test -d $d || continue; |
281 | case $d in | | 291 | case $d in |
282 | *X11*) test "$with_x" = "yes" || continue ;; | | 292 | *X11*) test "$with_x" = "yes" || continue ;; |
283 | esac | | 293 | esac |
284 | $mkdirprog $sandbox$d; | | 294 | $mkdirprog $sandbox$d; |
285 | $mountprog $mountflags -r $d $sandbox$d; | | 295 | $mountprog $mountflags -r $mounthost$d $sandbox$d; |
286 | echo "$d $d ro \\" >> $sandbox_script | | 296 | echo "$mounthost$d $d ro \\" >> $sandbox_script |
287 | done | | 297 | done |
288 | | | 298 | |
289 | echo "Making /tmp in $sandbox" | | 299 | echo "Making /tmp in $sandbox" |
290 | $mkdirprog $sandbox/tmp $sandbox/var/tmp | | 300 | $mkdirprog $sandbox/tmp $sandbox/var/tmp |
291 | $chmodprog 1777 $sandbox/tmp $sandbox/var/tmp | | 301 | $chmodprog 1777 $sandbox/tmp $sandbox/var/tmp |
292 | | | 302 | |
293 | echo "Making /var/games in $sandbox" | | 303 | echo "Making /var/games in $sandbox" |
294 | $mkdirprog $sandbox/var/games | | 304 | $mkdirprog $sandbox/var/games |
295 | $chownprog games:games $sandbox/var/games | | 305 | $chownprog games:games $sandbox/var/games |
296 | $chmodprog 2775 $sandbox/var/games | | 306 | $chmodprog 2775 $sandbox/var/games |
297 | | | 307 | |
298 | for d in $sandboxEmptyDirs; do | | 308 | for d in $sandboxEmptyDirs; do |
299 | test -d $d || continue | | 309 | test -d $d || continue |
| @@ -306,98 +316,115 @@ for f in $sandboxEmptyFiles; do | | | @@ -306,98 +316,115 @@ for f in $sandboxEmptyFiles; do |
306 | echo "Making $f in $sandbox" | | 316 | echo "Making $f in $sandbox" |
307 | $cpprog /dev/null $sandbox$f | | 317 | $cpprog /dev/null $sandbox$f |
308 | done | | 318 | done |
309 | | | 319 | |
310 | if [ "$need_src" = "yes" ]; then | | 320 | if [ "$need_src" = "yes" ]; then |
311 | echo "Mount $src from $sandbox" | | 321 | echo "Mount $src from $sandbox" |
312 | $mkdirprog $sandbox/usr/src | | 322 | $mkdirprog $sandbox/usr/src |
313 | $mountprog $mountflags -r $src $sandbox/usr/src | | 323 | $mountprog $mountflags -r $src $sandbox/usr/src |
314 | echo "$src /usr/src ro \\" >> $sandbox_script | | 324 | echo "$src /usr/src ro \\" >> $sandbox_script |
315 | fi | | 325 | fi |
316 | | | 326 | |
317 | echo "Mount $pkgsrc from $sandbox" | | 327 | echo "Mount $pkgsrc from $sandbox" |
318 | $mkdirprog $sandbox/usr/pkgsrc | | 328 | $mkdirprog $sandbox/usr/pkgsrc |
319 | $mountprog $mountflags $pkgsrc $sandbox/usr/pkgsrc | | 329 | $mountprog $mountflags $mounthost$pkgsrc $sandbox/usr/pkgsrc |
320 | echo "$pkgsrc /usr/pkgsrc rw \\" >> $sandbox_script | | 330 | echo "$mounthost$pkgsrc /usr/pkgsrc rw \\" >> $sandbox_script |
321 | | | 331 | |
322 | if [ "$need_xsrc" = "yes" ]; then | | 332 | if [ "$need_xsrc" = "yes" ]; then |
323 | echo "Mount $xsrc from $sandbox" | | 333 | echo "Mount $xsrc from $sandbox" |
324 | $mkdirprog $sandbox/usr/xsrc | | 334 | $mkdirprog $sandbox/usr/xsrc |
325 | $mountprog $mountflags -r $xsrc $sandbox/usr/xsrc | | 335 | $mountprog $mountflags -r $xsrc $sandbox/usr/xsrc |
326 | echo "$xsrc /usr/xsrc ro \\" >> $sandbox_script | | 336 | echo "$xsrc /usr/xsrc ro \\" >> $sandbox_script |
327 | fi | | 337 | fi |
328 | | | 338 | |
329 | echo "Mounting $packages and $distfiles from $sandbox" | | 339 | echo "Mounting $packages and $distfiles from $sandbox" |
330 | $mkdirprog $sandbox/$packages $sandbox/$distfiles | | 340 | $mkdirprog $sandbox/$packages $sandbox/$distfiles |
331 | $mkdirprog $packages $distfiles | | 341 | $mkdirprog $packages $distfiles |
332 | $mountprog $mountflags $packages $sandbox/$packages | | 342 | $mountprog $mountflags $mounthost$packages $sandbox/$packages |
333 | $mountprog $mountflags $distfiles $sandbox/$distfiles | | 343 | $mountprog $mountflags $mounthost$distfiles $sandbox/$distfiles |
334 | echo "$packages $packages rw \\" >> $sandbox_script | | 344 | echo "$mounthost$packages $packages rw \\" >> $sandbox_script |
335 | echo "$distfiles $distfiles rw \\" >> $sandbox_script | | 345 | echo "$mounthost$distfiles $distfiles rw \\" >> $sandbox_script |
336 | | | 346 | |
337 | if [ -n "$localpatches" ] && [ -d "$localpatches" ]; then | | 347 | if [ -n "$localpatches" ] && [ -d "$localpatches" ]; then |
338 | echo "Mounting $localpatches from $sandbox" | | 348 | echo "Mounting $localpatches from $sandbox" |
339 | $mkdirprog $sandbox/$localpatches | | 349 | $mkdirprog $sandbox/$localpatches |
340 | $mountprog $mountflags $localpatches $sandbox/$localpatches | | 350 | $mountprog $mountflags $localpatches $sandbox/$localpatches |
341 | echo "$localpatches $localpatches rw \\" >> $sandbox_script | | 351 | echo "$localpatches $localpatches rw \\" >> $sandbox_script |
342 | fi | | 352 | fi |
343 | | | 353 | |
344 | cat >> $sandbox_script <<EOS | | 354 | cat >> $sandbox_script <<EOS |
345 | " | | 355 | " |
346 | case x\$1 in | | 356 | case x\$1 in |
347 | xmount) | | 357 | xmount) |
348 | set dummy \$fses | | 358 | set dummy \$fses |
349 | shift | | 359 | shift |
350 | while [ \$# -ge 3 ]; do | | 360 | while [ \$# -ge 3 ]; do |
351 | fs=\$1; shift | | 361 | fs=\$1; shift |
352 | mntpoint=\$1; shift | | 362 | mntpoint=\$1; shift |
353 | rwro=\$1; shift | | 363 | rwro=\$1; shift |
354 | case \$rwro in | | 364 | case \$rwro in |
355 | ro) mount $mountflags -r \$fs \$sandbox/\$mntpoint || exit 1 ;; | | 365 | ro) $mountprog $mountflags -r \$fs \$sandbox/\$mntpoint || exit 1 ;; |
356 | rw) mount $mountflags \$fs \$sandbox/\$mntpoint || exit 1 ;; | | 366 | rw) $mountprog $mountflags \$fs \$sandbox/\$mntpoint || exit 1 ;; |
357 | esac | | 367 | esac |
358 | done | | 368 | done |
| | | 369 | case \$opsys in |
| | | 370 | Darwin|FreeBSD) |
| | | 371 | $mountprog -t devfs devfs \$sandbox/dev |
| | | 372 | ;; |
| | | 373 | Linux) |
| | | 374 | $mountprog $mountflags /dev \$sandbox/dev |
| | | 375 | ;; |
| | | 376 | esac |
359 | ;; | | 377 | ;; |
360 | xumount) | | 378 | xumount) |
361 | set dummy \`r3 \$fses\` | | 379 | set dummy \`r3 \$fses\` |
362 | shift | | 380 | shift |
363 | while [ \$# -ge 3 ]; do | | 381 | while [ \$# -ge 3 ]; do |
364 | fs=\$1; shift | | 382 | fs=\$1; shift |
365 | mntpoint=\$1; shift | | 383 | mntpoint=\$1; shift |
366 | dummy=\$1; shift | | 384 | dummy=\$1; shift |
367 | umount \$sandbox/\$mntpoint | | 385 | umount \$sandbox/\$mntpoint |
368 | done | | 386 | done |
| | | 387 | case \$opsys in |
| | | 388 | Darwin|FreeBSD|Linux) |
| | | 389 | umount \$sandbox/dev |
| | | 390 | ;; |
| | | 391 | esac |
369 | ;; | | 392 | ;; |
370 | xchroot) | | 393 | xchroot) |
371 | case x\$2 in | | 394 | case x\$2 in |
372 | x) rootshell=/bin/ksh ;; | | 395 | x) rootshell=/bin/ksh ;; |
373 | *) rootshell="\$2" ;; | | 396 | *) rootshell="\$2" ;; |
374 | esac | | 397 | esac |
375 | script="\$sandbox/tmp/script.\$\$" | | 398 | script="\$sandbox/tmp/script.\$\$" |
376 | echo "#!/bin/sh" > \$script | | 399 | echo "#!/bin/sh" > \$script |
377 | echo "ENV=/etc/shrc \$rootshell" >> \$script | | 400 | echo "ENV=/etc/shrc \$rootshell" >> \$script |
378 | chmod +x \$script | | 401 | chmod +x \$script |
379 | ENV=/etc/shrc chroot \$sandbox /tmp/\`basename \$script\` | | 402 | ENV=/etc/shrc chroot \$sandbox /tmp/\`basename \$script\` |
380 | rm -f \$script | | 403 | rm -f \$script |
381 | ;; | | 404 | ;; |
382 | *) | | 405 | *) |
383 | if [ \$# -eq 0 ]; then | | 406 | if [ \$# -eq 0 ]; then |
384 | set dummy /bin/sh | | 407 | set dummy /bin/sh |
385 | shift | | 408 | shift |
386 | fi | | 409 | fi |
387 | chroot \$sandbox "\$@" | | 410 | chroot \$sandbox "\$@" |
388 | ;; | | 411 | ;; |
389 | esac | | 412 | esac |
390 | EOS | | 413 | EOS |
391 | | | 414 | |
392 | chmod +x $sandbox_script | | 415 | chmod +x $sandbox_script |
393 | | | 416 | |
394 | case $opsys in | | 417 | case $opsys in |
| | | 418 | Darwin) |
| | | 419 | $cpprog /var/run/resolv.conf $sandbox/var/run/resolv.conf |
| | | 420 | $cpprog /mach_kernel $sandbox/mach_kernel |
| | | 421 | ;; |
395 | SunOS) | | 422 | SunOS) |
396 | $cpprog /etc/mnttab $sandbox/etc/mnttab | | 423 | $cpprog /etc/mnttab $sandbox/etc/mnttab |
397 | ;; | | 424 | ;; |
398 | *) | | 425 | *) |
399 | esac | | 426 | esac |
400 | | | 427 | |
401 | echo "Sandbox creation is now complete" | | 428 | echo "Sandbox creation is now complete" |
402 | | | 429 | |
403 | exit 0 | | 430 | exit 0 |