From c166975d460186ab9e0ba5304e2b59f263970720 Mon Sep 17 00:00:00 2001 From: Romain Dessort Date: Fri, 25 Aug 2017 16:56:30 -0400 Subject: [PATCH] Use same UID/GID in containers --- scripts/web-add.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/web-add.sh b/scripts/web-add.sh index 4160e7c..638edfc 100755 --- a/scripts/web-add.sh +++ b/scripts/web-add.sh @@ -271,12 +271,17 @@ create_www_account() { usermod -g www-data $in_login fi + # Get uid/gid for newly created accounts + uid=$(id -u $in_login) + gid=$(id -g $in_login) + www_uid=$(id -u www-$in_login) + # Create users inside all containers for php_version in ${PHP_VERSIONS[@]}; do - #lxc-attach -n php${php_version} -- /usr/sbin/adduser --firstuid $FIRST_UID --lastuid $LAST_UID --gecos "User $in_login" --disabled-password "$in_login" --shell /bin/bash $OPT_UID $OPT_UID_ARG --force-badname --home "$HOME_DIR_USER" >/dev/null - lxc-attach -n php${php_version} -- /usr/sbin/adduser --gecos "User $in_login" --disabled-password "$in_login" --shell /bin/bash $OPT_UID $OPT_UID_ARG --force-badname --home "$HOME_DIR_USER" >/dev/null + lxc-attach -n php${php_version} -- /usr/sbin/addgroup "$in_login" --gid $gid --force-badname >/dev/null + lxc-attach -n php${php_version} -- /usr/sbin/adduser --gecos "User $in_login" --disabled-password "$in_login" --shell /bin/bash --uid $uid --gid $gid --force-badname --home "$HOME_DIR_USER" >/dev/null lxc-attach -n php${php_version} -- [ -z "$in_sshkey" ] && echo "$in_login:$in_passwd" | chpasswd --md5 - lxc-attach -n php${php_version} -- /usr/sbin/adduser --disabled-password --home $HOME_DIR_USER/www --no-create-home --shell /bin/false --gecos "WWW $in_login" www-$in_login $OPT_WWWUID $OPT_WWWUID_ARG --ingroup $in_login --force-badname >/dev/null + lxc-attach -n php${php_version} -- /usr/sbin/adduser --disabled-password --home $HOME_DIR_USER/www --no-create-home --shell /bin/false --gecos "WWW $in_login" www-$in_login --uid $www_uid --ingroup $in_login --force-badname >/dev/null done sed -i "s/^AllowUsers .*/& $in_login/" /etc/ssh/sshd_config