From: Sam Hartman Date: Tue, 10 Mar 2015 00:45:38 +0000 (-0400) Subject: Real syslog support for trust router X-Git-Tag: 1.5~19 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=trust_router.git;a=commitdiff_plain;h=39c2dec6054da6fb692b40f6b5ac374795b17092 Real syslog support for trust router Merge branch 'logging_changes' of https://github.com/adam-bishop/trust_router Conflicts: common/tr_config.c common/tr_msg.c tr/tr_main.c --- 39c2dec6054da6fb692b40f6b5ac374795b17092 diff --cc common/tr_config.c index e221363,9b5dca6..4cf5d7f --- a/common/tr_config.c +++ b/common/tr_config.c @@@ -689,8 -728,8 +728,8 @@@ static TR_COMM *tr_cfg_parse_one_comm ( return NULL; } - if (NULL == (comm = talloc(trc, TR_COMM))) { - tr_debug("tr_cfg_parse_one_comm: Out of memory."); + if (NULL == (comm = talloc_zero(trc, TR_COMM))) { - fprintf(stderr, "tr_cfg_parse_one_comm: Out of memory.\n"); ++ tr_crit("tr_cfg_parse_one_comm: Out of memory."); *rc = TR_CFG_NOMEM; return NULL; } @@@ -742,8 -782,9 +781,8 @@@ comm->rp_realms = tr_cfg_parse_comm_rps(trc, jrps, rc); if (TR_CFG_SUCCESS != *rc) { - fprintf(stderr, "tr_cfg_parse_comm: Can't parse RP realms for comm %s .\n", comm->id->buf); + tr_debug("tr_cfg_parse_comm: Can't parse RP realms for comm %s .", comm->id->buf); tr_free_name(comm->id); - /* TBD -- free idps? */; return NULL; } diff --cc common/tr_msg.c index 85be430,841e894..5754f0c --- a/common/tr_msg.c +++ b/common/tr_msg.c @@@ -224,9 -224,8 +224,9 @@@ static json_t *tr_msg_encode_one_server { json_t *jsrvr = NULL; json_t *jstr = NULL; + gchar *time_str = g_time_val_to_iso8601(&srvr->key_expiration); - fprintf(stderr, "Encoding one server.\n"); + tr_debug("Encoding one server."); jsrvr = json_object(); @@@ -241,11 -237,9 +241,9 @@@ jstr = json_string(srvr->key_name->buf); json_object_set_new(jsrvr, "key_name", jstr); json_object_set_new(jsrvr, "server_dh", tr_msg_encode_dh(srvr->aaa_server_dh)); - - // tr_debug("tr_msg_encode_one_server(): jsrvr contains:"); - // tr_debug("%s", json_dumps(jsrvr, 0)); + if (srvr->path) + /* The path is owned by the srvr, so grab an extra ref*/ + json_object_set(jsrvr, "path", srvr->path); - // fprintf(stderr,"tr_msg_encode_one_server(): jsrvr contains:\n"); - // fprintf(stderr,"%s\n", json_dumps(jsrvr, 0)); return jsrvr; } diff --cc tr/tr_main.c index 241b496,9c8f909..c10843e --- a/tr/tr_main.c +++ b/tr/tr_main.c @@@ -98,8 -98,8 +99,8 @@@ static int tr_tids_req_handler (TIDS_IN return -1; } - if (NULL == (cfg_comm = tr_comm_lookup((TR_INSTANCE *)tids->cookie, orig_req->comm))) { + if (NULL == (cfg_comm = tr_comm_lookup(tids->cookie, orig_req->comm))) { - fprintf(stderr, "tr_tids_req_hander: Request for unknown comm: %s.\n", orig_req->comm->buf); + tr_notice("tr_tids_req_hander: Request for unknown comm: %s.", orig_req->comm->buf); tids_send_err_response(tids, orig_req, "Unknown community"); return -1; } @@@ -107,16 -107,16 +108,16 @@@ /* Check that the rp_realm matches the filter for the GSS name that * was received. */ - if ((!((TR_INSTANCE *)tr)->rp_gss) || - (!((TR_INSTANCE *)tr)->rp_gss->filter)) { + if ((!(tr)->rp_gss) || + (!(tr)->rp_gss->filter)) { - fprintf(stderr, "tr_tids_req_handler: No GSS name for incoming request.\n"); + tr_notice("tr_tids_req_handler: No GSS name for incoming request."); tids_send_err_response(tids, orig_req, "No GSS name for request"); return -1; } - if ((TR_FILTER_NO_MATCH == tr_filter_process_rp_permitted(orig_req->rp_realm, ((TR_INSTANCE *)tr)->rp_gss->filter, orig_req->cons, &fwd_req->cons, &oaction)) || + if ((TR_FILTER_NO_MATCH == tr_filter_process_rp_permitted(orig_req->rp_realm, (tr)->rp_gss->filter, orig_req->cons, &fwd_req->cons, &oaction)) || (TR_FILTER_ACTION_REJECT == oaction)) { - fprintf(stderr, "tr_tids_req_handler: RP realm (%s) does not match RP Realm filter for GSS name\n", orig_req->rp_realm->buf); + tr_notice("tr_tids_req_handler: RP realm (%s) does not match RP Realm filter for GSS name", orig_req->rp_realm->buf); tids_send_err_response(tids, orig_req, "RP Realm filter error"); return -1; } @@@ -139,8 -139,8 +140,8 @@@ apc = tr_dup_name(cfg_comm->apcs->id); /* Check that the APC is configured */ - if (NULL == (cfg_apc = tr_comm_lookup((TR_INSTANCE *)tids->cookie, apc))) { + if (NULL == (cfg_apc = tr_comm_lookup(tids->cookie, apc))) { - fprintf(stderr, "tr_tids_req_hander: Request for unknown comm: %s.\n", apc->buf); + tr_notice("tr_tids_req_hander: Request for unknown comm: %s.", apc->buf); tids_send_err_response(tids, orig_req, "Unknown APC"); return -1; } @@@ -184,12 -184,9 +185,12 @@@ /* send a TID request to the AAA server(s), and get the answer(s) */ /* TBD -- Handle multiple servers */ + if (cfg_apc) + fwd_req->expiration_interval = cfg_apc->expiration_interval; + else fwd_req->expiration_interval = cfg_comm->expiration_interval; /* Create a TID client instance */ if (NULL == (tidc = tidc_create())) { - fprintf(stderr, "tr_tids_req_hander: Unable to allocate TIDC instance.\n"); + tr_crit("tr_tids_req_hander: Unable to allocate TIDC instance."); tids_send_err_response(tids, orig_req, "Memory allocation failure"); return -1; } @@@ -223,13 -220,12 +224,13 @@@ } static int tr_tids_gss_handler(gss_name_t client_name, TR_NAME *gss_name, - void *tr) + void *tr_in) { TR_RP_CLIENT *rp; + TR_INSTANCE *tr = (TR_INSTANCE *) tr_in; if ((!client_name) || (!gss_name) || (!tr)) { - fprintf(stderr, "tr_tidc_gss_handler: Bad parameters.\n"); + tr_debug("tr_tidc_gss_handler: Bad parameters."); return -1; } @@@ -241,8 -237,8 +242,9 @@@ /* Store the rp client in the TR_INSTANCE structure for now... * TBD -- fix me for new tasking model. */ - ((TR_INSTANCE *)tr)->rp_gss = rp; + (tr)->rp_gss = rp; - fprintf( stderr, "Client's GSS Name: %s\n", gss_name->buf); + tr_debug("Client's GSS Name: %s", gss_name->buf); ++ return 0; }