Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add env variables to change UID/GID of www-data #1278

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions 18.0/apache/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ file_env() {
unset "$fileVar"
}

# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi

if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip
Expand Down
1 change: 1 addition & 0 deletions 18.0/fpm-alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ RUN set -ex; \
\
apk add --no-cache \
rsync \
shadow \
; \
\
rm /var/spool/cron/crontabs/root; \
Expand Down
16 changes: 16 additions & 0 deletions 18.0/fpm-alpine/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ file_env() {
unset "$fileVar"
}

# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi

if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip
Expand Down
16 changes: 16 additions & 0 deletions 18.0/fpm/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ file_env() {
unset "$fileVar"
}

# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi

if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip
Expand Down
16 changes: 16 additions & 0 deletions 19.0/apache/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ file_env() {
unset "$fileVar"
}

# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi

if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip
Expand Down
1 change: 1 addition & 0 deletions 19.0/fpm-alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ RUN set -ex; \
\
apk add --no-cache \
rsync \
shadow \
; \
\
rm /var/spool/cron/crontabs/root; \
Expand Down
16 changes: 16 additions & 0 deletions 19.0/fpm-alpine/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ file_env() {
unset "$fileVar"
}

# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi

if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip
Expand Down
16 changes: 16 additions & 0 deletions 19.0/fpm/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ file_env() {
unset "$fileVar"
}

# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi

if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip
Expand Down
16 changes: 16 additions & 0 deletions 20.0/apache/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ file_env() {
unset "$fileVar"
}

# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi

if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip
Expand Down
1 change: 1 addition & 0 deletions 20.0/fpm-alpine/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ RUN set -ex; \
\
apk add --no-cache \
rsync \
shadow \
; \
\
rm /var/spool/cron/crontabs/root; \
Expand Down
16 changes: 16 additions & 0 deletions 20.0/fpm-alpine/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ file_env() {
unset "$fileVar"
}

# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
jan-di marked this conversation as resolved.
Show resolved Hide resolved
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi

if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip
Expand Down
16 changes: 16 additions & 0 deletions 20.0/fpm/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ file_env() {
unset "$fileVar"
}

# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi

if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip
Expand Down
1 change: 1 addition & 0 deletions Dockerfile-alpine.template
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ RUN set -ex; \
\
apk add --no-cache \
rsync \
shadow \
; \
\
rm /var/spool/cron/crontabs/root; \
Expand Down
16 changes: 16 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ file_env() {
unset "$fileVar"
}

# change uid/gid of www-data
if [ "$(id -u)" = 0 ]; then
CURRENT_UID=$(id -u www-data)
CURRENT_GID=$(id -g www-data)
if [ -n "${UID+x}" ] && [ "$UID" -ne $CURRENT_UID ]; then
echo "Change UID of www-data from $CURRENT_UID to $UID"
usermod -u $UID www-data
find / -xdev -user $CURRENT_UID -exec chown -h www-data {} \;
fi
if [ -n "${GID+x}" ] && [ "$GID" -ne $CURRENT_GID ]; then
echo "Change GID of www-data from $CURRENT_GID to $GID"
groupmod -g $GID www-data
find / -xdev -group $CURRENT_GID -exec chgrp -h www-data {} \;
fi
fi

if expr "$1" : "apache" 1>/dev/null; then
if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then
a2disconf remoteip
Expand Down