File tree Expand file tree Collapse file tree 3 files changed +73
-5
lines changed
Expand file tree Collapse file tree 3 files changed +73
-5
lines changed Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # info: check user password
3+ # options: TYPE PASSWORD HASH
4+ #
5+ # example: v-check-mail-account-hash ARGONID2 PASS HASH
6+ #
7+ # This function verifies email account password hash
8+
9+ # ----------------------------------------------------------#
10+ # Variables & Functions #
11+ # ----------------------------------------------------------#
12+
13+ # Argument definition
14+ type=$1
15+ password=$2 ; HIDE=2
16+ hash=$3 ; HIDE=2
17+
18+ # Includes
19+ # shellcheck source=/etc/hestiacp/hestia.conf
20+ source /etc/hestiacp/hestia.conf
21+ # shellcheck source=/usr/local/hestia/func/main.sh
22+ source $HESTIA /func/main.sh
23+ # load config file
24+ source_conf " $HESTIA /conf/hestia.conf"
25+
26+ # ----------------------------------------------------------#
27+ # Verifications #
28+ # ----------------------------------------------------------#
29+
30+ check_args ' 3' " $# " ' TYPE PASS HASH'
31+
32+ is_password_valid
33+
34+ # ----------------------------------------------------------#
35+ # Action #
36+ # ----------------------------------------------------------#
37+
38+ if [ " $type " = " ARGONID2" ]; then
39+ match=$( doveadm pw -s ARGON2ID -p $password -t $hash | grep " verified" ) ;
40+ if [ -n " $match " ]; then
41+ exit 0;
42+ else
43+ echo $match ;
44+ exit 2;
45+ fi
46+ else
47+ echo " Not supported"
48+ exit 2;
49+ fi
50+
51+ # ----------------------------------------------------------#
52+ # Hestia #
53+ # ----------------------------------------------------------#
54+
55+ exit
Original file line number Diff line number Diff line change @@ -1475,6 +1475,18 @@ function check_ip_not_banned(){
14751475 assert_failure $E_EXISTS
14761476}
14771477
1478+ @test " MAIL: change mail account password" {
1479+ run curl -k -X POST -d " email=test@$domain &password=$userpass2 &new=123456" https://localhost:8083/reset/mail/
1480+ assert_success
1481+ assert_output --partial " ==ok=="
1482+ }
1483+
1484+ @test " MAIL: change mail account password (Incorrect PW)" {
1485+ run curl -k -X POST -d " email=test@$domain &password=$userpass2 &new=123456" https://localhost:8083/reset/mail/
1486+ assert_success
1487+ assert_output --partial " error"
1488+ }
1489+
14781490@test " MAIL: Delete account" {
14791491 run v-delete-mail-account $user $domain test
14801492 assert_success
Original file line number Diff line number Diff line change @@ -148,11 +148,12 @@ function to64 ($v, $n)
148148 $ n_hash = '{MD5} ' .$ n_hash ;
149149 }else {
150150 $ v_password = escapeshellarg ($ v_password );
151- exec ("doveadm pw -s ARGON2ID -p $ v_password -t ' $ v_hash' " , $ output , $ return_var );
152- if ($ return_var == 0 ) {
153- if (strpos ($ output , "(verified) " ) !== 0 ){
154- $ n_hash = $ v_hash ;
155- }
151+ $ s_hash = escapeshellarg ($ v_hash );
152+ exec (HESTIA_CMD ."v-check-mail-account-hash ARGONID2 " . $ v_password ." " . $ s_hash , $ output , $ return_var );
153+ if ($ return_var != 0 ){
154+ $ n_hash = '' ;
155+ }else {
156+ $ n_hash = $ v_hash ;
156157 }
157158 }
158159 // Change password
You can’t perform that action at this time.
0 commit comments