While reviewing support for lmtp as transport one thing I forgot to
test was adding a lmtp-transport pointing to an IPv6 address.
Using the use_mx flag (which only makes sense for domain-names) to
provide the information of whether the next-hop/hostname should be
written out in square brackets or not is a bit confusing, and leads
to ambiguous results when providing ipv6 literal addresses:
> host: 2001:db8:25::25
> port: 24
> gets rendered as
> lmtp:inet:2001:db8:25::25:24
Which postfix oddly enough parses 'correctly'; postfix splits on ':'
and uses the last part as port. For ip4 literals and dns-names this
works for ip6 literals it only works if you provide a port so it
makes more sense to always write ip(4|6) literals in brackets
By introducing a explicit flag "$bracket_host" and reordering the
conditions lmtp and smtp entries get rendered correctly (see `man
smtp`).
Additionally fixes an indentation glitch in read_transport_map.
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-By: Dominik Csapak <d.csapak@proxmox.com>
$host = $1;
$use_mx = 0;
}
$host = $1;
$use_mx = 0;
}
- $use_mx = 0 if ($protocol eq "lmtp");
+ $use_mx = 0 if ($protocol eq "lmtp");
eval { PVE::JSONSchema::pve_verify_address($host); };
if (my $err = $@) {
eval { PVE::JSONSchema::pve_verify_address($host); };
if (my $err = $@) {
if defined($comment) && $comment !~ m/^\s*$/;
my $use_mx = $data->{use_mx};
if defined($comment) && $comment !~ m/^\s*$/;
my $use_mx = $data->{use_mx};
- $use_mx = 0 if $data->{host} =~ m/^(?:$IPV4RE|$IPV6RE)$/;
+ my $bracket_host = ! $use_mx;
if ($data->{protocol} eq 'lmtp') {
if ($data->{protocol} eq 'lmtp') {
$data->{protocol} .= ":inet";
}
$data->{protocol} .= ":inet";
}
+ $bracket_host = 1 if $data->{host} =~ m/^(?:$IPV4RE|$IPV6RE)$/i;
+
+ if ($bracket_host) {
- $filename, $fh, "$data->{domain} $data->{protocol}:$data->{host}:$data->{port}\n");
+ $filename, $fh, "$data->{domain} $data->{protocol}:[$data->{host}]:$data->{port}\n");
} else {
PVE::Tools::safe_print(
} else {
PVE::Tools::safe_print(
- $filename, $fh, "$data->{domain} $data->{protocol}:[$data->{host}]:$data->{port}\n");
+ $filename, $fh, "$data->{domain} $data->{protocol}:$data->{host}:$data->{port}\n");