]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
re-add %R, as "print with secrets suppressed"
authorAlan T. DeKok <aland@freeradius.org>
Wed, 28 Jan 2026 18:51:09 +0000 (13:51 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 28 Jan 2026 18:51:09 +0000 (13:51 -0500)
mainly for edit assignments and debug outputs.

Note that %pairs.print() will still print all of the data, even if
they're secret.  And any error messages will still print the data

src/lib/server/exec_legacy.c
src/lib/server/tmpl_tokenize.c
src/lib/unlang/edit.c
src/lib/unlang/foreach.c
src/lib/unlang/map_builtin.c
src/lib/unlang/xlat_builtin.c
src/lib/unlang/xlat_eval.c
src/lib/unlang/xlat_expr.c
src/lib/unlang/xlat_pair.c
src/lib/unlang/xlat_tokenize.c
src/lib/util/print.c

index 1435f94150996de950a092d0d3fb0c28f7ba2dd0..710c33f83705c45c7cb6563e019af5da51fc434b 100644 (file)
@@ -538,10 +538,10 @@ wait:
                if (WIFEXITED(status)) {
                        status = WEXITSTATUS(status);
                        if (status != 0) {
-                               RERROR("Program returned code (%d) and output \"%pV\"", status,
+                               RERROR("Program returned code (%d) and output %pV", status,
                                       fr_box_strvalue_len(answer, len));
                        } else {
-                               RDEBUG2("Program returned code (%d) and output \"%pV\"", status,
+                               RDEBUG2("Program returned code (%d) and output %pV", status,
                                        fr_box_strvalue_len(answer, len));
                        }
 
index 71c59d688b3b833260a4685e262c2918ea35992f..1368f2935bce57b44c52504f986922b3b5ed0e74 100644 (file)
@@ -289,7 +289,7 @@ void tmpl_attr_debug(FILE *fp, tmpl_t const *vpt)
                return;
        }
 
-       fprintf(fp, "tmpl_t %s (%.8x) \"%pV\" (%p)\n",
+       fprintf(fp, "tmpl_t %s (%.8x) %pV (%p)\n",
                tmpl_type_to_str(vpt->type),
                vpt->type,
                fr_box_strvalue_len(vpt->name, vpt->len), vpt);
index f16aebbc8ebd0a58a3c77aa741257d7c9492a96b..1eed7390bac9e6e2591c93561e58d1cb641d8ffe 100644 (file)
@@ -50,7 +50,7 @@ static void rdebug_assign(request_t *request, char const *attr, fr_token_t op, f
 
        switch (box->type) {
        case FR_TYPE_QUOTED:
-               RDEBUG2("%s %s \"%pV\"", attr, fr_tokens[op], box);
+               RDEBUG2("%s %s %pR", attr, fr_tokens[op], box);
                break;
 
        case FR_TYPE_INTERNAL:
@@ -66,7 +66,7 @@ static void rdebug_assign(request_t *request, char const *attr, fr_token_t op, f
                        break;
                }
 
-               RDEBUG2("%s %s %pV", attr, fr_tokens[op], box);
+               RDEBUG2("%s %s %pR", attr, fr_tokens[op], box);
                break;
        }
 }
@@ -386,7 +386,7 @@ static int apply_edits_to_list(request_t *request, unlang_frame_state_edit_t *st
                relative = (fr_pair_parse_t) { };
 
                if (fr_pair_list_afrom_substr(&root, &relative, &FR_SBUFF_IN(box->vb_strvalue, box->vb_length)) < 0) {
-                       RPEDEBUG("Failed parsing string '%pV' as attribute list", box);
+                       RPEDEBUG("Failed parsing string %pV as attribute list", box);
                        return -1;
                }
 
index f62d81a4386536553d8fe4531ea2b402e86fb741..dafce3b69ba6206d71c10ede6a669935541d622b 100644 (file)
@@ -191,7 +191,7 @@ next:
 
        fr_value_box_clear_value(&state->value->data);
        if (fr_value_box_cast(state->value, &state->value->data, state->value->vp_type, state->value->da, box) < 0) {
-               RDEBUG("Failed casting 'foreach' iteration variable '%s' from %pV", state->value->da->name, box);
+               RPEDEBUG("Failed casting 'foreach' iteration variable '%s' from %pV", state->value->da->name, box);
                goto next;
        }
 
@@ -224,7 +224,7 @@ static unlang_action_t unlang_foreach_xlat_expanded(unlang_result_t *p_result, r
 
 next:
        if (fr_value_box_cast(state->value, &state->value->data, state->value->vp_type, state->value->da, box) < 0) {
-               RDEBUG("Failed casting 'foreach' iteration variable '%s' from %pV", state->value->da->name, box);
+               RPEDEBUG("Failed casting 'foreach' iteration variable '%s' from %pV", state->value->da->name, box);
                box = fr_dcursor_next(&state->cursor);
                if (!box) goto done;
 
@@ -361,7 +361,7 @@ next:
                }
 
 #ifndef NDEBUG
-               RDEBUG2("# looping with: %s = %pV", state->value->da->name, &vp->data);
+               RDEBUG2("# looping with: %s = %pR", state->value->da->name, &vp->data);
 #endif
        }
 
index 1cdbbeb50be0a2e088a2961ae98069b0f6df3044..c6fe6366036dd3b7d454b500f76b42fa116b756c 100644 (file)
@@ -52,7 +52,7 @@ static int _list_map_proc_get_value(TALLOC_CTX *ctx, fr_pair_list_t *out,
        if (!vp) return -1;
 
        if (fr_value_box_cast(vp, &vp->data, vp->data.type, vp->da, value) < 0) {
-               RPEDEBUG("Failed casting \"%pV\" for attribute %s", value, vp->da->name);
+               RPEDEBUG("Failed casting %pR for attribute %s", value, vp->da->name);
                talloc_free(vp);
                return -1;
        }
index 46f0dac73ed635bfa98fb1ad68b57005c93cef4d..2aab69718dfef4fc3dd6be849a4305b27c77fe14 100644 (file)
@@ -1048,7 +1048,7 @@ static xlat_action_t xlat_func_integer(TALLOC_CTX *ctx, fr_dcursor_t *out,
        switch (in_vb->type) {
        default:
        error:
-               RPEDEBUG("Failed converting %pV (%s) to an integer", in_vb,
+               RPEDEBUG("Failed converting %pR (%s) to an integer", in_vb,
                         fr_type_to_str(in_vb->type));
                talloc_free(in_vb);
                return XLAT_ACTION_FAIL;
index 6bc210634feb28653bcca337b02268d8e889d5d6..497374212b24ead8b860b6200dde7d224cae80d0 100644 (file)
@@ -243,13 +243,13 @@ static inline void xlat_debug_log_expansion(request_t *request, xlat_exp_t const
                        a = fr_value_box_list_head(args);
                        b = fr_value_box_list_next(args, a);
 
-                       RDEBUG2("| (%pV %s %pV)", a, fr_tokens[node->call.func->token], b);
+                       RDEBUG2("| (%pR %s %pR)", a, fr_tokens[node->call.func->token], b);
 
 #ifndef NDEBUG
                        if (a && b) {
                                a = fr_value_box_list_next(args, b);
                                if (a) {
-                                       RDEBUG2("| ... ??? %pV", a);
+                                       RDEBUG2("| ... ??? %pR", a);
                                        fr_assert(0);
                                }
                        }
@@ -296,7 +296,7 @@ static inline void xlat_debug_log_result(request_t *request, xlat_exp_t const *n
 
        if (!RDEBUG_ENABLED2) return;
 
-       RDEBUG2("| --> %pV", result);
+       RDEBUG2("| --> %pR", result);
 }
 
 static int xlat_arg_stringify(request_t *request, xlat_arg_parser_t const *arg, xlat_exp_t const *node, fr_value_box_t *vb)
@@ -1128,7 +1128,7 @@ xlat_action_t xlat_frame_eval_resume(TALLOC_CTX *ctx, fr_dcursor_t *out,
 
                fr_dcursor_next(out);           /* Wind to the start of this functions output */
                if (node->call.func) {
-                       RDEBUG2("| --> %pV", fr_dcursor_current(out));
+                       RDEBUG2("| --> %pR", fr_dcursor_current(out));
                        if (!xlat_process_return(request, node->call.func, (fr_value_box_list_t *)out->dlist,
                                         fr_dcursor_current(out))) return XLAT_ACTION_FAIL;
                }
index 9a95cb4852e12c825de1192760b0a8d269a5a03a..7f4f14c8d09bd7c890057af0df966c68006dfce7 100644 (file)
@@ -354,7 +354,7 @@ static xlat_action_t xlat_binary_op(TALLOC_CTX *ctx, fr_dcursor_t *out,
 
        rcode = fr_value_calc_binary_op(dst, dst, default_type, a, op, b);
        if (rcode < 0) {
-               RPEDEBUG("Failed calculating '%pV %s %pV'", a, fr_tokens[op], b);
+               RPEDEBUG("Failed calculating '%pR %s %pR'", a, fr_tokens[op], b);
                talloc_free(dst);
                return XLAT_ACTION_FAIL;
        }
index e3fd6c6b9d9ce90cff6f0a4428b74a8737fc4f58..ac59457647299f86aedd3a2e3a677fefa62a5da4 100644 (file)
@@ -102,7 +102,7 @@ int xlat_decode_value_box_list(TALLOC_CTX *ctx, fr_pair_list_t *out,
                ssize_t         len;
 
                if (vb->type != FR_TYPE_OCTETS) {
-                       RWDEBUG("Skipping value \"%pV\", expected value of type %s, got type %s",
+                       RWDEBUG("Skipping value \"%pR\", expected value of type %s, got type %s",
                                vb,
                                fr_type_to_str(FR_TYPE_OCTETS),
                                fr_type_to_str(vb->type));
index ff298a4e84386dbffed169518b25ce8699196823..c931e62e3b1eb7b7c9105645b3445b44e0cf6234 100644 (file)
@@ -2006,7 +2006,7 @@ int xlat_resolve(xlat_exp_head_t *head, xlat_res_rules_t const *xr_rules)
                                 *      FIXME - Produce proper error with marker
                                 */
                                if (!xr_rules->allow_unresolved) {
-                                       fr_strerror_printf("Failed resolving function \"%pV\"",
+                                       fr_strerror_printf("Failed resolving function %pV",
                                                           fr_box_strvalue_buffer(node->fmt));
                                        return -1;
                                }
index 43ba190cecb981aa702bd32ac2e66164c041797e..62e852667b3c343d21db7fbdbbe97913f11d6013 100644 (file)
@@ -668,15 +668,17 @@ static char *fr_vasprintf_internal(TALLOC_CTX *ctx, char const *fmt, va_list ap,
                         *      subst types
                         */
                        switch (*(p + 1)) {
+                       case 'R':
+                               /*
+                                *      If the caller explicitly asks to suppress secrets via '%pR', then we
+                                *      do that.
+                                */
+                               suppress_secrets = true;
+                               FALL_THROUGH;
+
                        case 'V':
                        {
                                fr_value_box_t const *in = va_arg(ap_q, fr_value_box_t const *);
-                               fr_sbuff_escape_rules_t const *e_rules = NULL;
-
-                               /*
-                                *      Value boxes get escaped as double-quoted strings.
-                                */
-                               e_rules = &fr_value_escape_double;
 
                                /*
                                 *      Allocations that are not part of the output
@@ -687,7 +689,11 @@ static char *fr_vasprintf_internal(TALLOC_CTX *ctx, char const *fmt, va_list ap,
                                        subst = talloc_typed_strdup(NULL, "<<< secret >>>");
 
                                } else if (in) {
-                                       fr_value_box_aprint(NULL, &subst, in, e_rules);
+                                       /*
+                                        *      Value boxes get escaped as double-quoted strings.
+                                        */
+                                       fr_value_box_aprint(NULL, &subst, in, &fr_value_escape_double);
+
                                } else {
                                        subst = talloc_typed_strdup(NULL, "(null)");
                                }