From: Arran Cudbard-Bell Date: Thu, 4 Feb 2021 19:57:45 +0000 (+0000) Subject: Use the request_alloc functions to setup logging in trigger_exec X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7a538e38fc3b01616e4e7c613c8bbe40cf9eebe1;p=thirdparty%2Ffreeradius-server.git Use the request_alloc functions to setup logging in trigger_exec So we don't do it wrong and trip up asserts elsewhere in the code... or double alloc log.dst --- diff --git a/src/lib/server/trigger.c b/src/lib/server/trigger.c index edd7746b37d..df847a404da 100644 --- a/src/lib/server/trigger.c +++ b/src/lib/server/trigger.c @@ -377,7 +377,7 @@ int trigger_exec(request_t *request, CONF_SECTION const *cs, char const *name, b /* * radius_exec_program always needs a request. */ - fake = request_alloc(NULL, NULL); + fake = request_alloc(NULL, (&(request_init_args_t){ .parent = request, .detachable = true })); memcpy(&fake->server_cs, &subcs, sizeof(subcs)); /* completely wrong, but we need to use _something_ */ /* @@ -406,17 +406,8 @@ int trigger_exec(request_t *request, CONF_SECTION const *cs, char const *name, b fr_pair_list_init(&ctx->vps); ctx->name = talloc_strdup(ctx, value); - if (request) { - if (!fr_pair_list_empty(&request->request_pairs)) { - (void) fr_pair_list_copy(ctx, &ctx->vps, &request->request_pairs); - } - - fake->log = request->log; - } else { - fake->log.dst = talloc_zero(fake, log_dst_t); - fake->log.dst->func = vlog_request; - fake->log.dst->uctx = &default_log; - fake->log.lvl = fr_debug_lvl; + if (request && !fr_pair_list_empty(&request->request_pairs)) { + (void) fr_pair_list_copy(ctx, &ctx->vps, &request->request_pairs); } slen = xlat_tokenize_argv(ctx, &ctx->xlat, NULL, @@ -436,6 +427,13 @@ int trigger_exec(request_t *request, CONF_SECTION const *cs, char const *name, b return -1; } + + /* + * Ensure the trigger request is no longer associated + * with the parent. + */ + request_detach(fake); + /* * Run the trigger asynchronously. */