Skip to content

Commit 65a161f

Browse files
author
Kristan Kenney
committed
Merge branch 'feature/suspended-user-access' into feature/user-roles
2 parents 65ec0fa + 6128d1d commit 65a161f

File tree

7 files changed

+49
-18
lines changed

7 files changed

+49
-18
lines changed

bin/v-delete-user-backup

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ check_args '2' "$#" 'USER BACKUP'
3333
is_format_valid 'user' 'backup'
3434
is_system_enabled "$BACKUP_SYSTEM" 'BACKUP_SYSTEM'
3535
is_object_valid 'user' 'USER' "$user"
36-
is_object_unsuspended 'user' 'USER' "$user"
3736
is_object_valid 'backup' 'BACKUP' "$2"
3837

3938
# Perform verification if read-only mode is enabled

bin/v-list-sys-config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ json_list() {
8080
"POLICY_SYSTEM_HIDE_ADMIN": "'$POLICY_SYSTEM_HIDE_ADMIN'",
8181
"POLICY_SYSTEM_HIDE_SERVICES": "'$POLICY_SYSTEM_HIDE_SERVICES'",
8282
"POLICY_SYSTEM_PASSWORD_RESET": "'$POLICY_SYSTEM_PASSWORD_RESET'",
83+
"POLICY_USER_VIEW_SUSPENDED": "'$POLICY_USER_VIEW_SUSPENDED'",
8384
"POLICY_USER_EDIT_DETAILS": "'$POLICY_USER_EDIT_DETAILS'",
8485
"POLICY_USER_DELETE_LOGS": "'$POLICY_USER_DELETE_LOGS'",
8586
"POLICY_USER_VIEW_LOGS": "'$POLICY_USER_VIEW_LOGS'",

bin/v-suspend-user

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,16 @@ check_hestia_demo_mode
4343
# Action #
4444
#----------------------------------------------------------#
4545

46-
# Adding '!' in front of the password
47-
/usr/sbin/usermod --lock $user
48-
49-
# Suspending ftp accounts
50-
for ftp in $(grep "^${user}_" /etc/passwd |cut -f 1 -d : ); do
51-
/usr/sbin/usermod --lock $ftp 2>/dev/null
52-
done
46+
# Do not restrict access to SFTP/FTP/SSH if POLICY_USER_VIEW_SUSPENDED is set to yes
47+
if [ -z "$POLICY_USER_VIEW_SUSPENDED" ] || [ "$POLICY_USER_VIEW_SUSPENDED" = 'no' ]; then
48+
# Adding '!' in front of the password
49+
/usr/sbin/usermod --lock $user
50+
51+
# Suspending ftp accounts
52+
for ftp in $(grep "^${user}_" /etc/passwd |cut -f 1 -d : ); do
53+
/usr/sbin/usermod --lock $ftp 2>/dev/null
54+
done
55+
fi
5356

5457
# Suspending web domains
5558
if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB_SYSTEM" != 'no' ]; then

bin/v-unsuspend-user

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@ check_hestia_demo_mode
4141
# Action #
4242
#----------------------------------------------------------#
4343

44-
# Deleting '!' in front of the password
45-
/usr/sbin/usermod --unlock $user
46-
47-
# Unsuspending ftp accounts
48-
for ftp in $(grep "^${user}_" /etc/passwd |cut -f 1 -d : ); do
49-
/usr/sbin/usermod --unlock $ftp 2>/dev/null
50-
done
44+
# Do not restrict access to SFTP/FTP/SSH if POLICY_USER_VIEW_SUSPENDED is set to yes
45+
if [ -z "$POLICY_USER_VIEW_SUSPENDED" ] || [ "$POLICY_USER_VIEW_SUSPENDED" = 'no' ]; then
46+
# Deleting '!' in front of the password
47+
/usr/sbin/usermod --unlock $user
48+
49+
# Unsuspending ftp accounts
50+
for ftp in $(grep "^${user}_" /etc/passwd |cut -f 1 -d : ); do
51+
/usr/sbin/usermod --unlock $ftp 2>/dev/null
52+
done
53+
fi
5154

5255
# Changing suspend value
5356
update_user_value "$user" '$SUSPENDED' 'no'

web/edit/server/index.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,17 @@
750750
}
751751
}
752752

753+
// Change POLICY_USER_VIEW_SUSPENDED
754+
if (empty($_SESSION['error_msg'])) {
755+
if ($_POST['v_policy_user_view_suspended'] != $_SESSION['POLICY_USER_VIEW_SUSPENDED']) {
756+
exec (HESTIA_CMD."v-change-sys-config-value POLICY_USER_VIEW_SUSPENDED ".escapeshellarg($_POST['v_policy_user_view_suspended']), $output, $return_var);
757+
check_return_code($return_var,$output);
758+
unset($output);
759+
if (empty($_SESSION['error_msg'])) $v_policy_system_hide_admin = $_POST['v_policy_user_view_suspended'];
760+
$v_security_adv = 'yes';
761+
}
762+
}
763+
753764
// Change POLICY_USER_CHANGE_THEME
754765
if (empty($_SESSION['error_msg'])) {
755766
if ($_POST['v_policy_user_change_theme'] == 'on') { $_POST['v_policy_user_change_theme'] = 'no'; } else { $_POST['v_policy_user_change_theme'] = 'yes'; } {

web/inc/main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function top_panel($user, $TAB) {
155155
unset($output);
156156

157157
// Log out active sessions for suspended users
158-
if ($panel[$user]['SUSPENDED'] === 'yes') {
158+
if (($panel[$user]['SUSPENDED'] === 'yes') && ($_SESSION['POLICY_USER_VIEW_SUSPENDED'] !== 'yes')) {
159159
$_SESSION['error_msg'] = "You have been logged out. Please log in again.";
160160
session_destroy();
161161
header("Location: /login/");

web/templates/pages/edit_server.html

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1059,7 +1059,7 @@
10591059
</tr>
10601060
<tr>
10611061
<td class="vst-text input-label">
1062-
<?php print _('Disable Server Settings access for other administrators');?>
1062+
<?php print _('Do not allow other administrators to access Server Settings');?>
10631063
</td>
10641064
</tr>
10651065
<tr>
@@ -1091,7 +1091,21 @@
10911091
<?=_('Users');?>
10921092
</td>
10931093

1094-
</tr>
1094+
</tr>
1095+
<tr>
1096+
<td class="vst-text input-label">
1097+
<?php print _('Allow suspended users to log in with read-only access');?>
1098+
</td>
1099+
</tr>
1100+
<tr>
1101+
<td>
1102+
<select class="vst-list" name="v_policy_user_view_suspended">
1103+
<option value='yes' <?php if($_SESSION['POLICY_USER_VIEW_SUSPENDED'] !== 'no') echo 'selected' ?>><?php print _('yes'); ?></option>
1104+
<option value='no' <?php if($_SESSION['POLICY_USER_VIEW_SUSPENDED'] == 'no') echo 'selected' ?>><?php print _('no'); ?></option>
1105+
</select>
1106+
<br><br>
1107+
</td>
1108+
</tr>
10951109
<tr>
10961110
<td class="vst-text input-label">
10971111
<?php print _('Allow users to edit their account details');?>

0 commit comments

Comments
 (0)