Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions demos/userns-block-fd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash
# This is an example of using the userns-block feature with bash.

# info pipe
exec 10<> <(:)
# userns_block pipe
exec 11<> <(:)

userns_setup() {
child_pid=$(jq -rn 'input | .["child-pid"]' <&10)
newuidmap $child_pid 0 $(id -u) 1
newgidmap $child_pid 0 $(id -g) 1
echo 1 >&11
exec 11>&-
}
userns_setup 10<&10 11>&11 &

bwrap \
--unshare-all \
--unshare-user \
--userns-block-fd 11 \
--info-fd 10 \
--bind / / \
cat /proc/self/uid_map \
10>&10 11<&11