From 79950a0545243cb460593dd593a6aca6ddce6312 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Sat, 7 Nov 2015 23:52:35 -0800 Subject: [PATCH] Fix monad-impersonate for OS X Docker on OS X uses a Linux host for the containers, 99% of the time it's the boot2docker image. The user and group within the image (and their IDs) is different from that of the OS X user. However, the Linux host machine also has the OS X host /Users folder mounted (using a VirtualBox share). Given the permissions of the Linux user inside the container, the OS X user's folders are writable. --- monad-docker.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/monad-docker.sh b/monad-docker.sh index 2fbd25391..16d5f5d70 100644 --- a/monad-docker.sh +++ b/monad-docker.sh @@ -40,8 +40,15 @@ monad-impersonate() local CUSER=$(id -un) local CGID=$(id -g) local CGROUP=$(id -gn) + # default docker-machine VM does not change + if [[ $OSTYPE == darwin* ]]; then + CUID=1000 + CUSER=docker + CGID=50 + CGROUP=staff + fi echo \ - groupadd -g $CGID $CGROUP '&&' \ + groupadd -o -f -g $CGID $CGROUP '&&' \ useradd -u $CUID -g $CGID -d /opt $CUSER '&&' \ sudo --set-home -u $CUSER -g $CGROUP -- }