]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
gnutls logging improvements
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 12 Sep 2017 11:45:30 +0000 (13:45 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 12 Sep 2017 11:47:07 +0000 (13:47 +0200)
- move it to utils.c, so it's sensitive to later changes in verbosity
- don't mark the lines with [tls], as they may come through libdnssec
- use stdout like other verbose messages, instead of stderr (real errors)

daemon/main.c
daemon/tls.c
daemon/tls.h
lib/utils.c

index 92546c43bf2c1a5464b733579c5ba68a5a2ba89e..56c2e85a1e9b17ce0d9d7c10d36b80a004bb3963 100644 (file)
@@ -398,7 +398,6 @@ static int run_worker(uv_loop_t *loop, struct engine *engine, fd_array_t *ipc_se
        }
        memcpy(&engine->ipc_set, ipc_set, sizeof(*ipc_set));
 
-       tls_setup_logging(kr_verbose_status);
        /* Notify supervisor. */
 #ifdef HAS_SYSTEMD
        sd_notify(0, "READY=1");
index 0b970613cf0ecb27266750d1830004229e076674..e1ed1161d5f5b4c30966c4fa36c65b3bc62ae29d 100644 (file)
@@ -61,17 +61,6 @@ struct tls_ctx_t {
 #define DEBUG_MSG(fmt...)
 #endif
 
-static void kres_gnutls_log(int level, const char *message)
-{
-       kr_log_error("[tls] gnutls: (%d) %s", level, message);
-}
-
-void tls_setup_logging(bool verbose)
-{
-       gnutls_global_set_log_function(kres_gnutls_log);
-       gnutls_global_set_log_level(verbose ? 5 : 0);
-}
-
 static ssize_t kres_gnutls_push(gnutls_transport_ptr_t h, const void *buf, size_t len)
 {
        struct tls_ctx_t *t = (struct tls_ctx_t *)h;
index d86d4c68212ba4b156c0d9495e27685aa5e19f53..385f8fe39bdd30e0a1127a568e810cfd802e898d 100644 (file)
@@ -34,9 +34,6 @@ struct tls_credentials {
        char *ephemeral_servicename;
 };
 
-/*! Toggle verbose logging from TLS context. */
-void tls_setup_logging(bool verbose);
-
 /*! Create an empty TLS context in query context */
 struct tls_ctx_t* tls_new(struct worker_ctx *worker);
 
index f1195a634d3be865977e2cba8e1f6c8dbb0c2026..f88b33f3417ed14a1463299c4c6be094103c1027 100644 (file)
@@ -22,6 +22,7 @@
 #include <sys/time.h>
 #include <contrib/cleanup.h>
 #include <ccan/isaac/isaac.h>
+#include <gnutls/gnutls.h>
 #include <libknot/descriptor.h>
 #include <libknot/dname.h>
 #include <libknot/rrtype/rrsig.h>
@@ -74,10 +75,22 @@ static inline int u16tostr(uint8_t *dst, uint16_t num)
  * Cleanup callbacks.
  */
 
+static void kres_gnutls_log(int level, const char *message)
+{
+       kr_log_verbose("gnutls: (%d) %s", level, message);
+}
+
 bool kr_verbose_set(bool status)
 {
 #ifndef NOVERBOSELOG
        kr_verbose_status = status;
+
+       /* gnutls logs messages related to our TLS and also libdnssec,
+        * and the logging is set up in a global way only */
+       if (status) {
+               gnutls_global_set_log_function(kres_gnutls_log);
+       }
+       gnutls_global_set_log_level(status ? 5 : 0);
 #endif
        return kr_verbose_status;
 }