Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Meißner
Scripts
Commits
27a23148
Commit
27a23148
authored
Feb 21, 2023
by
Florian Meißner
Browse files
Options
Downloads
Patches
Plain Diff
added example shell from bwrap git repo
parent
1be82370
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
bubblewrap/shell.sh
+39
-0
39 additions, 0 deletions
bubblewrap/shell.sh
with
39 additions
and
0 deletions
bubblewrap/shell.sh
0 → 100755
+
39
−
0
View file @
27a23148
#!/usr/bin/env bash
#
## Shell example modified to get stub for sandboxing cli tools
##
## https://github.com/containers/bubblewrap/blob/main/demos/bubblewrap-shell.sh
#
# Use bubblewrap to run /bin/sh reusing the host OS binaries (/usr), but with
# separate /tmp, /home, /var, /run, and /etc. For /etc we just inherit the
# host's resolv.conf, and set up "stub" passwd/group files. Not sharing
# /home for example is intentional. If you wanted to, you could design
# a bwrap-using program that shared individual parts of /home, perhaps
# public content.
#
# Another way to build on this example is to remove --share-net to disable
# networking.
set
-euo
pipefail
exec
bwrap
--ro-bind
/usr /usr
\
--dir
/tmp
\
--dir
/var
\
--symlink
../tmp var/tmp
\
--proc
/proc
\
--dev
/dev
\
--ro-bind
/etc/resolv.conf /etc/resolv.conf
\
--symlink
usr/lib /lib
\
--symlink
usr/lib64 /lib64
\
--symlink
usr/bin /bin
\
--symlink
usr/sbin /sbin
\
--chdir
/
\
--unshare-all
\
--share-net
\
--die-with-parent
\
--dir
/run/user/
$(
id
-u
)
\
--setenv
XDG_RUNTIME_DIR
"/run/user/
`
id
-u
`
"
\
--setenv
PS1
"bwrap-demo
$
"
\
--file
11 /etc/passwd
\
--file
12 /etc/group
\
/bin/sh
)
\
11< <
(
getent passwd
$UID
65534
)
\
12< <
(
getent group
$(
id
-g
)
65534
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment