diff options
| author | 2008-10-01 16:01:42 +0000 | |
|---|---|---|
| committer | 2008-10-01 16:01:42 +0000 | |
| commit | d9d142a15aba29f9e28028f7f9a092bd6f667cc9 (patch) | |
| tree | 5ec2340c7e74f9f8b6ad1a68571d9f936949477f | |
| parent | 61c98e4aa9db50970b030d71f6e7640f5a67d743 (diff) | |
better logging
| -rw-r--r-- | src/gnutls_hooks.c | 45 |
1 files changed, 24 insertions, 21 deletions
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) | |||
| 54 | { | 54 | { |
| 55 | apr_file_printf(debug_log_fp, "<%d> %s\n", level, str); | 55 | apr_file_printf(debug_log_fp, "<%d> %s\n", level, str); |
| 56 | } | 56 | } |
| 57 | #define _gnutls_log apr_file_printf | ||
| 58 | #else | ||
| 59 | # define _gnutls_log(...) | ||
| 57 | #endif | 60 | #endif |
| 58 | 61 | ||
| 59 | int | 62 | int |
| @@ -67,11 +70,11 @@ int ret; | |||
| 67 | APR_APPEND | APR_WRITE | APR_CREATE, APR_OS_DEFAULT, | 70 | APR_APPEND | APR_WRITE | APR_CREATE, APR_OS_DEFAULT, |
| 68 | pconf); | 71 | pconf); |
| 69 | 72 | ||
| 70 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 73 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 71 | 74 | ||
| 72 | gnutls_global_set_log_level(9); | 75 | gnutls_global_set_log_level(9); |
| 73 | gnutls_global_set_log_function(gnutls_debug_log_all); | 76 | gnutls_global_set_log_function(gnutls_debug_log_all); |
| 74 | apr_file_printf(debug_log_fp, "gnutls: %s\n", gnutls_check_version(NULL)); | 77 | _gnutls_log(debug_log_fp, "gnutls: %s\n", gnutls_check_version(NULL)); |
| 75 | #endif | 78 | #endif |
| 76 | 79 | ||
| 77 | #if APR_HAS_THREADS | 80 | #if APR_HAS_THREADS |
| @@ -84,14 +87,14 @@ int ret; | |||
| 84 | #endif | 87 | #endif |
| 85 | 88 | ||
| 86 | if (gnutls_check_version(LIBGNUTLS_VERSION)==NULL) { | 89 | if (gnutls_check_version(LIBGNUTLS_VERSION)==NULL) { |
| 87 | apr_file_printf(debug_log_fp, "gnutls_check_version() failed. Required: gnutls-%s Found: gnutls-%s\n", | 90 | _gnutls_log(debug_log_fp, "gnutls_check_version() failed. Required: gnutls-%s Found: gnutls-%s\n", |
| 88 | LIBGNUTLS_VERSION, gnutls_check_version(NULL)); | 91 | LIBGNUTLS_VERSION, gnutls_check_version(NULL)); |
| 89 | return -3; | 92 | return -3; |
| 90 | } | 93 | } |
| 91 | 94 | ||
| 92 | ret = gnutls_global_init(); | 95 | ret = gnutls_global_init(); |
| 93 | if (ret < 0) { | 96 | if (ret < 0) { |
| 94 | apr_file_printf(debug_log_fp, "gnutls_global_init: %s\n", gnutls_strerror(ret)); | 97 | _gnutls_log(debug_log_fp, "gnutls_global_init: %s\n", gnutls_strerror(ret)); |
| 95 | return -3; | 98 | return -3; |
| 96 | } | 99 | } |
| 97 | 100 | ||
| @@ -109,7 +112,7 @@ static int mgs_select_virtual_server_cb(gnutls_session_t session) | |||
| 109 | int ret; | 112 | int ret; |
| 110 | int cprio[2]; | 113 | int cprio[2]; |
| 111 | 114 | ||
| 112 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 115 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 113 | 116 | ||
| 114 | ctxt = gnutls_transport_get_ptr(session); | 117 | ctxt = gnutls_transport_get_ptr(session); |
| 115 | 118 | ||
| @@ -167,7 +170,7 @@ static int cert_retrieve_fn(gnutls_session_t session, gnutls_retr_st * ret) | |||
| 167 | { | 170 | { |
| 168 | mgs_handle_t *ctxt; | 171 | mgs_handle_t *ctxt; |
| 169 | 172 | ||
| 170 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 173 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 171 | ctxt = gnutls_transport_get_ptr(session); | 174 | ctxt = gnutls_transport_get_ptr(session); |
| 172 | 175 | ||
| 173 | if (ctxt == NULL) | 176 | if (ctxt == NULL) |
| @@ -219,7 +222,7 @@ static int read_crt_cn(server_rec * s, apr_pool_t * p, | |||
| 219 | size_t data_len; | 222 | size_t data_len; |
| 220 | 223 | ||
| 221 | 224 | ||
| 222 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 225 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 223 | *cert_cn = NULL; | 226 | *cert_cn = NULL; |
| 224 | 227 | ||
| 225 | data_len = 0; | 228 | data_len = 0; |
| @@ -271,7 +274,7 @@ static int read_pgpcrt_cn(server_rec * s, apr_pool_t * p, | |||
| 271 | size_t data_len; | 274 | size_t data_len; |
| 272 | 275 | ||
| 273 | 276 | ||
| 274 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 277 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 275 | *cert_cn = NULL; | 278 | *cert_cn = NULL; |
| 276 | 279 | ||
| 277 | data_len = 0; | 280 | data_len = 0; |
| @@ -304,7 +307,7 @@ mgs_hook_post_config(apr_pool_t * p, apr_pool_t * plog, | |||
| 304 | int first_run = 0; | 307 | int first_run = 0; |
| 305 | const char *userdata_key = "mgs_init"; | 308 | const char *userdata_key = "mgs_init"; |
| 306 | 309 | ||
| 307 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 310 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 308 | apr_pool_userdata_get(&data, userdata_key, base_server->process->pool); | 311 | apr_pool_userdata_get(&data, userdata_key, base_server->process->pool); |
| 309 | if (data == NULL) { | 312 | if (data == NULL) { |
| 310 | first_run = 1; | 313 | first_run = 1; |
| @@ -451,7 +454,7 @@ void mgs_hook_child_init(apr_pool_t * p, server_rec * s) | |||
| 451 | mgs_srvconf_rec *sc = ap_get_module_config(s->module_config, | 454 | mgs_srvconf_rec *sc = ap_get_module_config(s->module_config, |
| 452 | &gnutls_module); | 455 | &gnutls_module); |
| 453 | 456 | ||
| 454 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 457 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 455 | if (sc->cache_type != mgs_cache_none) { | 458 | if (sc->cache_type != mgs_cache_none) { |
| 456 | rv = mgs_cache_child_init(p, s, sc); | 459 | rv = mgs_cache_child_init(p, s, sc); |
| 457 | if (rv != APR_SUCCESS) { | 460 | if (rv != APR_SUCCESS) { |
| @@ -470,7 +473,7 @@ const char *mgs_hook_http_scheme(const request_rec * r) | |||
| 470 | (mgs_srvconf_rec *) ap_get_module_config(r->server->module_config, | 473 | (mgs_srvconf_rec *) ap_get_module_config(r->server->module_config, |
| 471 | &gnutls_module); | 474 | &gnutls_module); |
| 472 | 475 | ||
| 473 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 476 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 474 | if (sc->enabled == GNUTLS_ENABLED_FALSE) { | 477 | if (sc->enabled == GNUTLS_ENABLED_FALSE) { |
| 475 | return NULL; | 478 | return NULL; |
| 476 | } | 479 | } |
| @@ -484,7 +487,7 @@ apr_port_t mgs_hook_default_port(const request_rec * r) | |||
| 484 | (mgs_srvconf_rec *) ap_get_module_config(r->server->module_config, | 487 | (mgs_srvconf_rec *) ap_get_module_config(r->server->module_config, |
| 485 | &gnutls_module); | 488 | &gnutls_module); |
| 486 | 489 | ||
| 487 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 490 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 488 | if (sc->enabled == GNUTLS_ENABLED_FALSE) { | 491 | if (sc->enabled == GNUTLS_ENABLED_FALSE) { |
| 489 | return 0; | 492 | return 0; |
| 490 | } | 493 | } |
| @@ -506,7 +509,7 @@ static int vhost_cb(void *baton, conn_rec * conn, server_rec * s) | |||
| 506 | mgs_srvconf_rec *tsc; | 509 | mgs_srvconf_rec *tsc; |
| 507 | vhost_cb_rec *x = baton; | 510 | vhost_cb_rec *x = baton; |
| 508 | 511 | ||
| 509 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 512 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 510 | tsc = (mgs_srvconf_rec *) ap_get_module_config(s->module_config, | 513 | tsc = (mgs_srvconf_rec *) ap_get_module_config(s->module_config, |
| 511 | &gnutls_module); | 514 | &gnutls_module); |
| 512 | 515 | ||
| @@ -559,7 +562,7 @@ mgs_srvconf_rec *mgs_find_sni_server(gnutls_session_t session) | |||
| 559 | mgs_srvconf_rec *tsc; | 562 | mgs_srvconf_rec *tsc; |
| 560 | #endif | 563 | #endif |
| 561 | 564 | ||
| 562 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 565 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 563 | ctxt = gnutls_transport_get_ptr(session); | 566 | ctxt = gnutls_transport_get_ptr(session); |
| 564 | 567 | ||
| 565 | rv = gnutls_server_name_get(ctxt->session, sni_name, | 568 | 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) | |||
| 637 | module_config, | 640 | module_config, |
| 638 | &gnutls_module); | 641 | &gnutls_module); |
| 639 | 642 | ||
| 640 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 643 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 641 | ctxt = apr_pcalloc(pool, sizeof(*ctxt)); | 644 | ctxt = apr_pcalloc(pool, sizeof(*ctxt)); |
| 642 | ctxt->c = c; | 645 | ctxt->c = c; |
| 643 | ctxt->sc = sc; | 646 | ctxt->sc = sc; |
| @@ -676,7 +679,7 @@ int mgs_hook_pre_connection(conn_rec * c, void *csd) | |||
| 676 | module_config, | 679 | module_config, |
| 677 | &gnutls_module); | 680 | &gnutls_module); |
| 678 | 681 | ||
| 679 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 682 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 680 | if (!(sc && (sc->enabled == GNUTLS_ENABLED_TRUE))) { | 683 | if (!(sc && (sc->enabled == GNUTLS_ENABLED_TRUE))) { |
| 681 | return DECLINED; | 684 | return DECLINED; |
| 682 | } | 685 | } |
| @@ -706,7 +709,7 @@ int mgs_hook_fixups(request_rec * r) | |||
| 706 | mgs_handle_t *ctxt; | 709 | mgs_handle_t *ctxt; |
| 707 | int rv = OK; | 710 | int rv = OK; |
| 708 | 711 | ||
| 709 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 712 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 710 | apr_table_t *env = r->subprocess_env; | 713 | apr_table_t *env = r->subprocess_env; |
| 711 | 714 | ||
| 712 | ctxt = | 715 | ctxt = |
| @@ -781,7 +784,7 @@ int mgs_hook_authz(request_rec * r) | |||
| 781 | mgs_dirconf_rec *dc = ap_get_module_config(r->per_dir_config, | 784 | mgs_dirconf_rec *dc = ap_get_module_config(r->per_dir_config, |
| 782 | &gnutls_module); | 785 | &gnutls_module); |
| 783 | 786 | ||
| 784 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 787 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 785 | ctxt = | 788 | ctxt = |
| 786 | ap_get_module_config(r->connection->conn_config, &gnutls_module); | 789 | ap_get_module_config(r->connection->conn_config, &gnutls_module); |
| 787 | 790 | ||
| @@ -843,7 +846,7 @@ mgs_add_common_cert_vars(request_rec * r, gnutls_x509_crt_t cert, int side, | |||
| 843 | 846 | ||
| 844 | apr_table_t *env = r->subprocess_env; | 847 | apr_table_t *env = r->subprocess_env; |
| 845 | 848 | ||
| 846 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 849 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 847 | if (export_certificates_enabled != 0) { | 850 | if (export_certificates_enabled != 0) { |
| 848 | char cert_buf[10 * 1024]; | 851 | char cert_buf[10 * 1024]; |
| 849 | len = sizeof(cert_buf); | 852 | len = sizeof(cert_buf); |
| @@ -950,7 +953,7 @@ mgs_add_common_pgpcert_vars(request_rec * r, gnutls_openpgp_crt_t cert, int side | |||
| 950 | size_t len; | 953 | size_t len; |
| 951 | int ret; | 954 | int ret; |
| 952 | 955 | ||
| 953 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 956 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 954 | apr_table_t *env = r->subprocess_env; | 957 | apr_table_t *env = r->subprocess_env; |
| 955 | 958 | ||
| 956 | if (export_certificates_enabled != 0) { | 959 | if (export_certificates_enabled != 0) { |
| @@ -1017,7 +1020,7 @@ static int mgs_cert_verify(request_rec * r, mgs_handle_t * ctxt) | |||
| 1017 | } cert; | 1020 | } cert; |
| 1018 | apr_time_t activation_time, expiration_time, cur_time; | 1021 | apr_time_t activation_time, expiration_time, cur_time; |
| 1019 | 1022 | ||
| 1020 | apr_file_printf(debug_log_fp, "%s: %d\n", __func__, __LINE__); | 1023 | _gnutls_log(debug_log_fp, "%s: %d\n", __func__, __LINE__); |
| 1021 | cert_list = | 1024 | cert_list = |
| 1022 | gnutls_certificate_get_peers(ctxt->session, &cert_list_size); | 1025 | gnutls_certificate_get_peers(ctxt->session, &cert_list_size); |
| 1023 | 1026 | ||
