From 76cb7e40cb9d41ce45b10e548f9675dc9e972e05 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Tue, 3 Jul 2018 16:13:49 -0700 Subject: [PATCH] Set permissions to container uid and group docker cp has a bug where it uses the host machine's uid and group for copied files and directories even though the copied files and directories should use the container's user's uid and group. To fix this, we run chown as root on the copied files and directories to get the correct permissions. --- libexec/copy-to-target | 1 + 1 file changed, 1 insertion(+) diff --git a/libexec/copy-to-target b/libexec/copy-to-target index 0a39c66..f422e3f 100755 --- a/libexec/copy-to-target +++ b/libexec/copy-to-target @@ -49,6 +49,7 @@ fi if [ -n "$USE_DOCKER" ]; then docker exec -u $TUSER gitian-target mkdir -p "/home/$TUSER/$2" docker cp "$1" gitian-target:"/home/$TUSER/$2" + docker exec -u root gitian-target chown -R $TUSER:$TUSER "/home/$TUSER/$2" elif [ -z "$USE_LXC" ]; then src="${1%/}" # remove trailing / which triggers special rsync behaviour rsync --checksum -a $QUIET_FLAG -e "ssh -oConnectTimeout=30 -oNoHostAuthenticationForLocalhost=yes -i ${GITIAN_BASE:-.}/var/id_rsa -p $VM_SSH_PORT" "${src}" "$TUSER@localhost:$2"