From 567cbc2bb44ed7a2c477b0787d4ccd50e8ebecf2 Mon Sep 17 00:00:00 2001 From: Eric Faurot Date: Tue, 21 Aug 2012 20:19:47 +0000 Subject: Allow smtpd to work as a backup MX, relaying only to MXs with higher priority in the DNS record. For example: accept for domain "foo.org" relay backup "mx3.foo.org" will relay mails for "foo.org" using only hosts with higher priority (i.e. lower value) than "mx3.foo.org", which is supposed to be the current server. If the specified backup MX is not found in the DNS record, relaying works as normal. ok gilles@ --- usr.sbin/smtpd/parse.y | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'usr.sbin/smtpd/parse.y') diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y index 1a2e6c11165..aee31596a91 100644 --- a/usr.sbin/smtpd/parse.y +++ b/usr.sbin/smtpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.90 2012/08/19 14:16:58 chl Exp $ */ +/* $OpenBSD: parse.y,v 1.91 2012/08/21 20:19:46 eric Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -124,7 +124,7 @@ typedef struct { %token AS QUEUE INTERVAL SIZE LISTEN ON ALL PORT EXPIRE %token MAP HASH LIST SINGLE SSL SMTPS CERTIFICATE %token DB PLAIN DOMAIN SOURCE -%token RELAY VIA DELIVER TO MAILDIR MBOX HOSTNAME +%token RELAY BACKUP VIA DELIVER TO MAILDIR MBOX HOSTNAME %token ACCEPT REJECT INCLUDE ERROR MDA FROM FOR %token ARROW ENABLE AUTH TLS LOCAL VIRTUAL TAG ALIAS FILTER %token STRING @@ -887,6 +887,14 @@ action : DELIVER TO MAILDIR user { rule->r_action = A_RELAY; rule->r_as = $2; } + | RELAY BACKUP STRING relay_as { + rule->r_action = A_RELAY; + rule->r_as = $4; + rule->r_value.relayhost.flags |= F_BACKUP; + strlcpy(rule->r_value.relayhost.hostname, $3, + sizeof (rule->r_value.relayhost.hostname)); + free($3); + } | RELAY VIA STRING certname credentials relay_as { rule->r_action = A_RELAYVIA; rule->r_as = $6; @@ -1093,6 +1101,7 @@ lookup(char *s) { "all", ALL }, { "as", AS }, { "auth", AUTH }, + { "backup", BACKUP }, { "certificate", CERTIFICATE }, { "db", DB }, { "deliver", DELIVER }, -- cgit v1.2.3