Merge branch 'master' into debian-testing
authorJennifer Richards <jennifer@painless-security.com>
Fri, 23 Feb 2018 17:08:25 +0000 (12:08 -0500)
committerJennifer Richards <jennifer@painless-security.com>
Fri, 23 Feb 2018 17:08:25 +0000 (12:08 -0500)
12 files changed:
Makefile.am
common/tr_comm.c
common/tr_dh.c
common/tr_idp.c
common/tr_rp.c
configure.ac
redhat/default-internal.cfg
redhat/organizations.cfg
tr/internal.cfg
tr/organizations.cfg
tr/tr_tid.c
trust_router.spec

index de442b0..ae745ef 100644 (file)
@@ -48,7 +48,7 @@ trp/trp_upd.c
 
 libtr_tid_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden
 libtr_tid_la_LIBADD = gsscon/libgsscon.la $(GLIB_LIBS)
-libtr_tid_la_LDFLAGS = $(AM_LDFLAGS) -version-info 4:0:2 -no-undefined
+libtr_tid_la_LDFLAGS = $(AM_LDFLAGS) -version-info 4:1:2 -no-undefined
 
 common_t_constraint_SOURCES = common/t_constraint.c \
 common/tr_debug.c \
index 6212b5d..dd3c304 100644 (file)
@@ -372,10 +372,10 @@ static TR_COMM *tr_comm_sweep_func(TR_COMM *head)
     return NULL;
 
   /* will not remove the head here, that has already been done */
-  for (comm=head; comm->next!=NULL; comm=comm->next) {
+  for (comm=head; (comm!=NULL) && (comm->next!=NULL); comm=comm->next) {
     if (comm->next->refcount==0) {
       old_next=comm->next;
-      tr_comm_remove(head, comm->next); /* changes comm->next */
+      tr_comm_remove(head, comm->next); /* changes comm->next, may make it null */
       tr_comm_free(old_next);
     }
   }
index 031b404..906d53c 100644 (file)
@@ -82,7 +82,7 @@ DH *tr_dh_new(void)
   return DH_new();
 }
 
-DH *tr_create_dh_params(unsigned char *priv_key, 
+DH *tr_create_dh_params(unsigned char *priv_key,
                        size_t keylen) {
 
   DH *dh = NULL;
@@ -95,6 +95,7 @@ DH *tr_create_dh_params(unsigned char *priv_key,
       (NULL == (dh->p = BN_new())) ||
       (NULL == (dh->q = BN_new()))) {
     DH_free(dh);
+    return NULL;
   }
 
   BN_set_word(dh->g, 2);
@@ -235,15 +236,15 @@ DH *tr_dh_dup(DH *in)
   return out;
 }
 
-int tr_compute_dh_key(unsigned char **pbuf, 
-                     BIGNUM *pub_key, 
+int tr_compute_dh_key(unsigned char **pbuf,
+                     BIGNUM *pub_key,
                      DH *priv_dh) {
   size_t buflen;
   unsigned char *buf = NULL;;
   int rc = 0;
-  
-  if ((!pbuf) || 
-      (!pub_key) || 
+
+  if ((!pbuf) ||
+      (!pub_key) ||
       (!priv_dh)) {
     tr_debug("tr_compute_dh_key: Invalid parameters.");
     return(-1);
@@ -256,7 +257,7 @@ int tr_compute_dh_key(unsigned char **pbuf,
     return -1;
   }
 
-  
+
   rc = DH_compute_key(buf, pub_key, priv_dh);
   if (0 <= rc) {
     *pbuf = buf;
index 984e6b5..747397b 100644 (file)
@@ -389,11 +389,11 @@ TR_IDP_REALM *tr_idp_realm_sweep_func(TR_IDP_REALM *head)
   if (head==NULL)
     return NULL;
 
-  /* will not remove the head here, that has already been done */
-  for (idp=head; idp->next!=NULL; idp=idp->next) {
+  /* Will not remove the head here, that has already been done.*/
+  for (idp=head; (idp!=NULL) && (idp->next!=NULL); idp=idp->next) {
     if (idp->next->refcount==0) {
       old_next=idp->next;
-      tr_idp_realm_remove(head, idp->next); /* changes idp->next */
+      tr_idp_realm_remove(head, idp->next); /* changes idp->next, may make it NULL */
       tr_idp_realm_free(old_next);
     }
   }
index 495c77e..4acdc4b 100644 (file)
@@ -290,10 +290,10 @@ TR_RP_REALM *tr_rp_realm_sweep_func(TR_RP_REALM *head)
     return NULL;
 
   /* will not remove the head here, that has already been done */
-  for (rp=head; rp->next!=NULL; rp=rp->next) {
+  for (rp=head; (rp!=NULL) && (rp->next!=NULL); rp=rp->next) {
     if (rp->next->refcount==0) {
       old_next=rp->next;
-      tr_rp_realm_remove(head, rp->next); /* changes rp->next */
+      tr_rp_realm_remove(head, rp->next); /* changes rp->next, may make it null */
       tr_rp_realm_free(old_next);
     }
   }
index 1a5a53e..47c962b 100644 (file)
@@ -1,5 +1,5 @@
 AC_PREREQ(2.63)
-AC_INIT([trust_router],[3.0.2],
+AC_INIT([trust_router],[3.3.0],
 [bugs@project-moonshot.org])
 AC_CONFIG_MACRO_DIR(m4)
 AC_CONFIG_AUX_DIR(build-aux)
index eef0f61..8b2a77b 100644 (file)
@@ -1,6 +1,5 @@
 {
   "tr_internal": {
-    "max_tree_depth": 12,
     "hostname":"beta.example.com",
     "trps_port":12308,
     "tids_port":12309,
index 5c190b8..58f9ac1 100644 (file)
@@ -3,13 +3,16 @@
     {
       "apcs": [],
       "community_id": "apc.x",
-      "idp_realms": ["idp.x", "other.idp.x"],
-      "rp_realms": ["rp.x", "other.rp.x"],
+      "idp_realms": ["apc.x",
+                     "idp.x",
+                     "other.idp.x"],
+      "rp_realms": ["rp.x",
+                    "other.rp.x"],
       "type": "apc",
-      "expiration_interval": 10
+      "expiration_interval": 30
     },
     {
-      "apcs": ["apc."],
+      "apcs": ["apc.x"],
       "community_id": "coi.x",
       "idp_realms": ["idp.x"],
       "rp_realms": ["rp.x"],
   ],
   "local_organizations": [
     {
+      "organization_name": "APC",
+      "realms": [
+        {
+          "realm": "apc.x",
+          "identity_provider": {
+            "aaa_servers": [
+              "apc.example.com"
+            ],
+            "apcs": [
+              "apc.x"
+            ],
+            "shared_config": "no"
+          }
+        }
+      ]
+    },
+    {
       "organization_name": "Demo Organization",
       "realms": [
-       {
-         "realm": "rp.x",
-         "gss_names": ["alpha-cred@apc.x",
-                       "beta-cred@apc.x",
-                       "gamma-cred@apc.x"],
-         "filters": {
-           "tid_inbound": [
-             {
-               "action": "accept",
-               "domain_constraints": [
-                 "*.local"
-               ],
-               "specs": [
-                 {
-                   "field": "rp_realm",
-                   "match": "rp.x"
-                 },
-                 {
-                   "field": "rp_realm",
-                   "match": "*.rp.x"
-                 }
-               ],
-               "realm_constraints": [
-                 "rp.x", "*.rp.x"
-               ]
-             }
-           ]
-         }
-       },
+        {
+          "realm": "rp.x",
+          "gss_names": ["rp-cred@apc.x",
+                        "second-rp-cred@apc.x"],
+          "filters": {
+            "tid_inbound": [
+              {
+                "action": "accept",
+                "domain_constraints": [
+                  "*.example.com"
+                ],
+                "specs": [
+                  {
+                    "field": "rp_realm",
+                    "match": [
+                      "rp.x", "*.rp.x"
+                    ]
+                  }
+                ],
+                "realm_constraints": [
+                  "rp.x", "*.rp.x"
+                ]
+              }
+            ]
+          }
+        },
         {
           "realm": "other.rp.x",
-          "gss_names": ["something@apc.x"]
+          "gss_names": ["other-rp-cred@apc.x"]
         },
-       {
-         "realm": "idp.x",
-         "gss_names": ["alpha-cred@apc.x"],
-         "identity_provider": {
-           "aaa_servers": ["alpha.local"],
-           "apcs": ["apc.x"],
-           "shared_config": "no"
-         }
+        {
+          "realm": "idp.x",
+          "gss_names": ["idp-cred@apc.x"],
+          "identity_provider": {
+            "aaa_servers": ["idp.example.com"],
+            "apcs": ["apc.x"],
+            "shared_config": "no"
+          }
         },
-       {
-         "realm": "other.idp.x",
-         "gss_names": ["beta-cred@apc.x"],
-         "identity_provider": {
-           "aaa_servers": ["alpha.local"],
-           "apcs": ["apc.x"],
-           "shared_config": "no"
-         }
-       }
+        {
+          "realm": "other.idp.x",
+          "gss_names": ["other-idp-cred@apc.x"],
+          "identity_provider": {
+            "aaa_servers": ["idp.example.com"],
+            "apcs": ["apc.x"],
+            "shared_config": "no"
+          }
+        }
       ]
     }
   ],
   "peer_organizations": [
     {
-      "hostname": "gamma.local",
+      "hostname": "peer.example.com",
       "port": 12310,
-      "gss_names": ["gamma-cred@apc.x"]
+      "gss_names": ["peer-cred@apc.x"]
     }
   ]
 }
index eef0f61..5b863d5 100644 (file)
@@ -1,7 +1,6 @@
 {
   "tr_internal": {
-    "max_tree_depth": 12,
-    "hostname":"beta.example.com",
+    "hostname":"tr.example.com",
     "trps_port":12308,
     "tids_port":12309,
     "cfg_poll_interval": 1,
index 5c190b8..58f9ac1 100644 (file)
@@ -3,13 +3,16 @@
     {
       "apcs": [],
       "community_id": "apc.x",
-      "idp_realms": ["idp.x", "other.idp.x"],
-      "rp_realms": ["rp.x", "other.rp.x"],
+      "idp_realms": ["apc.x",
+                     "idp.x",
+                     "other.idp.x"],
+      "rp_realms": ["rp.x",
+                    "other.rp.x"],
       "type": "apc",
-      "expiration_interval": 10
+      "expiration_interval": 30
     },
     {
-      "apcs": ["apc."],
+      "apcs": ["apc.x"],
       "community_id": "coi.x",
       "idp_realms": ["idp.x"],
       "rp_realms": ["rp.x"],
   ],
   "local_organizations": [
     {
+      "organization_name": "APC",
+      "realms": [
+        {
+          "realm": "apc.x",
+          "identity_provider": {
+            "aaa_servers": [
+              "apc.example.com"
+            ],
+            "apcs": [
+              "apc.x"
+            ],
+            "shared_config": "no"
+          }
+        }
+      ]
+    },
+    {
       "organization_name": "Demo Organization",
       "realms": [
-       {
-         "realm": "rp.x",
-         "gss_names": ["alpha-cred@apc.x",
-                       "beta-cred@apc.x",
-                       "gamma-cred@apc.x"],
-         "filters": {
-           "tid_inbound": [
-             {
-               "action": "accept",
-               "domain_constraints": [
-                 "*.local"
-               ],
-               "specs": [
-                 {
-                   "field": "rp_realm",
-                   "match": "rp.x"
-                 },
-                 {
-                   "field": "rp_realm",
-                   "match": "*.rp.x"
-                 }
-               ],
-               "realm_constraints": [
-                 "rp.x", "*.rp.x"
-               ]
-             }
-           ]
-         }
-       },
+        {
+          "realm": "rp.x",
+          "gss_names": ["rp-cred@apc.x",
+                        "second-rp-cred@apc.x"],
+          "filters": {
+            "tid_inbound": [
+              {
+                "action": "accept",
+                "domain_constraints": [
+                  "*.example.com"
+                ],
+                "specs": [
+                  {
+                    "field": "rp_realm",
+                    "match": [
+                      "rp.x", "*.rp.x"
+                    ]
+                  }
+                ],
+                "realm_constraints": [
+                  "rp.x", "*.rp.x"
+                ]
+              }
+            ]
+          }
+        },
         {
           "realm": "other.rp.x",
-          "gss_names": ["something@apc.x"]
+          "gss_names": ["other-rp-cred@apc.x"]
         },
-       {
-         "realm": "idp.x",
-         "gss_names": ["alpha-cred@apc.x"],
-         "identity_provider": {
-           "aaa_servers": ["alpha.local"],
-           "apcs": ["apc.x"],
-           "shared_config": "no"
-         }
+        {
+          "realm": "idp.x",
+          "gss_names": ["idp-cred@apc.x"],
+          "identity_provider": {
+            "aaa_servers": ["idp.example.com"],
+            "apcs": ["apc.x"],
+            "shared_config": "no"
+          }
         },
-       {
-         "realm": "other.idp.x",
-         "gss_names": ["beta-cred@apc.x"],
-         "identity_provider": {
-           "aaa_servers": ["alpha.local"],
-           "apcs": ["apc.x"],
-           "shared_config": "no"
-         }
-       }
+        {
+          "realm": "other.idp.x",
+          "gss_names": ["other-idp-cred@apc.x"],
+          "identity_provider": {
+            "aaa_servers": ["idp.example.com"],
+            "apcs": ["apc.x"],
+            "shared_config": "no"
+          }
+        }
       ]
     }
   ],
   "peer_organizations": [
     {
-      "hostname": "gamma.local",
+      "hostname": "peer.example.com",
       "port": 12310,
-      "gss_names": ["gamma-cred@apc.x"]
+      "gss_names": ["peer-cred@apc.x"]
     }
   ]
 }
index dffa46b..0c69d55 100644 (file)
@@ -399,38 +399,32 @@ static int tr_tids_req_handler(TIDS_INSTANCE *tids,
   tr_debug("tr_tids_req_handler: looking up route.");
   route=trps_get_selected_route(trps, orig_req->comm, orig_req->realm);
   if (route==NULL) {
-    tr_notice("tr_tids_req_handler: no route table entry found for realm (%s) in community (%s).",
-              orig_req->realm->buf, orig_req->comm->buf);
-    tids_send_err_response(tids, orig_req, "Missing trust route error");
-    retval=-1;
-    goto cleanup;
-  }
-  tr_debug("tr_tids_req_handler: found route.");
-  if (trp_route_is_local(route)) {
-    tr_debug("tr_tids_req_handler: route is local.");
-    aaa_servers = tr_idp_aaa_server_lookup(cfg_mgr->active->ctable->idp_realms, 
-                                           orig_req->realm, 
-                                           orig_req->comm,
-                                          &idp_shared);
-  } else {
-    tr_debug("tr_tids_req_handler: route not local.");
-    aaa_servers = tr_aaa_server_new(tmp_ctx, trp_route_get_next_hop(route));
-    idp_shared=0;
-  }
-
-  /* Find the AAA server(s) for this request */
-  if (NULL == aaa_servers) {
-    tr_debug("tr_tids_req_handler: No AAA Servers for realm %s, defaulting.", orig_req->realm->buf);
-    if (NULL == (aaa_servers = tr_default_server_lookup (cfg_mgr->active->default_servers,
-                                                         orig_req->comm))) {
+    /* No route. Use default AAA servers if we have them. */
+    tr_debug("tr_tids_req_handler: No route for realm %s, defaulting.", orig_req->realm->buf);
+    if (NULL == (aaa_servers = tr_default_server_lookup(cfg_mgr->active->default_servers,
+                                                        orig_req->comm))) {
       tr_notice("tr_tids_req_handler: No default AAA servers, discarded.");
       tids_send_err_response(tids, orig_req, "No path to AAA Server(s) for realm");
-      retval=-1;
+      retval = -1;
       goto cleanup;
     }
-    idp_shared=0;
+    idp_shared = 0;
   } else {
-    /* if we aren't defaulting, check idp coi and apc membership */
+    /* Found a route. Determine the AAA servers or next hop address. */
+    tr_debug("tr_tids_req_handler: found route.");
+    if (trp_route_is_local(route)) {
+      tr_debug("tr_tids_req_handler: route is local.");
+      aaa_servers = tr_idp_aaa_server_lookup(cfg_mgr->active->ctable->idp_realms,
+                                             orig_req->realm,
+                                             orig_req->comm,
+                                             &idp_shared);
+    } else {
+      tr_debug("tr_tids_req_handler: route not local.");
+      aaa_servers = tr_aaa_server_new(tmp_ctx, trp_route_get_next_hop(route));
+      idp_shared = 0;
+    }
+
+    /* Since we aren't defaulting, check idp coi and apc membership */
     if (NULL == (tr_comm_find_idp(cfg_mgr->active->ctable, cfg_comm, fwd_req->realm))) {
       tr_notice("tr_tids_req_handler: IDP Realm (%s) not member of community (%s).", orig_req->realm->buf, orig_req->comm->buf);
       tids_send_err_response(tids, orig_req, "IDP community membership error");
@@ -445,6 +439,15 @@ static int tr_tids_req_handler(TIDS_INSTANCE *tids,
     }
   }
 
+  /* Make sure we came through with a AAA server. If not, we can't handle the request. */
+  if (NULL == aaa_servers) {
+    tr_notice("tr_tids_req_handler: no route or AAA server for realm (%s) in community (%s).",
+              orig_req->realm->buf, orig_req->comm->buf);
+    tids_send_err_response(tids, orig_req, "Missing trust route error");
+    retval = -1;
+    goto cleanup;
+  }
+
   /* send a TID request to the AAA server(s), and get the answer(s) */
   tr_debug("tr_tids_req_handler: sending TID request(s).");
   if (cfg_apc)
index 21373de..f0000ec 100644 (file)
@@ -1,6 +1,6 @@
 %global optflags %{optflags} -Wno-parentheses
 Name:           trust_router
-Version:        3.0.2
+Version:        3.3.0
 Release:        1%{?dist}
 Summary:        Moonshot Trust Router
 
@@ -10,6 +10,7 @@ URL:            http://www.project-moonshot.org/
 Source0:        %{name}-%{version}.tar.gz
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 
+BuildRequires: autoconf, automake, m4, libtool
 BuildRequires:  krb5-devel, glib2-devel
 BuildRequires: jansson-devel >= 2.4
 BuildRequires: sqlite-devel, openssl-devel, libtalloc-devel, libevent-devel