Skip to content

Commit fb34e24

Browse files
Improve password loading in password_valid (hestiacp#2739)
* Fix some small bugs in upgrade scripts * Fix issue with spaces in password * Prevent password_valid access other files Only limit to tmp folder * Add spacing. Co-authored-by: Raphael <rs@scit.ch>
1 parent 8613f15 commit fb34e24

File tree

6 files changed

+28
-21
lines changed

6 files changed

+28
-21
lines changed

bin/v-add-mail-account

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ check_hestia_demo_mode
6868
# Generating hashed password
6969
if [ -n "$(doveadm pw -l | grep ARGON2ID)" ]; then
7070
set +H # disable ! style history substitution
71-
md5="$(doveadm pw -s ARGON2ID -p $password)"
71+
md5="$(doveadm pw -s ARGON2ID -p "$password")"
7272
else
7373
# Fall back on MD5
7474
salt=$(generate_password "$PW_MATRIX" "8")

bin/v-change-mail-account-password

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ check_hestia_demo_mode
5858
# Generating hashed password
5959
if [ -n "$(doveadm pw -l | grep ARGON2ID)" ]; then
6060
set +H # disable ! style history substitution
61-
md5="$(doveadm pw -s ARGON2ID -p $password)"
61+
md5="$(doveadm pw -s ARGON2ID -p "$password")"
6262
else
6363
salt=$(generate_password "$PW_MATRIX" "8")
6464
md5="{MD5}$($BIN/v-generate-password-hash md5 $salt <<<$password)"

bin/v-check-mail-account-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ is_password_valid
3636
#----------------------------------------------------------#
3737

3838
if [ "$type" = "ARGONID2" ]; then
39-
match=$(doveadm pw -s ARGON2ID -p $password -t $hash | grep "verified");
39+
match=$(doveadm pw -s ARGON2ID -p "$password" -t $hash | grep "verified");
4040
if [ -n "$match" ]; then
4141
exit 0;
4242
else

func/main.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,17 +414,22 @@ is_object_value_exist() {
414414
# Check if password is transmitted via file
415415
is_password_valid() {
416416
if [[ "$password" =~ ^/tmp/ ]]; then
417-
if [ -f "$password" ]; then
418-
password="$(head -n1 $password)"
417+
if ! [[ "$password" == *../* ]]; then
418+
if [ -f "$password" ]; then
419+
password="$(head -n1 $password)"
420+
fi
419421
fi
420422
fi
423+
echo $password;
421424
}
422425

423426
# Check if hash is transmitted via file
424427
is_hash_valid() {
425428
if [[ "$hash" =~ ^/tmp/ ]]; then
426-
if [ -f "$hash" ]; then
427-
hash="$(head -n1 $hash)"
429+
if ! [[ "$hash" == *../* ]]; then
430+
if [ -f "$hash" ]; then
431+
hash="$(head -n1 $hash)"
432+
fi
428433
fi
429434
fi
430435
}

install/upgrade/versions/1.6.2.sh

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,18 @@ upgrade_config_set_value 'UPGRADE_UPDATE_MAIL_TEMPLATES' 'no'
2121
upgrade_config_set_value 'UPGRADE_REBUILD_USERS' 'no'
2222
upgrade_config_set_value 'UPGRADE_UPDATE_FILEMANAGER_CONFIG' 'false'
2323

24-
alc=$(cat /etc/exim4/exim4.conf.template | grep '${lookup{${domain:$authenticated_id}}dsearch{/etc/exim4/domains/}}/limits');
25-
if [ -z "$alc" ]; then
26-
sed -i 's| set acl_c_msg_limit|#string1\n#replaceme|' /etc/exim4/exim4.conf.template
27-
sed -i '/#replaceme/d' /etc/exim4/exim4.conf.template
28-
sed -i 's|#string1|set acl_c_msg_limit = \${if exists{/etc/exim4/domains/\${lookup{\${domain:\$authenticated_id}}dsearch{/etc/exim4/domains/}}/limits}{\${lookup {\$authenticated_id} lsearch{/etc/exim4/domains/\${lookup{${domain:\$authenticated_id}}dsearch{/etc/exim4/domains/}}/limits}{\$value}{\${readfile{/etc/exim4/limit.conf}}}}}{\${readfile{/etc/exim4/limit.conf}}} }|g' /etc/exim4/exim4.conf.template
29-
fi
30-
31-
system_filter=$(cat /etc/exim4/exim4.conf.template | grep 'system_filter');
32-
if [ -z "$system_filter" ]; then
33-
sed -i '/SMTP_RELAY_PASS = \${lookup{pass}lsearch{SMTP_RELAY_FILE}}/a #shouldberemoved\n# Custom Filter\nsystem_filter = \/etc\/exim4\/system.filter\nsystem_filter_user = Debian-exim' /etc/exim4/exim4.conf.template
34-
# Keep the spacing between the reley_pass and Custom Filter we need to insert a dummy text and remove it later on
35-
sed -i 's/#shouldberemoved//g' /etc/exim4/exim4.conf.template
36-
fi
24+
if [ "$MAIL_SYSTEM" == "exim4" ]; then
25+
alc=$(cat /etc/exim4/exim4.conf.template | grep '${lookup{${domain:$authenticated_id}}dsearch{/etc/exim4/domains/}}/limits');
26+
if [ -z "$alc" ]; then
27+
sed -i 's| set acl_c_msg_limit|#string1\n#replaceme|' /etc/exim4/exim4.conf.template
28+
sed -i '/#replaceme/d' /etc/exim4/exim4.conf.template
29+
sed -i 's|#string1|set acl_c_msg_limit = \${if exists{/etc/exim4/domains/\${lookup{\${domain:\$authenticated_id}}dsearch{/etc/exim4/domains/}}/limits}{\${lookup {\$authenticated_id} lsearch{/etc/exim4/domains/\${lookup{${domain:\$authenticated_id}}dsearch{/etc/exim4/domains/}}/limits}{\$value}{\${readfile{/etc/exim4/limit.conf}}}}}{\${readfile{/etc/exim4/limit.conf}}} }|g' /etc/exim4/exim4.conf.template
30+
fi
31+
32+
system_filter=$(cat /etc/exim4/exim4.conf.template | grep 'system_filter');
33+
if [ -z "$system_filter" ]; then
34+
sed -i '/SMTP_RELAY_PASS = \${lookup{pass}lsearch{SMTP_RELAY_FILE}}/a #shouldberemoved\n# Custom Filter\nsystem_filter = \/etc\/exim4\/system.filter\nsystem_filter_user = Debian-exim' /etc/exim4/exim4.conf.template
35+
# Keep the spacing between the reley_pass and Custom Filter we need to insert a dummy text and remove it later on
36+
sed -i 's/#shouldberemoved//g' /etc/exim4/exim4.conf.template
37+
fi
38+
fi

install/upgrade/versions/1.6.3.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ upgrade_config_set_value 'UPGRADE_UPDATE_MAIL_TEMPLATES' 'yes'
2121
upgrade_config_set_value 'UPGRADE_REBUILD_USERS' 'yes'
2222
upgrade_config_set_value 'UPGRADE_UPDATE_FILEMANAGER_CONFIG' 'false'
2323

24-
if [ -f /etc/exim4/exim4.conf.template ]; then
24+
if [ "$MAIL_SYSTEM" == "exim4" ]; then
2525
host=$(cat /etc/exim4/exim4.conf.template | grep hosts_try_fastopen);
2626
if [ -z "$host" ]; then
2727
echo "[ * ] Fix an issue with sending large attachments to Google / Gmail"

0 commit comments

Comments
 (0)