Skip to content

Instantly share code, notes, and snippets.

@cfinch
Created April 15, 2018 15:18
Show Gist options
  • Save cfinch/bcc5a265add80633fd60e250da5ea3b4 to your computer and use it in GitHub Desktop.
Save cfinch/bcc5a265add80633fd60e250da5ea3b4 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Credit to Ivan Zahariev at https://blog.famzah.net/2014/06/04/private-tmp-mount-per-process-in-linux/
TARGET_CMD=$1
NEWTMP="$(mktemp -d)"
chown "root:root" "$NEWTMP"
chmod 770 "$NEWTMP"
unshare --mount -- /bin/bash -c "mount -o bind,noexec,nosuid,nodev '$NEWTMP' /tmp && $TARGET_CMD"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment