Skip to content

Instantly share code, notes, and snippets.

@npcardoso
Last active October 24, 2015 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save npcardoso/920051ac16ba4d4f576a to your computer and use it in GitHub Desktop.
Save npcardoso/920051ac16ba4d4f576a to your computer and use it in GitHub Desktop.
A chroot wrapper for pixelserv (https://github.com/HunterZ/pixelserv)
#!/bin/sh
set -e
P=`readlink -m $0`
P="$P.bin"
HOME='/tmp/pixelserv/chroot'
if [[ ! -d $HOME ]]; then
echo "Creating '$HOME'"
mkdir $HOME -p
fi
DEPS=`ldd $P | grep '/' | sed 's|[^/]*\(/[^ ]*\).*|\1|'`
echo "Copying '$P'"
cp $P $HOME
for d in $DEPS; do
echo "Copying '$d'"
cp --parents -L $d $HOME
done
echo "Setting perms"
chmod a+rx "$HOME/" -R
echo "Launching"
exec chroot --userspec=nobody:nobody $HOME ./pixelserv.bin -f -p 8888
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment