mirror of
https://github.com/drwetter/testssl.sh.git
synced 2026-06-23 08:47:38 +02:00
Fix --mx host:port parsing and incorrect no-MX message (#2986)
When a port was appended to the domain (e.g. "--mx example.com:25"), the suffix was passed straight into the MX DNS lookup, so no MX records were found. Strip a trailing :port off the domain before the lookup and use it as the port to test. Also fix the no-MX message, which printed $1 (the run date) instead of the domain, plus a "records(s)" typo.
This commit is contained in:
+10
-4
@@ -23652,21 +23652,27 @@ draw_line() {
|
|||||||
|
|
||||||
run_mx_all_ips() {
|
run_mx_all_ips() {
|
||||||
local fname_date="$1"
|
local fname_date="$1"
|
||||||
|
local domain="$2"
|
||||||
local mxs mx
|
local mxs mx
|
||||||
local mxport
|
local mxport=${3:-25}
|
||||||
local -i ret=0
|
local -i ret=0
|
||||||
local word=""
|
local word=""
|
||||||
|
|
||||||
STARTTLS_PROTOCOL="smtp"
|
STARTTLS_PROTOCOL="smtp"
|
||||||
|
# A port may be appended to the domain, e.g. "--mx example.com:587" (#2986).
|
||||||
|
# Strip it off before the MX DNS lookup and use it as the port to test.
|
||||||
|
if [[ "$domain" =~ :[0-9]+$ ]]; then
|
||||||
|
mxport="${domain##*:}"
|
||||||
|
domain="${domain%:*}"
|
||||||
|
fi
|
||||||
# test first higher priority servers
|
# test first higher priority servers
|
||||||
mxs=$(get_mx_record "$2" | sort -n | sed -e 's/^.* //' -e 's/\.$//' | tr '\n' ' ')
|
mxs=$(get_mx_record "$domain" | sort -n | sed -e 's/^.* //' -e 's/\.$//' | tr '\n' ' ')
|
||||||
if [[ $CMDLINE_IP == one ]]; then
|
if [[ $CMDLINE_IP == one ]]; then
|
||||||
word="as instructed one" # with highest priority
|
word="as instructed one" # with highest priority
|
||||||
mxs=${mxs%% *}
|
mxs=${mxs%% *}
|
||||||
else
|
else
|
||||||
word="the only"
|
word="the only"
|
||||||
fi
|
fi
|
||||||
mxport=${3:-25}
|
|
||||||
if [[ -n "$LOGFILE" ]] || [[ -n "$PARENT_LOGFILE" ]]; then
|
if [[ -n "$LOGFILE" ]] || [[ -n "$PARENT_LOGFILE" ]]; then
|
||||||
prepare_logging "${fname_date}"
|
prepare_logging "${fname_date}"
|
||||||
else
|
else
|
||||||
@@ -23707,7 +23713,7 @@ run_mx_all_ips() {
|
|||||||
outln
|
outln
|
||||||
pr_bold "Done testing all MX records (on port $mxport): "; outln "$mxs"
|
pr_bold "Done testing all MX records (on port $mxport): "; outln "$mxs"
|
||||||
else
|
else
|
||||||
prln_bold " $1 has no MX records(s)"
|
prln_bold " $domain has no MX record(s)"
|
||||||
fi
|
fi
|
||||||
return $ret
|
return $ret
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user