]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
keylogfile: only consider the SSLKEYLOGFILE variable
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Mon, 6 Jun 2016 16:43:12 +0000 (18:43 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Mon, 6 Jun 2016 16:46:43 +0000 (18:46 +0200)
In addition do not check the environment in the constructor
but instead use static variables to save the key file name.
The GNUTLS_KEYLOGFILE environment variable is no longer used
since there is no reason to have a separate one.

lib/global.c
lib/global.h
lib/kx.c
tests/keylog-env.c

index ef05efaba188ca40776a0a769b4fb71a1e6f3872..535bb19896f0082bddbb152f4fc9a1a407f85481 100644 (file)
@@ -71,7 +71,6 @@ extern const ASN1_ARRAY_TYPE gnutls_asn1_tab[];
 extern const ASN1_ARRAY_TYPE pkix_asn1_tab[];
 void *_gnutls_file_mutex;
 void *_gnutls_pkcs11_mutex;
-const char *_gnutls_keylogfile = NULL;
 
 ASN1_TYPE _gnutls_pkix1_asn = ASN1_TYPE_EMPTY;
 ASN1_TYPE _gnutls_gnutls_asn = ASN1_TYPE_EMPTY;
@@ -242,10 +241,6 @@ int gnutls_global_init(void)
 
        _gnutls_switch_lib_state(LIB_STATE_INIT);
 
-       _gnutls_keylogfile = secure_getenv("GNUTLS_KEYLOGFILE");
-       if (_gnutls_keylogfile == NULL)
-               _gnutls_keylogfile = secure_getenv("SSLKEYLOGFILE");
-
        e = secure_getenv("GNUTLS_DEBUG_LEVEL");
        if (e != NULL) {
                level = atoi(e);
index 8efa3b417b0c7f4e2f079d6077ca0bfe8e6b9638..45d8dcaff8752aab786765e9f2fca3f3ab29e462 100644 (file)
@@ -38,8 +38,6 @@ extern ASN1_TYPE _gnutls_gnutls_asn;
 #define _gnutls_get_gnutls_asn() ((ASN1_TYPE) _gnutls_gnutls_asn)
 #define _gnutls_get_pkix() ((ASN1_TYPE) _gnutls_pkix1_asn)
 
-extern const char *_gnutls_keylogfile;
-
 extern gnutls_log_func _gnutls_log_func;
 extern gnutls_audit_log_func _gnutls_audit_log_func;
 extern int _gnutls_log_level;
index 87a93f69069599f2076e0e1e0418bf8fcdf7b5a5..4e0a50bd7439969201af9fe90bcb8d9982cfa2f1 100644 (file)
--- a/lib/kx.c
+++ b/lib/kx.c
@@ -100,11 +100,18 @@ static void write_nss_key_log(gnutls_session_t session, const gnutls_datum_t *pr
        char buf[512];
        char buf2[512];
        FILE *fp;
+       static const char *keylogfile = NULL;
+       static unsigned checked_env = 0;
 
-       if (_gnutls_keylogfile == NULL)
+       if (!checked_env) {
+               checked_env = 1;
+               keylogfile = secure_getenv("SSLKEYLOGFILE");
+       }
+
+       if (keylogfile == NULL)
                return;
 
-       fp = fopen(_gnutls_keylogfile, "a");
+       fp = fopen(keylogfile, "a");
        if (fp == NULL)
                return;
 
index 666c61ace4a8b7d2486c265ca03f6506b5256f51..ec35a6b0485ab50b234c02deaa2e57ead179da11 100644 (file)
@@ -129,7 +129,5 @@ void doit(void)
 
        assert(get_tmpname(filename)!=NULL);
 
-       gnutls_global_deinit();
-       run("GNUTLS_KEYLOGFILE", filename);
        run("SSLKEYLOGFILE", filename);
 }