Skip to content

Commit

Permalink
Merge pull request #321 from Kong/permissions
Browse files Browse the repository at this point in the history
fix(mount) update permissions to ensure access
  • Loading branch information
hanshuebner authored Sep 13, 2022
2 parents 15d30a1 + e7a12bc commit c9279f8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion assets/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ USER root
# But that means hardcoding and that doesn't play well with the nature of Pongo
# that should be independent of Kong versions.
RUN apk update \
&& apk add zip unzip make g++ py-pip jq git bsd-compat-headers m4 openssl-dev curl wget python3-dev \
&& apk add zip unzip make g++ py-pip jq git bsd-compat-headers m4 openssl-dev curl wget python3-dev shadow \
&& curl -k -s -S -L https://github.com/fullstorydev/grpcurl/releases/download/v1.7.0/grpcurl_1.7.0_linux_x86_64.tar.gz | tar xz -C /kong/bin \
&& pip install httpie \
; cd /kong \
Expand Down
25 changes: 25 additions & 0 deletions assets/pongo_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,31 @@ if [ -z "$KONG_TEST_LUA_SSL_TRUSTED_CERTIFICATE" ]; then
fi


# Modify the 'kong' user to match the ownership of the mounted plugin folder
# Kong will not start because of permission errors if it cannot write to the
# /kong-plugin/servroot folder (which resides on the mount).
# Since those permissions are controlled by the host, we update the 'kong' user
# inside the container to match the UID and GID.
if [ -d /kong-plugin ]; then
KONG_UID=$(id -u kong)
KONG_GID=$(id -g kong)
MOUNT_UID=$(stat -c "%u" /kong-plugin)
MOUNT_GID=$(stat -c "%g" /kong-plugin)
if [ ! "$KONG_GID" = "$MOUNT_GID" ]; then
# change KONG_GID to the ID of the folder owner group
groupmod -g "$MOUNT_GID" --non-unique kong
fi

if [ ! "$KONG_UID" = "$MOUNT_UID" ]; then
# change KONG_UID to the ID of the folder owner
usermod -u "$MOUNT_UID" -g "$MOUNT_GID" --non-unique kong
fi
unset KONG_UID
unset KONG_GID
unset MOUNT_UID
unset MOUNT_GID
fi


# perform any custom setup if specified
if [ -f /kong-plugin/.pongo/pongo-setup.sh ]; then
Expand Down

0 comments on commit c9279f8

Please sign in to comment.