]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Home servers are unique by proto, too.
authorAlan T. DeKok <aland@freeradius.org>
Mon, 27 Jun 2011 12:52:54 +0000 (14:52 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 27 Jun 2011 12:54:10 +0000 (14:54 +0200)
Check for duplicates, and print errors if there are duplicates

src/main/realms.c

index 86ba068c94fdfbfb468d41a8ab8e34d7e5cbbcd7..38a869e9636a1bfb12eeb7413cc786747585562a 100644 (file)
@@ -164,6 +164,11 @@ static int home_server_addr_cmp(const void *one, const void *two)
        if (a->port < b->port) return -1;
        if (a->port > b->port) return +1;
 
+#ifdef WITH_TCP
+       if (a->proto < b->proto) return -1;
+       if (a->proto > b->proto) return +1;
+#endif
+
        rcode = fr_ipaddr_cmp(&a->src_ipaddr, &b->src_ipaddr);
        if (rcode != 0) return rcode;
 
@@ -708,6 +713,19 @@ static int home_server_add(realm_config_t *rc, CONF_SECTION *cs)
        free(hs_srcipaddr);
        hs_srcipaddr = NULL;
 
+       if (rbtree_finddata(home_servers_byname, home) != NULL) {
+               cf_log_err(cf_sectiontoitem(cs),
+                          "Duplicate home server name %s.", name2);
+               goto error;
+       }
+
+       if (!home->server &&
+           (rbtree_finddata(home_servers_byaddr, home) != NULL)) {
+               cf_log_err(cf_sectiontoitem(cs),
+                          "Duplicate home server IP %s.", name2);
+               goto error;
+       }
+
        if (!rbtree_insert(home_servers_byname, home)) {
                cf_log_err(cf_sectiontoitem(cs),
                           "Internal error %d adding home server %s.",