]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Need to track what log destination was cloned
authorNick Porter <nick@portercomputing.co.uk>
Tue, 9 Apr 2024 13:12:01 +0000 (14:12 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Tue, 9 Apr 2024 13:12:01 +0000 (14:12 +0100)
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.

src/lib/server/request.c
src/lib/unlang/xlat_builtin.c
src/lib/util/log.h

index f94f896c9e34afacaf1de245da43673d518bf9da..39d5b16168106544eda1d5c0cf97dbc33342a375 100644 (file)
@@ -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;
index f36cad500479e0ff09415cb6098c6b1a947b1a7c..7f849add1621e55c7cdb797aecb9febf7a5810b5 100644 (file)
@@ -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.
index 66821360c07a1e95cc9cf1a19f5ced4861e2a9e2..7ec1210e43a6a97e47e483d273c3d8d6a1a46abe 100644 (file)
@@ -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.