From d9d142a15aba29f9e28028f7f9a092bd6f667cc9 Mon Sep 17 00:00:00 2001 From: Nokis Mavrogiannopoulos Date: Wed, 1 Oct 2008 16:01:42 +0000 Subject: better logging --- src/gnutls_hooks.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/gnutls_hooks.c b/src/gnutls_hooks.c index 54b0a83..57d3aaf 100644 --- a/src/gnutls_hooks.c +++ b/src/gnutls_hooks.c @@ -54,6 +54,9 @@ static void gnutls_debug_log_all(int level, const char *str) { apr_file_printf(debug_log_fp, "<%d> %s\n", level, str); } +#define _gnutls_log apr_file_printf +#else +# define _gnutls_log(...) #endif int @@ -67,11 +70,11 @@ int ret; APR_APPEND | APR_WRITE | APR_CREATE, APR_OS_DEFAULT, pconf); - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); gnutls_global_set_log_level(9); gnutls_global_set_log_function(gnutls_debug_log_all); - apr_file_printf(debug_log_fp, "gnutls: %s\n", gnutls_check_version(NULL)); + _gnutls_log(debug_log_fp, "gnutls: %s\n", gnutls_check_version(NULL)); #endif #if APR_HAS_THREADS @@ -84,14 +87,14 @@ int ret; #endif if (gnutls_check_version(LIBGNUTLS_VERSION)==NULL) { - apr_file_printf(debug_log_fp, "gnutls_check_version() failed. Required: gnutls-%s Found: gnutls-%s\n", + _gnutls_log(debug_log_fp, "gnutls_check_version() failed. Required: gnutls-%s Found: gnutls-%s\n", LIBGNUTLS_VERSION, gnutls_check_version(NULL)); return -3; } ret = gnutls_global_init(); if (ret < 0) { - apr_file_printf(debug_log_fp, "gnutls_global_init: %s\n", gnutls_strerror(ret)); + _gnutls_log(debug_log_fp, "gnutls_global_init: %s\n", gnutls_strerror(ret)); return -3; } @@ -109,7 +112,7 @@ static int mgs_select_virtual_server_cb(gnutls_session_t session) int ret; int cprio[2]; - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); ctxt = gnutls_transport_get_ptr(session); @@ -167,7 +170,7 @@ static int cert_retrieve_fn(gnutls_session_t session, gnutls_retr_st * ret) { mgs_handle_t *ctxt; - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); ctxt = gnutls_transport_get_ptr(session); if (ctxt == NULL) @@ -219,7 +222,7 @@ static int read_crt_cn(server_rec * s, apr_pool_t * p, size_t data_len; - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); *cert_cn = NULL; data_len = 0; @@ -271,7 +274,7 @@ static int read_pgpcrt_cn(server_rec * s, apr_pool_t * p, size_t data_len; - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); *cert_cn = NULL; data_len = 0; @@ -304,7 +307,7 @@ mgs_hook_post_config(apr_pool_t * p, apr_pool_t * plog, int first_run = 0; const char *userdata_key = "mgs_init"; - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); apr_pool_userdata_get(&data, userdata_key, base_server->process->pool); if (data == NULL) { first_run = 1; @@ -451,7 +454,7 @@ void mgs_hook_child_init(apr_pool_t * p, server_rec * s) mgs_srvconf_rec *sc = ap_get_module_config(s->module_config, &gnutls_module); - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); if (sc->cache_type != mgs_cache_none) { rv = mgs_cache_child_init(p, s, sc); if (rv != APR_SUCCESS) { @@ -470,7 +473,7 @@ const char *mgs_hook_http_scheme(const request_rec * r) (mgs_srvconf_rec *) ap_get_module_config(r->server->module_config, &gnutls_module); - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); if (sc->enabled == GNUTLS_ENABLED_FALSE) { return NULL; } @@ -484,7 +487,7 @@ apr_port_t mgs_hook_default_port(const request_rec * r) (mgs_srvconf_rec *) ap_get_module_config(r->server->module_config, &gnutls_module); - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); if (sc->enabled == GNUTLS_ENABLED_FALSE) { return 0; } @@ -506,7 +509,7 @@ static int vhost_cb(void *baton, conn_rec * conn, server_rec * s) mgs_srvconf_rec *tsc; vhost_cb_rec *x = baton; - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); tsc = (mgs_srvconf_rec *) ap_get_module_config(s->module_config, &gnutls_module); @@ -559,7 +562,7 @@ mgs_srvconf_rec *mgs_find_sni_server(gnutls_session_t session) mgs_srvconf_rec *tsc; #endif - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); ctxt = gnutls_transport_get_ptr(session); rv = gnutls_server_name_get(ctxt->session, sni_name, @@ -637,7 +640,7 @@ static mgs_handle_t *create_gnutls_handle(apr_pool_t * pool, conn_rec * c) module_config, &gnutls_module); - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); ctxt = apr_pcalloc(pool, sizeof(*ctxt)); ctxt->c = c; ctxt->sc = sc; @@ -676,7 +679,7 @@ int mgs_hook_pre_connection(conn_rec * c, void *csd) module_config, &gnutls_module); - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); if (!(sc && (sc->enabled == GNUTLS_ENABLED_TRUE))) { return DECLINED; } @@ -706,7 +709,7 @@ int mgs_hook_fixups(request_rec * r) mgs_handle_t *ctxt; int rv = OK; - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); apr_table_t *env = r->subprocess_env; ctxt = @@ -781,7 +784,7 @@ int mgs_hook_authz(request_rec * r) mgs_dirconf_rec *dc = ap_get_module_config(r->per_dir_config, &gnutls_module); - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); ctxt = ap_get_module_config(r->connection->conn_config, &gnutls_module); @@ -843,7 +846,7 @@ mgs_add_common_cert_vars(request_rec * r, gnutls_x509_crt_t cert, int side, apr_table_t *env = r->subprocess_env; - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); if (export_certificates_enabled != 0) { char cert_buf[10 * 1024]; len = sizeof(cert_buf); @@ -950,7 +953,7 @@ mgs_add_common_pgpcert_vars(request_rec * r, gnutls_openpgp_crt_t cert, int side size_t len; int ret; - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); apr_table_t *env = r->subprocess_env; if (export_certificates_enabled != 0) { @@ -1017,7 +1020,7 @@ static int mgs_cert_verify(request_rec * r, mgs_handle_t * ctxt) } cert; apr_time_t activation_time, expiration_time, cur_time; - apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); + _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); cert_list = gnutls_certificate_get_peers(ctxt->session, &cert_list_size); -- cgit