Skip to content

Instantly share code, notes, and snippets.

@JonathonMA
Created July 29, 2016 04:38
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 JonathonMA/9f7f09dca7225e4dd6b66620a0577a57 to your computer and use it in GitHub Desktop.
Save JonathonMA/9f7f09dca7225e4dd6b66620a0577a57 to your computer and use it in GitHub Desktop.
#!/bin/bash
cat > Dockerfile << EOF
FROM debian:jessie
ENV APPDIR=/srv/app
VOLUME \$APPDIR
WORKDIR \$APPDIR
RUN \
groupadd -g 1000 appgrp &&\
groupadd -g 1001 secgrp &&\
useradd -u 1000 -g 1000 -Ms /bin/bash appusr &&\
useradd -u 1001 -g 1001 -Ms /bin/bash secusr &&\
true
EOF
docker build -t permtest .
echo ">> Creating a secret file as the secret user"
docker run --rm -it \
-v `pwd`:/srv/app \
-u secusr \
permtest \
sh -c "echo imsecret > secret.txt && chmod 0600 secret.txt && ls -l secret.txt"
echo ">> Attempting to read the secret file as the unprivileged user"
docker run --rm -it \
-v `pwd`:/srv/app \
-u appusr \
permtest \
sh -c "ls -l secret.txt && cat secret.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment