File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -421,6 +421,17 @@ pkgs.nixosTest {
421421 wrap -p bash -c 'test -d "$HOME" -a -w "$HOME" && echo ok' | grep '^ok$' ||
422422 (echo 'Unexpected: $HOME not created or not writable inside sandbox'; false)
423423 """))
424+
425+ with subtest("r/w shared directory is created if it does not exist"):
426+ machine.succeed(as_alice("""
427+ export SOME_DIR=/tmp/some-dir
428+ rm -rf "$SOME_DIR"
429+
430+ wrap -p -e SOME_DIR -r "$SOME_DIR" bash -c 'test -d "$SOME_DIR" && echo ok' | grep '^ok$' ||
431+ (echo 'Unexpected: -r $SOME_DIR does not create directory'; false)
432+ wrap -p -e SOME_DIR -w "$SOME_DIR" bash -c 'test -d "$SOME_DIR" && echo ok' | grep '^ok$' ||
433+ (echo 'Unexpected: -w $SOME_DIR does not create directory'; false)
434+ """))
424435 '' ;
425436}
426437
Original file line number Diff line number Diff line change @@ -179,11 +179,17 @@ while getopts "r:w:e:abcdfhmnpuv" opt; do
179179
180180 # bind / mount a path readonly in sandbox to the same path as host
181181 r)
182+ # Create a directory if the path does not exist
183+ mkdir -p " $OPTARG " || true
184+
182185 bwrap_opts+=(--ro-bind " $OPTARG " " $OPTARG " )
183186 ;;
184187
185188 # bind / mount a path read/write in sandbox to the same path as host
186189 w)
190+ # Create a directory if the path does not exist
191+ mkdir -p " $OPTARG " || true
192+
187193 bwrap_opts+=(--bind " $OPTARG " " $OPTARG " )
188194 ;;
189195
@@ -307,6 +313,7 @@ while getopts "r:w:e:abcdfhmnpuv" opt; do
307313 usage
308314 exit 1
309315 ;;
316+
310317 :)
311318 usage
312319 exit 1
You can’t perform that action at this time.
0 commit comments