static TID_RESP *tids_create_response (TIDS_INSTANCE *tids, TID_REQ *req)
{
- TID_RESP *resp;
+ TID_RESP *resp=NULL;
+ int success=0;
if ((NULL == (resp = talloc_zero(req, TID_RESP)))) {
tr_crit("tids_create_response: Error allocating response structure.");
(NULL == (resp->realm = tr_dup_name(req->realm))) ||
(NULL == (resp->comm = tr_dup_name(req->comm)))) {
tr_crit("tids_create_response: Error allocating fields in response.");
- return NULL;
+ goto cleanup;
}
if (req->orig_coi) {
if (NULL == (resp->orig_coi = tr_dup_name(req->orig_coi))) {
tr_crit("tids_create_response: Error allocating fields in response.");
- return NULL;
+ goto cleanup;
}
}
+
+ success=1;
+
+cleanup:
+ if ((!success) && (resp!=NULL)) {
+ if (resp->rp_realm!=NULL)
+ tr_free_name(resp->rp_realm);
+ if (resp->realm!=NULL)
+ tr_free_name(resp->realm);
+ if (resp->comm!=NULL)
+ tr_free_name(resp->comm);
+ if (resp->orig_coi!=NULL)
+ tr_free_name(resp->orig_coi);
+ talloc_free(resp);
+ resp=NULL;
+ }
return resp;
}
}
/* returns 0 on authorization success, 1 on failure, or -1 in case of error */
-static int tids_auth_connection (struct tids_instance *inst,
- int conn, gss_ctx_id_t *gssctx)
+static int tids_auth_connection (TIDS_INSTANCE *inst,
+ int conn,
+ gss_ctx_id_t *gssctx)
{
int rc = 0;
int auth, autherr = 0;
nameLen = asprintf(&name, "trustidentity@%s", inst->hostname);
nameBuffer.length = nameLen;
nameBuffer.value = name;
-
+
if (rc = gsscon_passive_authenticate(conn, nameBuffer, gssctx, tids_auth_cb, inst)) {
tr_debug("tids_auth_connection: Error from gsscon_passive_authenticate(), rc = %d.", rc);
return -1;
tr_crit("tids_handle_connection: Error creating response structure.");
/* try to send an error */
tids_send_err_response(tids, tr_msg_get_req(mreq), "Error creating response.");
+ tr_msg_free_decoded(mreq);
return;
}
}
tids_destroy_response(tids, resp);
+ tr_msg_free_decoded(mreq);
return;
}
}
-TIDS_INSTANCE *tids_create (void)
+TIDS_INSTANCE *tids_create (TALLOC_CTX *mem_ctx)
{
- TIDS_INSTANCE *tids = NULL;
- if (tids = malloc(sizeof(TIDS_INSTANCE)))
- memset(tids, 0, sizeof(TIDS_INSTANCE));
- return tids;
+ return talloc_zero(mem_ctx, TIDS_INSTANCE);
}
/* Get a listener for tids requests, returns its socket fd. Accept
* connections with tids_accept() */
int tids_get_listener(TIDS_INSTANCE *tids,
TIDS_REQ_FUNC *req_handler,
- tids_auth_func *auth_handler,
+ TIDS_AUTH_FUNC *auth_handler,
const char *hostname,
unsigned int port,
void *cookie)
/* Process tids requests forever. Should not return except on error. */
int tids_start (TIDS_INSTANCE *tids,
TIDS_REQ_FUNC *req_handler,
- tids_auth_func *auth_handler,
+ TIDS_AUTH_FUNC *auth_handler,
const char *hostname,
unsigned int port,
void *cookie)