diff options
author | Eric Faurot <eric@faurot.net> | 2013-10-10 12:13:57 +0200 |
---|---|---|
committer | Eric Faurot <eric@faurot.net> | 2013-10-10 12:13:57 +0200 |
commit | 350bcde7481388736632dd56337226af4d6fd5d7 (patch) | |
tree | dbd506ce73d4bf8049e10e9cbef06168a9d9cfd4 /smtpd/mta.c | |
parent | missing stat counter update (diff) | |
download | OpenSMTPD-350bcde7481388736632dd56337226af4d6fd5d7.tar.xz OpenSMTPD-350bcde7481388736632dd56337226af4d6fd5d7.zip |
Allow to specify a hostname on relay rule:opensmtpd-201310101757
accept ... relay hostname "foobar"
Tweak the on-disk envelope format a bit, but make update seamless
for existing envelopes.
Diffstat (limited to 'smtpd/mta.c')
-rw-r--r-- | smtpd/mta.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/smtpd/mta.c b/smtpd/mta.c index 59592695..03ab187c 100644 --- a/smtpd/mta.c +++ b/smtpd/mta.c @@ -1572,6 +1572,9 @@ mta_relay(struct envelope *e) key.helotable = e->agent.mta.relay.helotable; if (!key.helotable[0]) key.helotable = NULL; + key.heloname = e->agent.mta.relay.heloname; + if (!key.heloname[0]) + key.heloname = NULL; if ((r = SPLAY_FIND(mta_relay_tree, &relays, &key)) == NULL) { r = xcalloc(1, sizeof *r, "mta_relay"); @@ -1594,6 +1597,9 @@ mta_relay(struct envelope *e) if (key.helotable) r->helotable = xstrdup(key.helotable, "mta: helotable"); + if (key.heloname) + r->heloname = xstrdup(key.heloname, + "mta: heloname"); SPLAY_INSERT(mta_relay_tree, &relays, r); stat_increment("mta.relay", 1); } else { @@ -1635,6 +1641,7 @@ mta_relay_unref(struct mta_relay *relay) free(relay->backupname); free(relay->cert); free(relay->helotable); + free(relay->heloname); free(relay->secret); free(relay->sourcetable); @@ -1707,6 +1714,12 @@ mta_relay_to_text(struct mta_relay *relay) strlcat(buf, relay->helotable, sizeof buf); } + if (relay->heloname) { + strlcat(buf, sep, sizeof buf); + strlcat(buf, "heloname=", sizeof buf); + strlcat(buf, relay->heloname, sizeof buf); + } + strlcat(buf, "]", sizeof buf); return (buf); @@ -1844,6 +1857,12 @@ mta_relay_cmp(const struct mta_relay *a, const struct mta_relay *b) return (1); if (a->helotable && ((r = strcmp(a->helotable, b->helotable)))) return (r); + if (a->heloname == NULL && b->heloname) + return (-1); + if (a->heloname && b->heloname == NULL) + return (1); + if (a->heloname && ((r = strcmp(a->heloname, b->heloname)))) + return (r); if (a->cert == NULL && b->cert) return (-1); |