Skip to content

Commit 465c349

Browse files
committed
Added bash demo for userns-block-fd
1 parent 4a7bb29 commit 465c349

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

demos/userns-block-fd.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
# This is an example of using the userns-block feature with bash.
3+
4+
# info pipe
5+
exec 10<> <(:)
6+
# userns_block pipe
7+
exec 11<> <(:)
8+
9+
userns_setup() {
10+
child_pid=$(jq -rn 'input | .["child-pid"]' <&10)
11+
newuidmap $child_pid 0 $(id -u) 1
12+
newgidmap $child_pid 0 $(id -g) 1
13+
echo 1 >&11
14+
exec 11>&-
15+
}
16+
userns_setup 10<&10 11>&11 &
17+
18+
bwrap \
19+
--unshare-all \
20+
--unshare-user \
21+
--userns-block-fd 11 \
22+
--info-fd 10 \
23+
--bind / / \
24+
cat /proc/self/uid_map \
25+
10>&10 11<&11

0 commit comments

Comments
 (0)