summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2008-11-22 20:26:09 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2008-11-22 20:26:09 +0000
commit1f7fa548404d88d6545729694cab86cd18ee7fec (patch)
tree971e64b84fc862d33858f7ba6cba589c6edfdc84
parent86d10d125a927309b03c83721547d3b7d2b1460c (diff)
- allow the optionnal ssmtp keywork in "relay via" rules, while at it
allow port to become optionnal (implicit 25) or provided by value or name.
-rw-r--r--usr.sbin/smtpd/parse.y19
1 files changed, 10 insertions, 9 deletions
diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y
index 38f220a2b0e..9052083e7c9 100644
--- a/usr.sbin/smtpd/parse.y
+++ b/usr.sbin/smtpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.9 2008/11/13 23:24:19 gilles Exp $ */
+/* $OpenBSD: parse.y,v 1.10 2008/11/22 20:26:08 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -651,17 +651,18 @@ action : DELIVER TO MAILDIR STRING {
| RELAY {
rule->r_action = A_RELAY;
}
- | RELAY VIA STRING PORT NUMBER {
+ | RELAY VIA ssmtp STRING port {
rule->r_action = A_RELAYVIA;
- if (strlcpy(rule->r_value.host.hostname, $3, MAXHOSTNAMELEN)
+ if (strlcpy(rule->r_value.host.hostname, $4, MAXHOSTNAMELEN)
>= MAXHOSTNAMELEN)
fatal("hostname too long");
- if ($5 <= 0 || $5 >= (int)USHRT_MAX) {
- yyerror("invalid port: %d", $5);
- YYERROR;
- }
- rule->r_value.host.port = $5;
- free($3);
+
+ if ($5 == 0)
+ rule->r_value.host.port = htons(25);
+ else
+ rule->r_value.host.port = htons($5);
+
+ free($4);
}
;