Skip to content

Commit 2616a6b

Browse files
authored
3354 [Bug]couldn't login with my admin password with the error message : invalid username or password (hestiacp#3356)
* Fix hestiacp#3354 Replace mkpasswd with python3 * Add option via hestia.conf only to disable ip check In some rare cases some users reported experiencing "random" log outs due to random ip changes. This causes users to logout. As this is a security issue it is "disabled" by default and only change able via hestia.conf by the root user. * Update v-list-sys-config
1 parent 7998479 commit 2616a6b

File tree

6 files changed

+23
-5
lines changed

6 files changed

+23
-5
lines changed

bin/v-check-user-password

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,14 @@ if [ -z "$salt" ]; then
8585
fi
8686

8787
if [ "$method" = "yescrypt" ]; then
88-
hash=$(mkpasswd "$password" "$shadow")
88+
if which python3 > /dev/null; then
89+
export PASS="$password" SALT="$shadow"
90+
hash=$(python3 -c 'import crypt, os; print(crypt.crypt(os.getenv("PASS"), os.getenv("SALT")))')
91+
else
92+
# Fall back to mkpasswd as fallback
93+
hash=$(mkpasswd "$password" "$shadow")
94+
fi
95+
8996
if [ $? -ne 0 ]; then
9097
echo "Error: password missmatch"
9198
echo "$date $time $user $ip46 failed to login" >> $HESTIA/log/auth.log

bin/v-list-sys-config

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ json_list() {
100100
"SERVER_SMTP_SECURITY": "'$SERVER_SMTP_SECURITY'",
101101
"SERVER_SMTP_USER": "'$SERVER_SMTP_USER'",
102102
"SERVER_SMTP_PASSWD": "'$SERVER_SMTP_PASSWD'",
103-
"SERVER_SMTP_ADDR": "'$SERVER_SMTP_ADDR'"
103+
"SERVER_SMTP_ADDR": "'$SERVER_SMTP_ADDR'",
104+
"DISABLE_IP_CHECK": "'$DISABLE_IP_CHECK'"
104105
}
105106
}'
106107
}

func/syshealth.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ function syshealth_update_system_config_format() {
198198
# SYSTEM CONFIGURATION
199199
# Create array of known keys in configuration file
200200
system="system"
201-
known_keys="ANTISPAM_SYSTEM ANTIVIRUS_SYSTEM API_ALLOWED_IP API BACKEND_PORT BACKUP_GZIP BACKUP_MODE BACKUP_SYSTEM CRON_SYSTEM DB_PMA_ALIAS DB_SYSTEM DISK_QUOTA DNS_SYSTEM ENFORCE_SUBDOMAIN_OWNERSHIP FILE_MANAGER FIREWALL_EXTENSION FIREWALL_SYSTEM FTP_SYSTEM IMAP_SYSTEM INACTIVE_SESSION_TIMEOUT LANGUAGE LOGIN_STYLE MAIL_SYSTEM PROXY_PORT PROXY_SSL_PORT PROXY_SYSTEM RELEASE_BRANCH STATS_SYSTEM THEME UPDATE_HOSTNAME_SSL UPGRADE_SEND_EMAIL UPGRADE_SEND_EMAIL_LOG WEB_BACKEND WEBMAIL_ALIAS WEBMAIL_SYSTEM WEB_PORT WEB_RGROUPS WEB_SSL WEB_SSL_PORT WEB_SYSTEM VERSION"
201+
known_keys="ANTISPAM_SYSTEM ANTIVIRUS_SYSTEM API_ALLOWED_IP API BACKEND_PORT BACKUP_GZIP BACKUP_MODE BACKUP_SYSTEM CRON_SYSTEM DB_PMA_ALIAS DB_SYSTEM DISK_QUOTA DNS_SYSTEM ENFORCE_SUBDOMAIN_OWNERSHIP FILE_MANAGER FIREWALL_EXTENSION FIREWALL_SYSTEM FTP_SYSTEM IMAP_SYSTEM INACTIVE_SESSION_TIMEOUT LANGUAGE LOGIN_STYLE MAIL_SYSTEM PROXY_PORT PROXY_SSL_PORT PROXY_SYSTEM RELEASE_BRANCH STATS_SYSTEM THEME UPDATE_HOSTNAME_SSL UPGRADE_SEND_EMAIL UPGRADE_SEND_EMAIL_LOG WEB_BACKEND WEBMAIL_ALIAS WEBMAIL_SYSTEM WEB_PORT WEB_RGROUPS WEB_SSL WEB_SSL_PORT WEB_SYSTEM VERSION DISABLE_IP_CHECK"
202202
write_kv_config_file
203203
unset system
204204
unset known_keys
@@ -476,9 +476,13 @@ function syshealth_repair_system_config() {
476476
$BIN/v-change-sys-config-value "POLICY_CSRF_STRICTNESS" "1"
477477
fi
478478
if [[ -z $(check_key_exists 'DNS_CLUSTER_SYSTEM') ]]; then
479-
echo "[ ! ] Adding missing variable to hestia.conf: DNS_CLUSTER_SYSTEM ('')"
479+
echo "[ ! ] Adding missing variable to hestia.conf: DNS_CLUSTER_SYSTEM ('hestia')"
480480
$BIN/v-change-sys-config-value "DNS_CLUSTER_SYSTEM" "hestia"
481481
fi
482+
if [[ -z $(check_key_exists 'DISABLE_IP_CHECK') ]]; then
483+
echo "[ ! ] Adding missing variable to hestia.conf: DISABLE_IP_CHECK ('no')"
484+
$BIN/v-change-sys-config-value "DISABLE_IP_CHECK" "no"
485+
fi
482486

483487
touch $HESTIA/conf/hestia.conf.new
484488
while IFS='= ' read -r lhs rhs; do

install/hst-install-debian.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2103,6 +2103,7 @@ write_config_value "SERVER_SMTP_USER" ""
21032103
write_config_value "SERVER_SMTP_PASSWD" ""
21042104
write_config_value "SERVER_SMTP_ADDR" ""
21052105
write_config_value "POLICY_CSRF_STRICTNESS" "1"
2106+
write_config_value "DISABLE_IP_CHECK" "no"
21062107

21072108
# Add /usr/local/hestia/bin/ to path variable
21082109
echo 'if [ "${PATH#*/usr/local/hestia/bin*}" = "$PATH" ]; then

install/hst-install-ubuntu.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,6 +2154,7 @@ write_config_value "SERVER_SMTP_USER" ""
21542154
write_config_value "SERVER_SMTP_PASSWD" ""
21552155
write_config_value "SERVER_SMTP_ADDR" ""
21562156
write_config_value "POLICY_CSRF_STRICTNESS" "1"
2157+
write_config_value "DISABLE_IP_CHECK" "no"
21572158

21582159
# Add /usr/local/hestia/bin/ to path variable
21592160
echo 'if [ "${PATH#*/usr/local/hestia/bin*}" = "$PATH" ]; then

web/inc/main.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ function destroy_sessions() {
6666
}
6767

6868
// Checking user to use session from the same IP he has been logged in
69-
if ($_SESSION["user_combined_ip"] != $user_combined_ip && isset($_SESSION["user"])) {
69+
if (
70+
$_SESSION["user_combined_ip"] != $user_combined_ip &&
71+
isset($_SESSION["user"]) &&
72+
$_SESSION["DISABLE_IP_CHECK"] != "yes"
73+
) {
7074
$v_user = quoteshellarg($_SESSION["user"]);
7175
$v_session_id = quoteshellarg($_SESSION["token"]);
7276
exec(HESTIA_CMD . "v-log-user-logout " . $v_user . " " . $v_session_id, $output, $return_var);

0 commit comments

Comments
 (0)