Skip to content

Commit 395c471

Browse files
committed
Update v-add-user
More stricter permissions, the current setup allows any user on the system to read other users web files as long as they know the path, the only users which should be allow to access $HOMEDIR/$user/web is owner of sites and nginx user to be able to serve static files. I also locked down access $HOMEDIR/$user/tmp to the user, its gets used in the hosting template for tmp files, i don't see why another user would need access to it as apache runs as the user.
1 parent 1689ea3 commit 395c471

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

bin/v-add-user

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,13 @@ echo "$user:$password" | /usr/sbin/chpasswd
6767
mkdir $HOMEDIR/$user/conf
6868

6969
if [ ! -z "$WEB_SYSTEM" ]; then
70+
nginxuser=$(ps -eo user,comm|grep nginx|uniq|grep -v "root"|awk '{ print $1}')
7071
mkdir $HOMEDIR/$user/conf/web $HOMEDIR/$user/web $HOMEDIR/$user/tmp
71-
chmod 751 $HOMEDIR/$user/conf/web $HOMEDIR/$user/web
72-
chmod 771 $HOMEDIR/$user/tmp
73-
chown $user:$user $HOMEDIR/$user/web $HOMEDIR/$user/tmp
72+
chmod 751 $HOMEDIR/$user/conf/web
73+
chmod 710 $HOMEDIR/$user/web
74+
chmod 700 $HOMEDIR/$user/tmp
75+
chown $user:$nginxuser $HOMEDIR/$user/web
76+
chown $user:$user $HOMEDIR/$user/tmp
7477
fi
7578

7679
if [ ! -z "$MAIL_SYSTEM" ]; then

0 commit comments

Comments
 (0)