Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. # Use bubblewrap to run /bin/sh reusing the host OS binaries (/usr), but with
  3. # separate /tmp, /home, /var, /run, and /etc. For /etc we just inherit the
  4. # host's resolv.conf, and set up "stub" passwd/group files. Not sharing
  5. # /home for example is intentional. If you wanted to, you could design
  6. # a bwrap-using program that shared individual parts of /home, perhaps
  7. # public content.
  8. #
  9. # Another way to build on this example is to remove --share-net to disable
  10. # networking.
  11. set -euo pipefail
  12. (exec bwrap --ro-bind /usr /usr \
  13. --dir /tmp \
  14. --dir /var \
  15. --symlink ../tmp var/tmp \
  16. --proc /proc \
  17. --dev /dev \
  18. --ro-bind /etc/resolv.conf /etc/resolv.conf \
  19. --symlink usr/lib /lib \
  20. --symlink usr/lib64 /lib64 \
  21. --symlink usr/bin /bin \
  22. --symlink usr/sbin /sbin \
  23. --chdir / \
  24. --unshare-all \
  25. --share-net \
  26. --die-with-parent \
  27. --dir /run/user/$(id -u) \
  28. --setenv XDG_RUNTIME_DIR "/run/user/`id -u`" \
  29. --setenv PS1 "bwrap-demo$ " \
  30. --file 11 /etc/passwd \
  31. --file 12 /etc/group \
  32. /bin/sh) \
  33. 11< <(getent passwd $UID 65534) \
  34. 12< <(getent group $(id -g) 65534)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement