summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2009-01-04 16:40:59 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2009-01-04 16:40:59 +0000
commit3a9239d3714ea270c4025beef438c5a2935dea14 (patch)
tree60d7212adccc9c03cba02fd5bb59d20e5fe78f21 /usr.sbin
parentfb415ea1b5e64ff362890f4e0e4ac359b16b5403 (diff)
- change name of "masked" member in struct netaddr, it was misleading
- allow "from all" so that the ugly "accept from { 0.0.0.0/0, ::/0 }" construct becomes a nice looking "accept from all" ok jacekm@
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/smtpd/mfa.c8
-rw-r--r--usr.sbin/smtpd/parse.y70
-rw-r--r--usr.sbin/smtpd/smtpd.h4
3 files changed, 65 insertions, 17 deletions
diff --git a/usr.sbin/smtpd/mfa.c b/usr.sbin/smtpd/mfa.c
index 975d125ac7c..9b330002dea 100644
--- a/usr.sbin/smtpd/mfa.c
+++ b/usr.sbin/smtpd/mfa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfa.c,v 1.7 2009/01/04 14:46:14 jacekm Exp $ */
+/* $OpenBSD: mfa.c,v 1.8 2009/01/04 16:40:58 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -455,11 +455,11 @@ mfa_match_mask(struct sockaddr_storage *ss, struct netaddr *ssmask)
int i;
bzero(&mask, sizeof(mask));
- for (i = 0; i < (128 - ssmask->masked) / 8; i++)
+ for (i = 0; i < (128 - ssmask->bits) / 8; i++)
mask.s6_addr[i] = 0xff;
- i = ssmask->masked % 8;
+ i = ssmask->bits % 8;
if (i)
- mask.s6_addr[ssmask->masked / 8] = 0xff00 >> i;
+ mask.s6_addr[ssmask->bits / 8] = 0xff00 >> i;
in = &((struct sockaddr_in6 *)ss)->sin6_addr;
inmask = &((struct sockaddr_in6 *)&ssmask->ss)->sin6_addr;
diff --git a/usr.sbin/smtpd/parse.y b/usr.sbin/smtpd/parse.y
index d7a06caf63c..a23cdf97f54 100644
--- a/usr.sbin/smtpd/parse.y
+++ b/usr.sbin/smtpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.20 2008/12/20 00:18:03 gilles Exp $ */
+/* $OpenBSD: parse.y,v 1.21 2009/01/04 16:40:58 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -416,7 +416,7 @@ stringel : STRING {
bits = inet_net_pton(AF_INET, $1, &ssin.sin_addr, sizeof(struct in_addr));
if (bits != -1) {
ssin.sin_family = AF_INET;
- me->me_key.med_addr.masked = bits;
+ me->me_key.med_addr.bits = bits;
me->me_key.med_addr.ss = *(struct sockaddr_storage *)&ssin;
}
else {
@@ -425,7 +425,7 @@ stringel : STRING {
if (bits == -1)
err(1, "inet_net_pton");
ssin6.sin6_family = AF_INET6;
- me->me_key.med_addr.masked = bits;
+ me->me_key.med_addr.bits = bits;
me->me_key.med_addr.ss = *(struct sockaddr_storage *)&ssin6;
}
}
@@ -433,12 +433,12 @@ stringel : STRING {
/* IP address ? */
if (inet_pton(AF_INET, $1, &ssin.sin_addr) == 1) {
ssin.sin_family = AF_INET;
- me->me_key.med_addr.masked = 0;
+ me->me_key.med_addr.bits = 0;
me->me_key.med_addr.ss = *(struct sockaddr_storage *)&ssin;
}
else if (inet_pton(AF_INET6, $1, &ssin6.sin6_addr) == 1) {
ssin6.sin6_family = AF_INET6;
- me->me_key.med_addr.masked = 0;
+ me->me_key.med_addr.bits = 0;
me->me_key.med_addr.ss = *(struct sockaddr_storage *)&ssin6;
}
else {
@@ -494,7 +494,7 @@ mapref : STRING {
bits = inet_net_pton(AF_INET, $1, &ssin.sin_addr, sizeof(struct in_addr));
if (bits != -1) {
ssin.sin_family = AF_INET;
- me->me_key.med_addr.masked = bits;
+ me->me_key.med_addr.bits = bits;
me->me_key.med_addr.ss = *(struct sockaddr_storage *)&ssin;
}
else {
@@ -503,7 +503,7 @@ mapref : STRING {
if (bits == -1)
err(1, "inet_net_pton");
ssin6.sin6_family = AF_INET6;
- me->me_key.med_addr.masked = bits;
+ me->me_key.med_addr.bits = bits;
me->me_key.med_addr.ss = *(struct sockaddr_storage *)&ssin6;
}
}
@@ -511,12 +511,12 @@ mapref : STRING {
/* IP address ? */
if (inet_pton(AF_INET, $1, &ssin.sin_addr) == 1) {
ssin.sin_family = AF_INET;
- me->me_key.med_addr.masked = 0;
+ me->me_key.med_addr.bits = 0;
me->me_key.med_addr.ss = *(struct sockaddr_storage *)&ssin;
}
else if (inet_pton(AF_INET6, $1, &ssin6.sin6_addr) == 1) {
ssin6.sin6_family = AF_INET6;
- me->me_key.med_addr.masked = 0;
+ me->me_key.med_addr.bits = 0;
me->me_key.med_addr.ss = *(struct sockaddr_storage *)&ssin6;
}
else {
@@ -694,6 +694,54 @@ action : DELIVER TO MAILDIR STRING {
from : FROM mapref {
$$ = $2;
}
+ | FROM ALL {
+ struct map *m;
+ struct mapel *me;
+ struct sockaddr_in *ssin;
+ struct sockaddr_in6 *ssin6;
+
+ if ((m = calloc(1, sizeof(*m))) == NULL)
+ fatal("out of memory");
+ m->m_id = last_map_id++;
+ if (m->m_id == INT_MAX) {
+ yyerror("too many maps defined");
+ free(m);
+ YYERROR;
+ }
+ if (! bsnprintf(m->m_name, MAX_LINE_SIZE, "<dynamic(%u)>", m->m_id))
+ fatal("snprintf");
+ m->m_flags |= F_DYNAMIC|F_USED;
+ m->m_type = T_SINGLE;
+
+ TAILQ_INIT(&m->m_contents);
+
+ if ((me = calloc(1, sizeof(*me))) == NULL)
+ fatal("out of memory");
+ me->me_key.med_addr.bits = 32;
+ ssin = (struct sockaddr_in *)&me->me_key.med_addr.ss;
+ ssin->sin_family = AF_INET;
+ if (inet_pton(AF_INET, "0.0.0.0", &ssin->sin_addr) != 1) {
+ free(me);
+ free(m);
+ YYERROR;
+ }
+ TAILQ_INSERT_TAIL(&m->m_contents, me, me_entry);
+
+ if ((me = calloc(1, sizeof(*me))) == NULL)
+ fatal("out of memory");
+ me->me_key.med_addr.bits = 128;
+ ssin6 = (struct sockaddr_in6 *)&me->me_key.med_addr.ss;
+ ssin6->sin6_family = AF_INET6;
+ if (inet_pton(AF_INET6, "::", &ssin6->sin6_addr) != 1) {
+ free(me);
+ free(m);
+ YYERROR;
+ }
+ TAILQ_INSERT_TAIL(&m->m_contents, me, me_entry);
+
+ TAILQ_INSERT_TAIL(conf->sc_maps, m, m_entry);
+ $$ = m->m_id;
+ }
| /* empty */ {
struct map *m;
struct mapel *me;
@@ -717,7 +765,7 @@ from : FROM mapref {
if ((me = calloc(1, sizeof(*me))) == NULL)
fatal("out of memory");
- me->me_key.med_addr.masked = 0;
+ me->me_key.med_addr.bits = 0;
ssin = (struct sockaddr_in *)&me->me_key.med_addr.ss;
ssin->sin_family = AF_INET;
if (inet_pton(AF_INET, "127.0.0.1", &ssin->sin_addr) != 1) {
@@ -729,7 +777,7 @@ from : FROM mapref {
if ((me = calloc(1, sizeof(*me))) == NULL)
fatal("out of memory");
- me->me_key.med_addr.masked = 0;
+ me->me_key.med_addr.bits = 0;
ssin6 = (struct sockaddr_in6 *)&me->me_key.med_addr.ss;
ssin6->sin6_family = AF_INET6;
if (inet_pton(AF_INET6, "::1", &ssin6->sin6_addr) != 1) {
diff --git a/usr.sbin/smtpd/smtpd.h b/usr.sbin/smtpd/smtpd.h
index 486896e83a4..40d295d099e 100644
--- a/usr.sbin/smtpd/smtpd.h
+++ b/usr.sbin/smtpd/smtpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: smtpd.h,v 1.39 2009/01/04 14:46:14 jacekm Exp $ */
+/* $OpenBSD: smtpd.h,v 1.40 2009/01/04 16:40:58 gilles Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org>
@@ -76,7 +76,7 @@
struct netaddr {
struct sockaddr_storage ss;
- int masked;
+ int bits;
};
struct relayhost {