Use json_is_true() in place of json_boolean_value() for compatibility
[trust_router.git] / common / tr_gss_client.c
index db9f380..f45af3a 100644 (file)
 #include <tr_debug.h>
 #include <tr_gss_client.h>
 
-static int tr_gssc_destructor(void *obj)
-{
-  TR_GSSC_INSTANCE *tr_gssc=talloc_get_type_abort(obj, TR_GSSC_INSTANCE);
-  if (NULL!=tr_gssc) {
-    if (NULL!=tr_gssc->client_dh)
-      tr_destroy_dh_params(tr_gssc->client_dh);
-  }
-  return 0;
-}
-
 TR_GSSC_INSTANCE *tr_gssc_instance_new(TALLOC_CTX *mem_ctx)
 {
   TR_GSSC_INSTANCE *gssc=talloc(NULL, TR_GSSC_INSTANCE);
   if (gssc != NULL) {
     gssc->service_name = NULL;
-    gssc->client_dh = NULL;
     gssc->conn = -1;
     gssc->gss_ctx = talloc(gssc, gss_ctx_id_t);
     if (gssc->gss_ctx == NULL) {
-      talloc_free(gssc); /* before the destructor is set */
+      talloc_free(gssc);
       return NULL;
     }
-    talloc_set_destructor((void *)gssc, tr_gssc_destructor);
   }
   return gssc;
 }
@@ -80,10 +68,15 @@ void tr_gssc_instance_free(TR_GSSC_INSTANCE *tr_gssc)
  * @param port TCP port to connect
  * @return 0 on success, -1 on failure
  */
-int tr_gssc_open_connection(TR_GSSC_INSTANCE *gssc, const char *server, unsigned int port)
+int tr_gssc_open_connection(TR_GSSC_INSTANCE *gssc, const char *server, int port)
 {
+  if ((port <= 0) || (port > 65535)) {
+    tr_err("tr_gssc_open_connection: invalid port requested (%d)", port);
+    return -1;
+  }
+
   tr_debug("tr_gssc_open_connection: opening connection to %s:%d", server, port);
-  if (0 != gsscon_connect(server, port, gssc->service_name, &(gssc->conn), gssc->gss_ctx))
+  if (0 != gsscon_connect(server, (unsigned int) port, gssc->service_name, &(gssc->conn), gssc->gss_ctx))
     return -1;
 
   return 0; /* success */
@@ -145,14 +138,3 @@ cleanup:
   talloc_free(tmp_ctx);
   return resp_msg;
 }
-
-DH * tr_gssc_get_dh(TR_GSSC_INSTANCE *inst)
-{
-  return inst->client_dh;
-}
-
-DH *tr_gssc_set_dh(TR_GSSC_INSTANCE *inst, DH *dh)
-{
-  inst->client_dh = dh;
-  return dh;
-}