Explorar el Código

Don't log about Libevent/OpenSSL initialization when all's well

OTOH, log the Libevent and OpenSSL versions on the first line when
we're starting Tor.
Nick Mathewson hace 11 años
padre
commit
e3a130a7eb
Se han modificado 7 ficheros con 44 adiciones y 11 borrados
  1. 3 0
      changes/quiet_lib_init
  2. 4 4
      src/common/aes.c
  3. 1 1
      src/common/compat_libevent.c
  4. 25 0
      src/common/crypto.c
  5. 1 0
      src/common/crypto.h
  6. 3 3
      src/common/tortls.c
  7. 7 3
      src/or/main.c

+ 3 - 0
changes/quiet_lib_init

@@ -0,0 +1,3 @@
+  o Minor features:
+    - Log less at level notice about our OpenSSL and Libevent versions
+      when everything is going right. Partial fix for 6736.

+ 4 - 4
src/common/aes.c

@@ -212,11 +212,11 @@ evaluate_evp_for_aes(int force_val)
   e = ENGINE_get_cipher_engine(NID_aes_128_ecb);
 
   if (e) {
-    log_notice(LD_CRYPTO, "AES engine \"%s\" found; using EVP_* functions.",
+    log_info(LD_CRYPTO, "AES engine \"%s\" found; using EVP_* functions.",
                ENGINE_get_name(e));
     should_use_EVP = 1;
   } else {
-    log_notice(LD_CRYPTO, "No AES engine found; using AES_* functions.");
+    log_info(LD_CRYPTO, "No AES engine found; using AES_* functions.");
     should_use_EVP = 0;
   }
 #endif
@@ -263,12 +263,12 @@ evaluate_ctr_for_aes(void)
                "not using it.");
   } else {
     /* Counter mode is okay */
-    log_notice(LD_CRYPTO, "This OpenSSL has a good implementation of counter "
+    log_info(LD_CRYPTO, "This OpenSSL has a good implementation of counter "
                "mode; using it.");
     should_use_openssl_CTR = 1;
   }
 #else
-  log_notice(LD_CRYPTO, "This version of OpenSSL has a slow implementation of "
+  log_info(LD_CRYPTO, "This version of OpenSSL has a slow implementation of "
              "counter mode; not using it.");
 #endif
   return 0;

+ 1 - 1
src/common/compat_libevent.c

@@ -266,7 +266,7 @@ tor_libevent_initialize(tor_libevent_cfg *torcfg)
 #if defined(HAVE_EVENT_GET_VERSION) && defined(HAVE_EVENT_GET_METHOD)
   /* Making this a NOTICE for now so we can link bugs to a libevent versions
    * or methods better. */
-  log(LOG_NOTICE, LD_GENERAL,
+  log(LOG_INFO, LD_GENERAL,
       "Initialized libevent version %s using method %s. Good.",
       event_get_version(), tor_libevent_get_method());
 #else

+ 25 - 0
src/common/crypto.c

@@ -221,6 +221,30 @@ try_load_engine(const char *path, const char *engine)
 }
 #endif
 
+static char *crypto_openssl_version_str = NULL;
+/* Return a human-readable version of the run-time openssl version number. */
+const char *
+crypto_openssl_get_version_str(void)
+{
+  if (crypto_openssl_version_str == NULL) {
+    const char *raw_version = SSLeay_version(SSLEAY_VERSION);
+    const char *end_of_version = NULL;
+    /* The output should be something like "OpenSSL 1.0.0b 10 May 2012. Let's
+       trim that down. */
+    if (!strcmpstart(raw_version, "OpenSSL ")) {
+      raw_version += strlen("OpenSSL ");
+      end_of_version = strchr(raw_version, ' ');
+    }
+
+    if (end_of_version)
+      crypto_openssl_version_str = tor_strndup(raw_version,
+                                               end_of_version-raw_version);
+    else
+      crypto_openssl_version_str = tor_strdup(raw_version);
+  }
+  return crypto_openssl_version_str;
+}
+
 /** Initialize the crypto library.  Return 0 on success, -1 on failure.
  */
 int
@@ -3018,6 +3042,7 @@ crypto_global_cleanup(void)
     tor_free(ms);
   }
 #endif
+  tor_free(crypto_openssl_version_str);
   return 0;
 }
 

+ 1 - 0
src/common/crypto.h

@@ -111,6 +111,7 @@ typedef struct crypto_digest_t crypto_digest_t;
 typedef struct crypto_dh_t crypto_dh_t;
 
 /* global state */
+const char * crypto_openssl_get_version_str(void);
 int crypto_global_init(int hardwareAccel,
                        const char *accelName,
                        const char *accelPath);

+ 3 - 3
src/common/tortls.c

@@ -478,7 +478,7 @@ tor_tls_init(void)
      * a test of intelligence and determination.
      */
     if (version > OPENSSL_V(0,9,8,'k') && version <= OPENSSL_V(0,9,8,'l')) {
-      log_notice(LD_GENERAL, "OpenSSL %s looks like version 0.9.8l, but "
+      log_info(LD_GENERAL, "OpenSSL %s looks like version 0.9.8l, but "
                  "some vendors have backported renegotiation code from "
                  "0.9.8m without updating the version number. "
                  "I will try SSL3_FLAGS and SSL_OP to enable renegotation.",
@@ -486,12 +486,12 @@ tor_tls_init(void)
       use_unsafe_renegotiation_flag = 1;
       use_unsafe_renegotiation_op = 1;
     } else if (version > OPENSSL_V(0,9,8,'l')) {
-      log_notice(LD_GENERAL, "OpenSSL %s looks like version 0.9.8m or later; "
+      log_info(LD_GENERAL, "OpenSSL %s looks like version 0.9.8m or later; "
                  "I will try SSL_OP to enable renegotiation",
                  SSLeay_version(SSLEAY_VERSION));
       use_unsafe_renegotiation_op = 1;
     } else if (version <= OPENSSL_V(0,9,8,'k')) {
-      log_notice(LD_GENERAL, "OpenSSL %s [%lx] looks like it's older than "
+      log_info(LD_GENERAL, "OpenSSL %s [%lx] looks like it's older than "
                  "0.9.8l, but some vendors have backported 0.9.8l's "
                  "renegotiation code to earlier versions, and some have "
                  "backported the code from 0.9.8m or 0.9.8n.  I'll set both "

+ 7 - 3
src/or/main.c

@@ -2304,12 +2304,16 @@ tor_init(int argc, char *argv[])
 
   {
     const char *version = get_version();
+    log_notice(LD_GENERAL, "Tor v%s %srunning on %s with Libevent %s "
+               "and OpenSSL %s.", version,
 #ifdef USE_BUFFEREVENTS
-    log_notice(LD_GENERAL, "Tor v%s (with bufferevents) running on %s.",
-                version, get_uname());
+               "(with bufferevents) ",
 #else
-    log_notice(LD_GENERAL, "Tor v%s running on %s.", version, get_uname());
+               "",
 #endif
+               get_uname(),
+               tor_libevent_get_version_str(),
+               crypto_openssl_get_version_str());
 
     log_notice(LD_GENERAL, "Tor can't help you if you use it wrong! "
                "Learn how to be safe at "