void (*print)(struct ndr_print *, const char *, ...) PRINTF_ATTRIBUTE(2,3);
void *private_data;
bool no_newline;
+ bool print_secrets;
};
#define LIBNDR_FLAG_BIGENDIAN (1<<0)
LIBNDR_FLAG_STR_RAW8 | \
0)
+/*
+ * Mark an element as SECRET, it won't be printed by
+ * via ndr_print* unless NDR_PRINT_SECRETS is specified.
+ */
+#define LIBNDR_FLAG_IS_SECRET (1<<14)
+
/* Disable string token compression */
#define LIBNDR_FLAG_NO_COMPRESSION (1<<15)
#define NDR_PRINT_OUT_STRING(ctx, type, p) NDR_PRINT_FUNCTION_STRING(ctx, type, NDR_OUT, p)
#define NDR_PRINT_IN_STRING(ctx, type, p) NDR_PRINT_FUNCTION_STRING(ctx, type, NDR_IN | NDR_SET_VALUES, p)
+#define NDR_HIDE_SECRET(ndr) \
+ (unlikely(((ndr)->flags & LIBNDR_FLAG_IS_SECRET) && !(ndr)->print_secrets))
+
#define NDR_BE(ndr) (unlikely(((ndr)->flags & (LIBNDR_FLAG_BIGENDIAN|LIBNDR_FLAG_LITTLE_ENDIAN)) == LIBNDR_FLAG_BIGENDIAN))
enum ndr_err_code {
ndr->print = ndr_print_debugc_helper;
ndr->depth = 1;
ndr->flags = 0;
+#ifdef DEBUG_PASSWORD
+ if (CHECK_DEBUGLVL(100)) {
+ ndr->print_secrets = true;
+ }
+#endif
+
fn(ndr, name, ptr);
talloc_free(ndr);
}
ndr->print = ndr_print_debug_helper;
ndr->depth = 1;
ndr->flags = 0;
+#ifdef DEBUG_PASSWORD
+ if (CHECK_DEBUGLVL(100)) {
+ ndr->print_secrets = true;
+ }
+#endif
+
fn(ndr, name, ptr);
talloc_free(ndr);
}
ndr->print = ndr_print_debug_helper;
ndr->depth = 1;
ndr->flags = 0;
+#ifdef DEBUG_PASSWORD
+ if (CHECK_DEBUGLVL(100)) {
+ ndr->print_secrets = true;
+ }
+#endif
+
ndr_print_set_switch_value(ndr, ptr, level);
fn(ndr, name, ptr);
talloc_free(ndr);
ndr->print = ndr_print_debug_helper;
ndr->depth = 1;
ndr->flags = 0;
+#ifdef DEBUG_PASSWORD
+ if (CHECK_DEBUGLVL(100)) {
+ ndr->print_secrets = true;
+ }
+#endif
fn(ndr, name, flags, ptr);
talloc_free(ndr);
_PUBLIC_ void ndr_print_int8(struct ndr_print *ndr, const char *name, int8_t v)
{
+ if (NDR_HIDE_SECRET(ndr)) {
+ ndr->print(ndr, "%-25s: <REDACTED SECRET VALUE>", name);
+ return;
+ }
ndr->print(ndr, "%-25s: %d", name, v);
}
_PUBLIC_ void ndr_print_uint8(struct ndr_print *ndr, const char *name, uint8_t v)
{
+ if (NDR_HIDE_SECRET(ndr)) {
+ ndr->print(ndr, "%-25s: <REDACTED SECRET VALUE>", name);
+ return;
+ }
ndr->print(ndr, "%-25s: 0x%02x (%u)", name, v, v);
}
_PUBLIC_ void ndr_print_int16(struct ndr_print *ndr, const char *name, int16_t v)
{
+ if (NDR_HIDE_SECRET(ndr)) {
+ ndr->print(ndr, "%-25s: <REDACTED SECRET VALUE>", name);
+ return;
+ }
ndr->print(ndr, "%-25s: %d", name, v);
}
_PUBLIC_ void ndr_print_uint16(struct ndr_print *ndr, const char *name, uint16_t v)
{
+ if (NDR_HIDE_SECRET(ndr)) {
+ ndr->print(ndr, "%-25s: <REDACTED SECRET VALUE>", name);
+ return;
+ }
ndr->print(ndr, "%-25s: 0x%04x (%u)", name, v, v);
}
_PUBLIC_ void ndr_print_int32(struct ndr_print *ndr, const char *name, int32_t v)
{
+ if (NDR_HIDE_SECRET(ndr)) {
+ ndr->print(ndr, "%-25s: <REDACTED SECRET VALUE>", name);
+ return;
+ }
ndr->print(ndr, "%-25s: %d", name, v);
}
_PUBLIC_ void ndr_print_uint32(struct ndr_print *ndr, const char *name, uint32_t v)
{
+ if (NDR_HIDE_SECRET(ndr)) {
+ ndr->print(ndr, "%-25s: <REDACTED SECRET VALUE>", name);
+ return;
+ }
ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v);
}
_PUBLIC_ void ndr_print_int3264(struct ndr_print *ndr, const char *name, int32_t v)
{
+ if (NDR_HIDE_SECRET(ndr)) {
+ ndr->print(ndr, "%-25s: <REDACTED SECRET VALUE>", name);
+ return;
+ }
ndr->print(ndr, "%-25s: %d", name, v);
}
_PUBLIC_ void ndr_print_uint3264(struct ndr_print *ndr, const char *name, uint32_t v)
{
+ if (NDR_HIDE_SECRET(ndr)) {
+ ndr->print(ndr, "%-25s: <REDACTED SECRET VALUE>", name);
+ return;
+ }
ndr->print(ndr, "%-25s: 0x%08x (%u)", name, v, v);
}
_PUBLIC_ void ndr_print_dlong(struct ndr_print *ndr, const char *name, int64_t v)
{
+ if (NDR_HIDE_SECRET(ndr)) {
+ ndr->print(ndr, "%-25s: <REDACTED SECRET VALUE>", name);
+ return;
+ }
ndr->print(ndr, "%-25s: 0x%016llx (%lld)", name, (unsigned long long)v, (long long)v);
}
return;
}
+ if (NDR_HIDE_SECRET(ndr)) {
+ ndr->print(ndr, "%s: ARRAY(%d): <REDACTED SECRET VALUES>", name, count);
+ return;
+ }
+
if (count <= _ONELINE_LIMIT && (ndr->flags & LIBNDR_PRINT_ARRAY_HEX)) {
char s[(_ONELINE_LIMIT + 1) * 2];
for (i=0;i<count;i++) {
*/
static void ndr_dump_data(struct ndr_print *ndr, const uint8_t *buf, int len)
{
+ if (NDR_HIDE_SECRET(ndr)) {
+ return;
+ }
ndr->no_newline = true;
dump_data_cb(buf, len, true, ndr_print_dump_data_cb, ndr);
ndr->no_newline = false;