From: Nick Porter Date: Tue, 9 Apr 2024 13:12:01 +0000 (+0100) Subject: Need to track what log destination was cloned X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9934de726968ddcffaa91de72d50054a88f72216;p=thirdparty%2Ffreeradius-server.git Need to track what log destination was cloned log_dst_by_name() returns a destination from the list of destinations parsed from the config, which then gets cloned for appending to a request's list. Therefore when matching in the request's list we need to know what the original destination was that was cloned. --- diff --git a/src/lib/server/request.c b/src/lib/server/request.c index f94f896c9e3..39d5b161681 100644 --- a/src/lib/server/request.c +++ b/src/lib/server/request.c @@ -116,7 +116,7 @@ void request_log_prepend(request_t *request, fr_log_t *log_dst, fr_log_lvl_t lvl last = &request->log.dst; while (*last) { dst = *last; - if (dst->uctx == log_dst) { + if (((fr_log_t *)dst->uctx)->parent == log_dst) { *last = dst->next; talloc_free(dst); if (!request->log.dst) request->log.lvl = L_DBG_LVL_OFF; @@ -133,7 +133,7 @@ void request_log_prepend(request_t *request, fr_log_t *log_dst, fr_log_lvl_t lvl * Change the debug level of an existing destination. */ for (dst = request->log.dst; dst != NULL; dst = dst->next) { - if (dst->uctx == log_dst) { + if (((fr_log_t *)dst->uctx)->parent == log_dst) { dst->lvl = lvl; if (lvl > request->log.lvl) request->log.lvl = lvl; return; diff --git a/src/lib/unlang/xlat_builtin.c b/src/lib/unlang/xlat_builtin.c index f36cad50047..7f849add162 100644 --- a/src/lib/unlang/xlat_builtin.c +++ b/src/lib/unlang/xlat_builtin.c @@ -1224,6 +1224,7 @@ static xlat_action_t xlat_func_log_dst(UNUSED TALLOC_CTX *ctx, UNUSED fr_dcursor * Clone it. */ MEM(dbg = talloc_memdup(request, log, sizeof(*log))); + dbg->parent = log; /* * Open the new filename. diff --git a/src/lib/util/log.h b/src/lib/util/log.h index 66821360c07..7ec1210e43a 100644 --- a/src/lib/util/log.h +++ b/src/lib/util/log.h @@ -91,7 +91,9 @@ typedef enum { L_TIMESTAMP_OFF //!< Never log timestamps. } fr_log_timestamp_t; -typedef struct { +typedef struct fr_log_s fr_log_t; + +struct fr_log_s { fr_log_dst_t dst; //!< Log destination. bool line_number; //!< Log src file and line number. @@ -115,7 +117,9 @@ typedef struct { ssize_t (*cookie_write)(void *, char const *, size_t); //!< write function void *uctx; //!< User data associated with the fr_log_t. -} fr_log_t; + + fr_log_t *parent; //!< Log destination this was cloned from. +}; typedef struct { char const *first_prefix; //!< Prefix for the first line printed.