From 2af136356d6bc1dc4835a4f76ac06d9e0942f205 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 23 Aug 2019 03:37:40 -0400 Subject: [PATCH] Update the Docker entrypoint UID and GUID code Update the ownership of files when the UID of GUID are changed. GitLab issue #650. Allow changing the GID of the mayan user to existing values. GitLab issue #652. Thanks to Fabian (@ruffy91) for both reports. Signed-off-by: Roberto Rosario --- HISTORY.rst | 8 ++++++++ docker/rootfs/usr/local/bin/entrypoint.sh | 18 +++++++++++++++--- docs/releases/3.2.7.rst | 10 ++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 4363bb67a0..0155e7fb9a 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -17,6 +17,14 @@ * Increase mailing profile password field max length from 48 to 128 characters. GitLab issue #657. Thanks to sigsec (@sigsec) for the report. +* Update the Docker entrypoint to update the ownership + of files when the UID of GUID are changed. + GitLab issue #650. Thanks to Fabian (@ruffy91) + for the report. +* Update the Docker entrypoint to allow changing + the GID of the mayan user to existing values. + GitLab issue #652. Thanks to Fabian (@ruffy91) + for the report. 3.2.6 (2019-07-10) ================== diff --git a/docker/rootfs/usr/local/bin/entrypoint.sh b/docker/rootfs/usr/local/bin/entrypoint.sh index 733bd5c763..427e86ee4d 100755 --- a/docker/rootfs/usr/local/bin/entrypoint.sh +++ b/docker/rootfs/usr/local/bin/entrypoint.sh @@ -8,6 +8,9 @@ CONCURRENCY_ARGUMENT=--concurrency= DEFAULT_USER_UID=1000 DEFAULT_USER_GUID=1000 +MAYAN_USER_UID=${MAYAN_USER_UID:-${DEFAULT_USER_UID}} +MAYAN_USER_GUID=${MAYAN_USER_GUID:-${DEFAULT_USER_GUID}} + export MAYAN_DEFAULT_BROKER_URL=redis://127.0.0.1:6379/0 export MAYAN_DEFAULT_CELERY_RESULT_BACKEND=redis://127.0.0.1:6379/0 @@ -30,9 +33,18 @@ MAYAN_WORKER_FAST_CONCURRENCY=${MAYAN_WORKER_FAST_CONCURRENCY:-1} MAYAN_WORKER_MEDIUM_CONCURRENCY=${MAYAN_WORKER_MEDIUM_CONCURRENCY:-1} MAYAN_WORKER_SLOW_CONCURRENCY=${MAYAN_WORKER_SLOW_CONCURRENCY:-1} -echo "mayan: changing uid/guid" -usermod mayan -u ${MAYAN_USER_UID:-${DEFAULT_USER_UID}} -groupmod mayan -g ${MAYAN_USER_GUID:-${DEFAULT_USER_GUID}} +update_uid_gid() { + echo "mayan: update_uid_gid()" + groupmod mayan -g ${MAYAN_USER_GUID} 2>/dev/null || true + usermod mayan -u ${MAYAN_USER_UID} -g ${MAYAN_USER_GUID} 2>/dev/null + + if [ ${MAYAN_USER_UID} -ne ${DEFAULT_USER_UID} ] || [ ${MAYAN_USER_GUID} -ne ${DEFAULT_USER_GUID} ]; then + echo "mayan: Updating file ownership. This might take a while if there are many documents." + chown mayan:mayan ${MAYAN_INSTALL_DIR} ${MAYAN_STATIC_ROOT} ${MAYAN_MEDIA_ROOT} + fi +} + +update_uid_gid if [ "$MAYAN_WORKER_FAST_CONCURRENCY" -eq 0 ]; then MAYAN_WORKER_FAST_CONCURRENCY= diff --git a/docs/releases/3.2.7.rst b/docs/releases/3.2.7.rst index 802d3ca7ea..fd2dad0ec6 100644 --- a/docs/releases/3.2.7.rst +++ b/docs/releases/3.2.7.rst @@ -24,6 +24,14 @@ Changes - Increase mailing profile password field max length from 48 to 128 characters. GitLab issue #657. Thanks to sigsec (@sigsec) for the report. +- Update the Docker entrypoint to update the ownership + of files when the UID of GUID are changed. + GitLab issue #650. Thanks to Fabian (@ruffy91) + for the report. +- Update the Docker entrypoint to allow changing + the GID of the mayan user to existing values. + GitLab issue #652. Thanks to Fabian (@ruffy91) + for the report. Removals -------- @@ -116,6 +124,8 @@ Backward incompatible changes Bugs fixed or issues closed --------------------------- +- :gitlab-issue:`650` Permission denied when MAYAN_USER_UID and MAYAN_USER_GUID are set +- :gitlab-issue:`652` MAYAN_USER_GUID cannot be set to specific values - :gitlab-issue:`654` Internal Server Error, Document Checkout - :gitlab-issue:`655` Index setup tree view shows two times the "enabled" field instead of "Link documents" - :gitlab-issue:`657` Mailer password length restriction is too short