Skip to content

Commit 5b231dd

Browse files
Revert "Customize container user permissions using PUID and PGID. pgadmin-org#9657"
This reverts commit 97c90f1.
1 parent 3e48c21 commit 5b231dd

File tree

2 files changed

+5
-50
lines changed

2 files changed

+5
-50
lines changed

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ RUN apk update && apk upgrade && \
165165
tzdata \
166166
libedit \
167167
libldap \
168-
libcap \
169-
su-exec && \
168+
libcap && \
170169
rm -rf /var/cache/apk/*
171170

172171
# Copy in the Python packages
@@ -207,6 +206,8 @@ RUN /venv/bin/python3 -m pip install --no-cache-dir gunicorn==23.0.0 && \
207206
echo "pgadmin ALL = NOPASSWD: /usr/sbin/postfix start" > /etc/sudoers.d/postfix && \
208207
echo "pgadminr ALL = NOPASSWD: /usr/sbin/postfix start" >> /etc/sudoers.d/postfix
209208

209+
USER 5050
210+
210211
# Finish up
211212
VOLUME /var/lib/pgadmin
212213
EXPOSE 80 443

pkg/docker/entrypoint.sh

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,4 @@
11
#!/usr/bin/env bash
2-
PUID=${PUID:-5050}
3-
PGID=${PGID:-0}
4-
5-
if [ "$(id -u)" = "0" ]; then
6-
# Ensure a group with the target GID exists
7-
if ! getent group "$PGID" > /dev/null 2>&1; then
8-
addgroup -g "$PGID" pggroup
9-
fi
10-
11-
# Reassign the pgadmin user to the desired UID/GID
12-
usermod -o -u "$PUID" -g "$PGID" pgadmin 2>&1 || \
13-
echo "WARNING: usermod failed for UID=$PUID GID=$PGID"
14-
15-
# Compose su-exec command
16-
SU_EXEC="su-exec $PUID:$PGID"
17-
echo "pgAdmin will run as UID=$PUID, GID=$PGID"
18-
else
19-
SU_EXEC=""
20-
fi
212

223
# Fixup the passwd file, in case we're on OpenShift
234
if ! whoami > /dev/null 2>&1; then
@@ -28,27 +9,6 @@ if ! whoami > /dev/null 2>&1; then
289
fi
2910
fi
3011

31-
# Helper: chown a path only if it exists and isn't already owned correctly
32-
safe_chown() {
33-
local target="$1"
34-
local owner="$2:$3" # UID:GID
35-
36-
# Skip if path doesn't exist
37-
[ -e "$target" ] || return 0
38-
39-
# Get current ownership
40-
local current_uid current_gid
41-
current_uid=$(stat -c '%u' "$target")
42-
current_gid=$(stat -c '%g' "$target")
43-
44-
# Skip if already owned correctly
45-
if [ "$current_uid" = "$2" ] && [ "$current_gid" = "$3" ]; then
46-
return 0
47-
fi
48-
49-
chown -R "$owner" "$target"
50-
}
51-
5212
# usage: file_env VAR [DEFAULT] ie: file_env 'XYZ_DB_PASSWORD' 'example'
5313
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
5414
# "$XYZ_DB_PASSWORD" from a file, for Docker's secrets feature)
@@ -222,12 +182,6 @@ fi
222182
# to define the Gunicorn worker timeout
223183
TIMEOUT=$(cd /pgadmin4 && /venv/bin/python3 -c 'import config; print(config.SESSION_EXPIRATION_TIME * 60 * 60 * 24)')
224184

225-
if [ "$(id -u)" = "0" ]; then
226-
for path in /run/pgadmin /var/lib/pgadmin "$CONFIG_DISTRO_FILE_PATH" /certs; do
227-
safe_chown "$path" "$PUID" "$PGID"
228-
done
229-
fi
230-
231185
# NOTE: currently pgadmin can run only with 1 worker due to sessions implementation
232186
# Using --threads to have multi-threaded single-process worker
233187

@@ -242,7 +196,7 @@ else
242196
fi
243197

244198
if [ -n "${PGADMIN_ENABLE_TLS}" ]; then
245-
exec $SU_EXEC /venv/bin/gunicorn --limit-request-line "${GUNICORN_LIMIT_REQUEST_LINE:-8190}" --timeout "${TIMEOUT}" --bind "${BIND_ADDRESS}" -w 1 --threads "${GUNICORN_THREADS:-25}" --access-logfile "${GUNICORN_ACCESS_LOGFILE:--}" --keyfile /certs/server.key --certfile /certs/server.cert -c gunicorn_config.py run_pgadmin:app
199+
exec /venv/bin/gunicorn --limit-request-line "${GUNICORN_LIMIT_REQUEST_LINE:-8190}" --timeout "${TIMEOUT}" --bind "${BIND_ADDRESS}" -w 1 --threads "${GUNICORN_THREADS:-25}" --access-logfile "${GUNICORN_ACCESS_LOGFILE:--}" --keyfile /certs/server.key --certfile /certs/server.cert -c gunicorn_config.py run_pgadmin:app
246200
else
247-
exec $SU_EXEC /venv/bin/gunicorn --limit-request-line "${GUNICORN_LIMIT_REQUEST_LINE:-8190}" --limit-request-fields "${GUNICORN_LIMIT_REQUEST_FIELDS:-100}" --limit-request-field_size "${GUNICORN_LIMIT_REQUEST_FIELD_SIZE:-8190}" --timeout "${TIMEOUT}" --bind "${BIND_ADDRESS}" -w 1 --threads "${GUNICORN_THREADS:-25}" --access-logfile "${GUNICORN_ACCESS_LOGFILE:--}" -c gunicorn_config.py run_pgadmin:app
201+
exec /venv/bin/gunicorn --limit-request-line "${GUNICORN_LIMIT_REQUEST_LINE:-8190}" --limit-request-fields "${GUNICORN_LIMIT_REQUEST_FIELDS:-100}" --limit-request-field_size "${GUNICORN_LIMIT_REQUEST_FIELD_SIZE:-8190}" --timeout "${TIMEOUT}" --bind "${BIND_ADDRESS}" -w 1 --threads "${GUNICORN_THREADS:-25}" --access-logfile "${GUNICORN_ACCESS_LOGFILE:--}" -c gunicorn_config.py run_pgadmin:app
248202
fi

0 commit comments

Comments
 (0)