• Omar Polo [2023-12-15 10:04]:
Hi,
On 2023/12/14 23:15:53 +0000, gil...@poolp.org wrote:
hello,
fyi,
if the first line of a file used to feed a table is @list, then
it forces parsing to consider content as a serie of values, not
a serie of key-value.
Yeah, the @list special comment is handy to avoid ambiguities between
key-value and list tables. However, in this specific case, the helo-src
table, we can't use a list table, we need a kp-table.
In my previous mail I failed to realize that the colon is needed for
aliases(5) so we can't "just" get rid of it. (thanks Kirill for making
me noticing it -- I completely forgot that file tables split on : too.)
I don't have any other ideas. Maybe we can try to be 'smart' and not
split on : if the line starts with a "[" character, or maybe that's just
too magic.
split on : only if it is followed by whitespace would work, no?
and make sure ipv6 addresses are enclosed in [], to avoid confusion with
addresses ending in ::
P.S.:
[...]
After a closer look I noticed that there might be something wrong with
my diff, tracing table_static_priv_add() i noticed a weird 'pattern':
: adding [fe80::fce1:baff:fed3:6e35%tap0] -> (null)
: adding [[fe80::fce1:baff:fed3:6e35%tap0]] -> (null)
: adding [ipv6:[fe80::fce1:baff:fed3:6e35%tap0]] -> (null)
that I'm not sure was present also before, so I'll have to take a closer
look.
This is due to config.c:set_localaddrs wrapping the result from
ss_to_text() in brackets. Do you remember why it is needed?
ss_to_text() already wraps ipv6 addresses in [...] (without the ipv6:
"prefix" though.)
Thanks,
Omar Polo
diff /home/op/tmp/smtpd
commit - 59829af3c4da38e511c4f8e3e4a38e45fcf3b082
path + /home/op/tmp/smtpd
blob - a93e09cb6cf315d1e518de697912d1e43d8695da
file + config.c
--- config.c
+++ config.c
@@ -171,7 +171,6 @@ set_localaddrs(struct smtpd *conf, struct table *local
struct sockaddr_in *sain;
struct sockaddr_in6 *sin6;
struct table *t;
- char buf[NI_MAXHOST + 5];
t = table_create(conf, "static", "<anyhost>", NULL);
table_add(t, "local", NULL);
@@ -194,8 +193,6 @@ set_localaddrs(struct smtpd *conf, struct table *local
sain->sin_len = sizeof(struct sockaddr_in);
table_add(t, ss_to_text(&ss), NULL);
table_add(localnames, ss_to_text(&ss), NULL);
- (void)snprintf(buf, sizeof buf, "[%s]",
ss_to_text(&ss));
- table_add(localnames, buf, NULL);
break;
case AF_INET6:
@@ -215,10 +212,6 @@ set_localaddrs(struct smtpd *conf, struct table *local
#endif
table_add(t, ss_to_text(&ss), NULL);
table_add(localnames, ss_to_text(&ss), NULL);
- (void)snprintf(buf, sizeof buf, "[%s]",
ss_to_text(&ss));
- table_add(localnames, buf, NULL);
- (void)snprintf(buf, sizeof buf, "[ipv6:%s]",
ss_to_text(&ss));
- table_add(localnames, buf, NULL);
break;
}
}