Skip to content

Commit a241853

Browse files
authored
Merge branch 'staging/features' into feature/1089-proftpd_tls_support
2 parents ec68a01 + 6825a8e commit a241853

File tree

13 files changed

+114
-10
lines changed

13 files changed

+114
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ All notable changes to this project will be documented in this file.
1010
- `UPGRADE_SEND_EMAIL_LOG` = Sends installation log output to admin email address
1111
- Upgrade process will now save logs to the `hst_backups` directory.
1212
- Add support Proftpd TLS Support
13+
- Add the possibility to assign user "Administrators" rights on login. Replaces "root" login. Notifications are only send towards the "admin" account email
14+
15+
## Buggfixes
16+
- Removed root login (root / root password )
1317

1418
## Bugfixes
1519

bin/v-change-user-package

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ RKEY='$RKEY'
104104
TWOFA='$TWOFA'
105105
QRCODE='$QRCODE'
106106
PHPCLI='$PHPCLI'
107+
ROLE='$ROLE'
107108
SUSPENDED='$SUSPENDED'
108109
SUSPENDED_USERS='$SUSPENDED_USERS'
109110
SUSPENDED_WEB='$SUSPENDED_WEB'

bin/v-change-user-role

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
# info: updates user role
3+
# options: USER ROLE
4+
5+
#----------------------------------------------------------#
6+
# Variable&Function #
7+
#----------------------------------------------------------#
8+
9+
# Argument definition
10+
user=$1
11+
role=$2
12+
13+
14+
# Includes
15+
source $HESTIA/func/main.sh
16+
source $HESTIA/conf/hestia.conf
17+
18+
19+
#----------------------------------------------------------#
20+
# Verifications #
21+
#----------------------------------------------------------#
22+
23+
# Reading user values
24+
source $USER_DATA/user.conf
25+
26+
is_format_valid 'user' 'role'
27+
is_object_valid 'user' 'USER' "$user"
28+
29+
is_object_unsuspended 'user' 'USER' "$user"
30+
31+
#----------------------------------------------------------#
32+
# Action #
33+
#----------------------------------------------------------#
34+
35+
update_user_value "$user" '$ROLE' "$role"
36+
37+
38+
#----------------------------------------------------------#
39+
# Hestia #
40+
#----------------------------------------------------------#
41+
42+
exit

bin/v-get-user-salt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ check_args '1' "$#" 'USER [IP] [SALT]'
6161
is_format_valid 'user'
6262

6363
# Checking user
64-
if [ ! -d "$HESTIA/data/users/$user" ] && [ "$user" != 'root' ]; then
64+
if [ ! -d "$HESTIA/data/users/$user" ]; then
6565
echo "Error: password missmatch"
6666
echo "$date $time $user $ip failed to login" >> $HESTIA/log/auth.log
6767
exit 9

bin/v-list-user

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ json_list() {
4545
"RKEY": "'$RKEY'",
4646
"TWOFA": "'$TWOFA'",
4747
"QRCODE": "'$QRCODE'",
48+
"ROLE": "'$ROLE'",
4849
"SUSPENDED": "'$SUSPENDED'",
4950
"SUSPENDED_USERS": "'$SUSPENDED_USERS'",
5051
"SUSPENDED_WEB": "'$SUSPENDED_WEB'",

func/main.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,13 @@ is_object_format_valid() {
890890
fi
891891
}
892892

893+
# Role validator
894+
is_role_valid (){
895+
if ! [[ "$1" =~ ^admin|user$ ]]; then
896+
check_result $E_INVALID "invalid $2 format :: $1"
897+
fi
898+
}
899+
893900
# Password validator
894901
is_password_format_valid() {
895902
if [ "${#1}" -lt '6' ]; then
@@ -979,6 +986,7 @@ is_format_valid() {
979986
quota) is_int_format_valid "$arg" 'quota' ;;
980987
record) is_common_format_valid "$arg" 'record';;
981988
restart) is_boolean_format_valid "$arg" 'restart' ;;
989+
role) is_role_valid "$arg" 'role' ;;
982990
rtype) is_dns_type_format_valid "$arg" ;;
983991
rule) is_int_format_valid "$arg" "rule id" ;;
984992
service) is_service_format_valid "$arg" "$arg_name" ;;

func/rebuild.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ rebuild_user_conf() {
3131
if [ -z "${PHPCLI+x}" ]; then
3232
sed -i "/QRCODE/a PHPCLI=''" $USER_DATA/user.conf
3333
fi
34+
if [ -z "${ROLE+x}" ]; then
35+
sed -i "/PHPCLI/a ROLE='user'" $USER_DATA/user.conf
36+
fi
3437
# Run template trigger
3538
if [ -x "$HESTIA/data/packages/$PACKAGE.sh" ]; then
3639
$HESTIA/data/packages/$PACKAGE.sh "$user" "$CONTACT" "$NAME"

web/add/user/index.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@
7777
unset($output);
7878
}
7979

80+
// Set Role
81+
if (empty($_SESSION['error_msg'])) {
82+
$v_role = escapeshellarg($_POST['v_role']);
83+
exec (HESTIA_CMD."v-change-user-role ".$v_username." ".$v_role, $output, $return_var);
84+
check_return_code($return_var,$output);
85+
unset($output);
86+
}
87+
8088
// Send email to the new user
8189
if ((empty($_SESSION['error_msg'])) && (!empty($v_notify))) {
8290
$to = $_POST['v_notify'];

web/edit/user/index.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
$v_twofa = $data[$v_username]['TWOFA'];
3939
$v_qrcode = $data[$v_username]['QRCODE'];
4040
$v_phpcli = $data[$v_username]['PHPCLI'];
41+
$v_role = $data[$v_username]['ROLE'];
4142
$v_ns = $data[$v_username]['NS'];
4243
$nameservers = explode(",", $v_ns);
4344
$v_ns1 = $nameservers[0];
@@ -157,7 +158,14 @@
157158
check_return_code($return_var,$output);
158159
unset($output);
159160
}
160-
161+
// Change Role (admin only)
162+
if (($v_role != $_POST['$v_role']) && ($_SESSION['user'] == 'admin') && (empty($_SESSION['error_msg']))) {
163+
$v_role = escapeshellarg($_POST['v_role']);
164+
exec (HESTIA_CMD."v-change-user-role ".escapeshellarg($v_username)." ".$v_role, $output, $return_var);
165+
check_return_code($return_var,$output);
166+
unset($output);
167+
$v_role = $_POST['v_role'];
168+
}
161169
// Change language
162170
if (($v_language != $_POST['v_language']) && (empty($_SESSION['error_msg']))) {
163171
$v_language = escapeshellarg($_POST['v_language']);

web/inc/i18n/en.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
'STARTTLS' => 'STARTTLS',
229229
'Normal password' => 'Normal Password',
230230
'database' => 'Database',
231-
'User' => 'Username',
231+
'User' => 'User',
232232
'Host' => 'Hostname',
233233
'Charset' => 'Charset',
234234
'Min' => 'Minute',

0 commit comments

Comments
 (0)