summaryrefslogtreecommitdiffstats
path: root/docker/usr/bin
diff options
context:
space:
mode:
authortechknowlogick <techknowlogick@users.noreply.github.com>2018-05-16 11:58:44 -0400
committerLunny Xiao <xiaolunwen@gmail.com>2018-05-16 23:58:44 +0800
commitecfc401eaa707914d487574134fcd9e3bbeac60d (patch)
treee656b7cdd9b2dfe2402582d30b01d72f0df6853f /docker/usr/bin
parent4ceb92f311f8c27790378ff2b9d9820308ce5451 (diff)
downloadgitea-ecfc401eaa707914d487574134fcd9e3bbeac60d.tar.gz
gitea-ecfc401eaa707914d487574134fcd9e3bbeac60d.zip
Allow Gitea to run as different USER in Docker (#3961)
* If using a different $USER then rename git user * Chown based on $USER env * Target only one part of passwd * su-exec based on $USER not a hardcoded value
Diffstat (limited to 'docker/usr/bin')
-rwxr-xr-xdocker/usr/bin/entrypoint7
1 files changed, 7 insertions, 0 deletions
diff --git a/docker/usr/bin/entrypoint b/docker/usr/bin/entrypoint
index b374c5aed7..50623bfa66 100755
--- a/docker/usr/bin/entrypoint
+++ b/docker/usr/bin/entrypoint
@@ -1,5 +1,12 @@
#!/bin/sh
+if [ "${USER}" != "git" ]; then
+ # rename user
+ sed -i -e "s/^git\:/${USER}\:/g" /etc/passwd
+ # switch sshd config to different user
+ sed -i -e "s/AllowUsers git/AllowUsers ${USER}/g" /etc/ssh/sshd_config
+fi
+
## Change GID for USER?
if [ -n "${USER_GID}" ] && [ "${USER_GID}" != "`id -g ${USER}`" ]; then
sed -i -e "s/^${USER}:\([^:]*\):[0-9]*/${USER}:\1:${USER_GID}/" /etc/group