Fix --mx host:port parsing and incorrect no-MX message (#2986)#3049
Merged
Conversation
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.
Closed
Collaborator
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2986.
--mx <host>:<port>confused the parser:--mxsetsPORT=25unconditionally, and the trailing:porton the domain was never stripped before the MX DNS lookup — sohost -t MX example.com:25returned nothing, and the failure branch then printed$1(the run date) instead of the host, e.g.20260606-1200 has no MX records(s).This:
:<port>off the domain before theget_mx_recordlookup (bash parameter expansion, no extra fork) and uses it as the port under test;$domainandMX record(s)(typo).Tested against multiple hosts with and without an appended
:port(e.g.--mx google.com:25now resolves the MX and proceeds on port 25); plain--mx example.combehaviour is unchanged.shellcheck -x -P utils --severity=errorclean andbash -nclean on the change; five-space/no-tabs convention followed.