From ea03be36772246d04fc194d9c0a1b992ea093993 Mon Sep 17 00:00:00 2001 From: Ramael Metatron Date: Sun, 16 Oct 2016 15:15:55 -0500 Subject: [PATCH 1/5] fix permissions error, create secure config fix group permission error by assigning to user. copy config files to s config template. --- bin/v-add-web-domain-httpauth | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/v-add-web-domain-httpauth b/bin/v-add-web-domain-httpauth index 42dd269e..67d907c1 100755 --- a/bin/v-add-web-domain-httpauth +++ b/bin/v-add-web-domain-httpauth @@ -71,9 +71,13 @@ fi auth_hash=$($BIN/v-generate-password-hash htpasswd htpasswd $password) touch $htpasswd chmod 640 $htpasswd $htaccess +chgrp $user $htpasswd $htaccess sed -i "/^$auth_user:/d" $htpasswd echo "$auth_user:$auth_hash" >> $htpasswd +cp -p "$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.conf_htaccess" "$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.conf_htaccess" +cp -p "$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.htpasswd" "$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.htpasswd" + # Restarting web server if [ "$restart" != 'no' ] && [ "$restart_required" = 'yes' ]; then $BIN/v-restart-web From 60df6eea56a37df2971e4566c4128015f3bc3b6e Mon Sep 17 00:00:00 2001 From: Ramael Metatron Date: Sun, 16 Oct 2016 19:23:06 -0500 Subject: [PATCH 2/5] change secure config to symlink of non symbolic link prevent duplicate file data to maintain --- bin/v-add-web-domain-httpauth | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/v-add-web-domain-httpauth b/bin/v-add-web-domain-httpauth index 67d907c1..d0a73e34 100755 --- a/bin/v-add-web-domain-httpauth +++ b/bin/v-add-web-domain-httpauth @@ -75,8 +75,8 @@ chgrp $user $htpasswd $htaccess sed -i "/^$auth_user:/d" $htpasswd echo "$auth_user:$auth_hash" >> $htpasswd -cp -p "$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.conf_htaccess" "$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.conf_htaccess" -cp -p "$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.htpasswd" "$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.htpasswd" +ln -s "$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.conf_htaccess" "$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.conf_htaccess" +ln -s "$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.htpasswd" "$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.htpasswd" # Restarting web server if [ "$restart" != 'no' ] && [ "$restart_required" = 'yes' ]; then From b44fcd8929640443baf940ee7240e8b9c3da0623 Mon Sep 17 00:00:00 2001 From: Ramael Metatron Date: Sun, 16 Oct 2016 19:30:04 -0500 Subject: [PATCH 3/5] defined secure configs as separate variables --- bin/v-add-web-domain-httpauth | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/v-add-web-domain-httpauth b/bin/v-add-web-domain-httpauth index d0a73e34..a99c989d 100755 --- a/bin/v-add-web-domain-httpauth +++ b/bin/v-add-web-domain-httpauth @@ -24,6 +24,8 @@ source $VESTA/conf/vesta.conf # Defining htpasswd file htaccess="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.conf_htaccess" htpasswd="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.htpasswd" +shtaccess="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.conf_htaccess" +shtpasswd="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.htpasswd" docroot="$HOMEDIR/$user/web/$domain/public_html" @@ -75,15 +77,15 @@ chgrp $user $htpasswd $htaccess sed -i "/^$auth_user:/d" $htpasswd echo "$auth_user:$auth_hash" >> $htpasswd -ln -s "$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.conf_htaccess" "$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.conf_htaccess" -ln -s "$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.htpasswd" "$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.htpasswd" +# Symbolic link for secure web templates +ln -s $htpasswd $shtpasswd +ln -s $htaccess $shtaccess # Restarting web server if [ "$restart" != 'no' ] && [ "$restart_required" = 'yes' ]; then $BIN/v-restart-web fi - #----------------------------------------------------------# # Vesta # #----------------------------------------------------------# From 7b2b895d579b2ade2781352f2c6f188c0e9c13f0 Mon Sep 17 00:00:00 2001 From: Ramael Metatron Date: Sun, 16 Oct 2016 19:37:04 -0500 Subject: [PATCH 4/5] Remove symlink to httpauth config files --- bin/v-delete-web-domain-httpauth | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/v-delete-web-domain-httpauth b/bin/v-delete-web-domain-httpauth index 84f9767a..3fbc85da 100755 --- a/bin/v-delete-web-domain-httpauth +++ b/bin/v-delete-web-domain-httpauth @@ -23,7 +23,8 @@ source $VESTA/conf/vesta.conf # Defining htpasswd file htaccess="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.conf_htaccess" htpasswd="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.htpasswd" - +shtaccess="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.conf_htaccess" +shtpasswd="$HOMEDIR/$user/conf/web/s$WEB_SYSTEM.$domain.htpasswd" #----------------------------------------------------------# # Verifications # @@ -54,7 +55,7 @@ sed -i "/^$auth_user:/d" $htpasswd # Deleting password protection if [ "$(echo "$AUTH_USER" |tr : '\n' |wc -l)" -le 1 ]; then - rm -f $htaccess $htpasswd + rm -f $htaccess $htpasswd $shtaccess $shtpasswd restart_required='yes' fi From 0a51da259093b3620dfd407a84054720de38f159 Mon Sep 17 00:00:00 2001 From: Ramael Metatron Date: Thu, 20 Oct 2016 00:40:28 -0500 Subject: [PATCH 5/5] Added validation if file exists Added validation if file exists to not create, avoiding error when adding additional users with this command. --- bin/v-add-web-domain-httpauth | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/v-add-web-domain-httpauth b/bin/v-add-web-domain-httpauth index a99c989d..04ed8354 100755 --- a/bin/v-add-web-domain-httpauth +++ b/bin/v-add-web-domain-httpauth @@ -78,8 +78,12 @@ sed -i "/^$auth_user:/d" $htpasswd echo "$auth_user:$auth_hash" >> $htpasswd # Symbolic link for secure web templates -ln -s $htpasswd $shtpasswd +if [ ! -L $shtpasswd ]; then + ln -s $htpasswd $shtpasswd +fi +if [ ! -L $shtaccess ]; then ln -s $htaccess $shtaccess +fi # Restarting web server if [ "$restart" != 'no' ] && [ "$restart_required" = 'yes' ]; then