diff options
author | Reyk Floeter <reyk@cvs.openbsd.org> | 2009-08-05 13:46:14 +0000 |
---|---|---|
committer | Reyk Floeter <reyk@cvs.openbsd.org> | 2009-08-05 13:46:14 +0000 |
commit | 9cf9d3f9417b9bc23172dde9843df37ab87d07d5 (patch) | |
tree | 9eb54071ed19d16954c5972b3988a7ad8e635c6e | |
parent | 584ad849718300e719b0c35389723c9c65349846 (diff) |
prevent configuration of relays listening to a single addr:port tuple twice
-rw-r--r-- | usr.sbin/relayd/parse.y | 5 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.c | 14 | ||||
-rw-r--r-- | usr.sbin/relayd/relayd.h | 3 |
3 files changed, 18 insertions, 4 deletions
diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y index e3b521f94a4..42b737372c8 100644 --- a/usr.sbin/relayd/parse.y +++ b/usr.sbin/relayd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.135 2009/08/05 13:37:06 reyk Exp $ */ +/* $OpenBSD: parse.y,v 1.136 2009/08/05 13:46:13 reyk Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org> @@ -2390,7 +2390,8 @@ relay_inherit(struct relay *ra, struct relay *rb) goto err; } - if (relay_findbyname(conf, rb->rl_conf.name) != NULL) { + if (relay_findbyname(conf, rb->rl_conf.name) != NULL || + relay_findbyaddr(conf, &rb->rl_conf) != NULL) { yyerror("relay %s defined twice", rb->rl_conf.name); goto err; } diff --git a/usr.sbin/relayd/relayd.c b/usr.sbin/relayd/relayd.c index eb33e59fe53..7d832ef4df8 100644 --- a/usr.sbin/relayd/relayd.c +++ b/usr.sbin/relayd/relayd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.c,v 1.89 2009/06/05 23:39:51 pyr Exp $ */ +/* $OpenBSD: relayd.c,v 1.90 2009/08/05 13:46:13 reyk Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org> @@ -923,6 +923,18 @@ relay_findbyname(struct relayd *env, const char *name) return (NULL); } +struct relay * +relay_findbyaddr(struct relayd *env, struct relay_config *rc) +{ + struct relay *rlay; + + TAILQ_FOREACH(rlay, env->sc_relays, rl_entry) + if (bcmp(&rlay->rl_conf.ss, &rc->ss, sizeof(rc->ss)) == 0 && + rlay->rl_conf.port == rc->port) + return (rlay); + return (NULL); +} + void event_again(struct event *ev, int fd, short event, void (*fn)(int, short, void *), diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h index 8158704c65e..8abd91fd199 100644 --- a/usr.sbin/relayd/relayd.h +++ b/usr.sbin/relayd/relayd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: relayd.h,v 1.126 2009/06/06 18:31:42 pyr Exp $ */ +/* $OpenBSD: relayd.h,v 1.127 2009/08/05 13:46:13 reyk Exp $ */ /* * Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -823,6 +823,7 @@ void event_again(struct event *, int, short, struct relay *relay_find(struct relayd *, objid_t); struct session *session_find(struct relayd *, objid_t); struct relay *relay_findbyname(struct relayd *, const char *); +struct relay *relay_findbyaddr(struct relayd *, struct relay_config *); int expand_string(char *, size_t, const char *, const char *); void translate_string(char *); void purge_config(struct relayd *, u_int8_t); |