Skip to content

Commit 74d30c4

Browse files
committed
Fix: users added by Hestia are members of a common group
Upgarde script will update existing users
1 parent 992ea29 commit 74d30c4

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

bin/v-add-user

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,18 @@ check_result $? "user creation failed" $E_INVALID
6161
# Adding password
6262
echo "$user:$password" | /usr/sbin/chpasswd
6363

64+
# Add a general group for normal users created by Hestia
65+
if [ -z "$(grep ^hestia-users: /etc/group)" ]; then
66+
groupadd "hestia-users"
67+
fi
68+
69+
# Add membership to hestia-users group to non-admin users
70+
if [ "$user" != "admin" ]; then
71+
usermod -a -G "hestia-users" "$user"
72+
setfacl -m "u:$user:r-x" "$HOMEDIR/$user"
73+
fi
74+
setfacl -m "g:hestia-users:---" "$HOMEDIR/$user"
75+
6476
# Building directory tree
6577
mkdir $HOMEDIR/$user/conf
6678

bin/v-add-web-domain-ftp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ fi
8585
-s $shell \
8686
-o -u $(id -u $user) \
8787
-g $(id -u $user) \
88+
-G hestia-users \
8889
-M -d "$ftp_path_a" > /dev/null 2>&1
8990

9091
# Set ftp user password

install/upgrade/0.10.0-190430.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,31 @@ if [ -d "/etc/roundcube" ]; then
173173
chown root:www-data /etc/roundcube/debian-db*
174174
fi
175175

176+
# Add a general group for normal users created by Hestia
177+
if [ -z "$(grep ^hestia-users: /etc/group)" ]; then
178+
echo "Add missing hestia-users group"
179+
groupadd "hestia-users"
180+
fi
181+
182+
# Make sure non-admin users belong to correct Hestia group
183+
for user in `ls /usr/local/hestia/data/users/`; do
184+
echo "[ACL] Check user $user"
185+
if [ "$user" != "admin" ]; then
186+
echo "[ACL] Fix acl for user: $user"
187+
usermod -a -G "hestia-users" "$user"
188+
setfacl -m "u:$user:r-x" "$HOMEDIR/$user"
189+
190+
# fix FTP users
191+
uid=$(id -u $user)
192+
for ftp_user in $(cat /etc/passwd | grep -v "^$user:" | grep "^$user.*:$uid:$uid:" | cut -d ":" -f1); do
193+
echo "[ACL] Fix acl for FTP user: $ftp_user"
194+
usermod -a -G "hestia-users" "$ftp_user"
195+
done
196+
197+
fi
198+
setfacl -m "g:hestia-users:---" "$HOMEDIR/$user"
199+
done
200+
176201
# Add unassigned hosts configuration to Nginx and Apache
177202
for ipaddr in $(ls /usr/local/hestia/data/ips/ 2>/dev/null); do
178203

0 commit comments

Comments
 (0)