Skip to content

Commit 12b2c41

Browse files
authored
Merge pull request hestiacp#1659 from hestiacp/fix/2021-03-allow-users-system
Add system wide variable for allow_users option
2 parents 3f5ed5a + 2979924 commit 12b2c41

File tree

9 files changed

+53
-15
lines changed

9 files changed

+53
-15
lines changed

bin/v-list-sys-config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ json_list() {
6767
"DB_PGA_ALIAS": "'$DB_PGA_ALIAS'",
6868
"LOGIN_STYLE": "'$LOGIN_STYLE'",
6969
"INACTIVE_SESSION_TIMEOUT": "'$INACTIVE_SESSION_TIMEOUT'",
70-
"PHPMYADMIN_KEY": "'$PHPMYADMIN_KEY'"
70+
"PHPMYADMIN_KEY": "'$PHPMYADMIN_KEY'",
71+
"ALLOW_USERS_SYSTEM": "'$ALLOW_USERS_SYSTEM'"
7172
}
7273
}'
7374
}

func/domain.sh

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -881,9 +881,6 @@ is_valid_extension() {
881881
test_domain=$(idn -t --quiet -u "$1" )
882882
extension=$( /bin/echo "${test_domain}" | /usr/bin/rev | /usr/bin/cut -d "." --output-delimiter="." -f 1 | /usr/bin/rev );
883883
exten=$(grep "^$extension\$" $HESTIA/data/extensions/public_suffix_list.dat);
884-
if [ $? -ne 0 ]; then
885-
check_result 2 ".$extension is not valid"
886-
fi
887884
}
888885

889886
is_valid_2_part_extension() {
@@ -901,7 +898,7 @@ get_base_domain() {
901898
test_domain=$1
902899
is_valid_extension "$test_domain"
903900
if [ $? -ne 0 ]; then
904-
basedomain=""
901+
basedomain=$( /bin/echo "${test_domain}" | /usr/bin/rev | /usr/bin/cut -d "." --output-delimiter="." -f 1-2 | /usr/bin/rev );
905902
else
906903
is_valid_2_part_extension "$test_domain"
907904
if [ $? -ne 0 ]; then
@@ -919,14 +916,16 @@ is_base_domain_owner(){
919916
if [ "$object" != "none" ]; then
920917
get_base_domain $object
921918
web=$(grep -F -H -h "DOMAIN='$basedomain'" $HESTIA/data/users/*/web.conf);
922-
if [ ! -z "$web" ]; then
923-
parse_object_kv_list "$web"
924-
if [ -z "$ALLOW_USERS" ] || [ "$ALLOW_USERS" != "yes" ]; then
925-
# Don't care if $basedomain all ready exists only if the owner is of the base domain is the current user
926-
is_domain_new "" $basedomain
919+
if [ $ALLOW_USERS_SYSTEM = "no" ]; then
920+
if [ ! -z "$web" ]; then
921+
parse_object_kv_list "$web"
922+
if [ -z "$ALLOW_USERS" ] || [ "$ALLOW_USERS" != "yes" ]; then
923+
# Don't care if $basedomain all ready exists only if the owner is of the base domain is the current user
924+
is_domain_new "" $basedomain
925+
fi
926+
else
927+
is_domain_new "" $basedomain
927928
fi
928-
else
929-
is_domain_new "" $basedomain
930929
fi
931930
fi
932931
done

func/upgrade.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,12 @@ upgrade_health_check() {
143143
echo "[ ! ] Adding missing variable to hestia.conf: INACTIVE_SESSION_TIMEOUT ('60')"
144144
$BIN/v-change-sys-config-value "INACTIVE_SESSION_TIMEOUT" "60"
145145
fi
146-
146+
147+
# Inactive session timeout
148+
if [ -z "$ALLOW_USERS_SYSTEM" ]; then
149+
echo "[ ! ] Adding missing variable to hestia.conf: ALLOW_USERS_SYSTEM ('yes')"
150+
$BIN/v-change-sys-config-value "ALLOW_USERS_SYSTEM" "yes"
151+
fi
147152

148153
echo "[ * ] Health check complete. Starting upgrade from $VERSION to $new_version..."
149154
echo "============================================================================="

install/hst-install-debian.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,6 +1094,9 @@ echo "LOGIN_STYLE='default'" >> $HESTIA/conf/hestia.conf
10941094
# Inactive session timeout
10951095
echo "INACTIVE_SESSION_TIMEOUT='60'" >> $HESTIA/conf/hestia.conf
10961096

1097+
# Allow users to always create domains even the are not the owner of the main domain
1098+
echo "ALLOW_USERS_SYSTEM='no'" >> $HESTIA/conf/hestia.conf
1099+
10971100
# Version & Release Branch
10981101
echo "VERSION='${HESTIA_INSTALL_VER}'" >> $HESTIA/conf/hestia.conf
10991102
echo "RELEASE_BRANCH='release'" >> $HESTIA/conf/hestia.conf

install/hst-install-ubuntu.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,9 @@ echo "LOGIN_STYLE='default'" >> $HESTIA/conf/hestia.conf
11271127
# Inactive session timeout
11281128
echo "INACTIVE_SESSION_TIMEOUT='60'" >> $HESTIA/conf/hestia.conf
11291129

1130+
# Allow users to always create domains even the are not the owner of the main domain
1131+
echo "ALLOW_USERS_SYSTEM='no'" >> $HESTIA/conf/hestia.conf
1132+
11301133
# Version & Release Branch
11311134
echo "VERSION='${HESTIA_INSTALL_VER}'" >> $HESTIA/conf/hestia.conf
11321135
echo "RELEASE_BRANCH='release'" >> $HESTIA/conf/hestia.conf

web/add/web/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@
168168
exec (HESTIA_CMD."v-delete-web-domain-proxy ".$user." ".escapeshellarg($v_domain)." 'no'", $output, $return_var);
169169
check_return_code($return_var,$output);
170170
unset($output);
171+
$restart_web = 'yes';
171172
}
172173

173174
// Change template

web/edit/server/index.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@
660660
}
661661
}
662662

663-
// Change login style
663+
// Change INACTIVE_SESSION_TIMEOUT
664664
if (empty($_SESSION['error_msg'])) {
665665
if ($_POST['v_inactive_session_timeout'] != $_SESSION['INACTIVE_SESSION_TIMEOUT']) {
666666
exec (HESTIA_CMD."v-change-sys-config-value INACTIVE_SESSION_TIMEOUT ".escapeshellarg($_POST['v_inactive_session_timeout']), $output, $return_var);
@@ -670,6 +670,17 @@
670670
$v_security_adv = 'yes';
671671
}
672672
}
673+
674+
// Change ALLOW_USERS_SERVER
675+
if (empty($_SESSION['error_msg'])) {
676+
if ($_POST['v_allow_users_system'] != $_SESSION['v_allow_users_system']) {
677+
exec (HESTIA_CMD."v-change-sys-config-value ALLOW_USERS_SYSTEM ".escapeshellarg($_POST['v_allow_users_system']), $output, $return_var);
678+
check_return_code($return_var,$output);
679+
unset($output);
680+
if (empty($_SESSION['error_msg'])) $v_allow_users_system = $_POST['v_allow_users_system'];
681+
$v_security_adv = 'yes';
682+
}
683+
}
673684

674685
// Change login style
675686
if (empty($_SESSION['error_msg'])) {

web/edit/web/index.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@
333333
check_return_code($return_var,$output);
334334
unset($output);
335335
}
336+
$restart_proxy = 'yes';
336337
}
337338

338339
// Delete proxy support

web/templates/admin/edit_server.html

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@
982982
</tr>
983983
<tr>
984984
<td class="vst-text input-label">
985-
<?php print _('Inactive session length');?> (<?php print _('Minutes');?>)
985+
<?php print _('Inactive session timeout');?> (<?php print _('Minutes');?>)
986986
</td>
987987
</tr>
988988
<tr>
@@ -991,6 +991,20 @@
991991
<br><br>
992992
</td>
993993
</tr>
994+
<tr>
995+
<td class="vst-text input-label">
996+
<?php print _('Disable check domain owner');?>
997+
</td>
998+
</tr>
999+
<tr>
1000+
<td>
1001+
<select class="vst-list" name="v_allow_users_system">
1002+
<option value='yes'><?php print _('yes'); ?></option>
1003+
<option value='no' <?php if($_SESSION['ALLOW_USERS_SYSTEM'] == 'no') echo 'selected' ?> ><?php print _('no'); ?></option>
1004+
</select>
1005+
<br><br>
1006+
</td>
1007+
</tr>
9941008
</table>
9951009
</td>
9961010
</tr>

0 commit comments

Comments
 (0)