]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
varlink: restore debug output on incoming messages 30962/head
authorLennart Poettering <lennart@poettering.net>
Tue, 16 Jan 2024 11:06:17 +0000 (12:06 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 16 Jan 2024 16:17:19 +0000 (17:17 +0100)
Now that we can selectively suppress only sensitive fields in JSON
objects we can reenable debug logging for incoming messages, which was
removed in 2e3414660cb0c6a024661638d0b237d88b5a7cbc.

This makes Varlink fully debuggable again: we'll see both incoming and
outgoing messages, only the sensitive fields are suppressed.

See: #30578

src/shared/varlink.c

index 7c37211cdda1bac8a7bf76eb642aa4273fd82e2c..84497c1a06e38cf7f76af61e7dfec9b71dc24e74 100644 (file)
@@ -1065,6 +1065,17 @@ static int varlink_parse_message(Varlink *v) {
                         json_variant_sensitive(parameters);
         }
 
+        if (DEBUG_LOGGING) {
+                _cleanup_(erase_and_freep) char *censored_text = NULL;
+
+                /* Suppress sensitive fields in the debug output */
+                r = json_variant_format(v->current, /* flags= */ JSON_FORMAT_CENSOR_SENSITIVE, &censored_text);
+                if (r < 0)
+                        return r;
+
+                varlink_log(v, "Received message: %s", censored_text);
+        }
+
         v->input_buffer_size -= sz;
 
         if (v->input_buffer_size == 0)