aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorKevin Butler <haqkrs@gmail.com>2013-09-01 17:38:01 +0100
committerKevin Butler <haqkrs@gmail.com>2013-09-01 17:38:01 +0100
commit6e17fa6d7ba57b990dd929e07969d35dc82fc46b (patch)
treecb6d7b7e79941df0dec6b7379821c6e8f2cbebe8 /src/common
parent00bcc25d05dc0273323a2cae20c6aa62afd4b50a (diff)
downloadtor-6e17fa6d7ba57b990dd929e07969d35dc82fc46b.tar.gz
tor-6e17fa6d7ba57b990dd929e07969d35dc82fc46b.zip
Added --library-versions flag to print the compile time and runtime versions of libevent, openssl and zlib. Partially implements #6384.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/compat_libevent.c8
-rw-r--r--src/common/compat_libevent.h1
-rw-r--r--src/common/crypto.c41
-rw-r--r--src/common/crypto.h1
-rw-r--r--src/common/torgzip.c16
-rw-r--r--src/common/torgzip.h6
6 files changed, 60 insertions, 13 deletions
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c
index 200a7c65fb..4d0fff833b 100644
--- a/src/common/compat_libevent.c
+++ b/src/common/compat_libevent.c
@@ -415,6 +415,14 @@ tor_check_libevent_version(const char *m, int server,
#define HEADER_VERSION _EVENT_VERSION
#endif
+/** Return a string representation of the version of Libevent that was used
+* at compilation time. */
+const char *
+tor_libevent_get_header_version_str(void)
+{
+ return HEADER_VERSION;
+}
+
/** See whether the headers we were built against differ from the library we
* linked against so much that we're likely to crash. If so, warn the
* user. */
diff --git a/src/common/compat_libevent.h b/src/common/compat_libevent.h
index 2472e2c49e..fda8733592 100644
--- a/src/common/compat_libevent.h
+++ b/src/common/compat_libevent.h
@@ -78,6 +78,7 @@ void tor_check_libevent_version(const char *m, int server,
const char **badness_out);
void tor_check_libevent_header_compatibility(void);
const char *tor_libevent_get_version_str(void);
+const char *tor_libevent_get_header_version_str(void);
#ifdef USE_BUFFEREVENTS
const struct timeval *tor_libevent_get_one_tick_timeout(void);
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 6f1a0bca57..5be3327b81 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -195,6 +195,24 @@ try_load_engine(const char *path, const char *engine)
}
#endif
+static char *
+parse_openssl_version_str(const char *raw_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)
+ return tor_strndup(raw_version,
+ end_of_version-raw_version);
+ else
+ return tor_strdup(raw_version);
+}
+
static char *crypto_openssl_version_str = NULL;
/* Return a human-readable version of the run-time openssl version number. */
const char *
@@ -202,23 +220,20 @@ 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);
+ crypto_openssl_version_str = parse_openssl_version_str(raw_version);
}
return crypto_openssl_version_str;
}
+/* Return a human-readable version of the compile-time openssl version
+* number. */
+const char *
+crypto_openssl_get_header_version_str(void)
+{
+ //return OPENSSL_VERSION_TEXT;
+ return parse_openssl_version_str(OPENSSL_VERSION_TEXT);
+}
+
/** Initialize the crypto library. Return 0 on success, -1 on failure.
*/
int
diff --git a/src/common/crypto.h b/src/common/crypto.h
index 2750ed8109..6ce3697c92 100644
--- a/src/common/crypto.h
+++ b/src/common/crypto.h
@@ -109,6 +109,7 @@ typedef struct crypto_dh_t crypto_dh_t;
/* global state */
const char * crypto_openssl_get_version_str(void);
+const char * crypto_openssl_get_header_version_str(void);
int crypto_global_init(int hardwareAccel,
const char *accelName,
const char *accelPath);
diff --git a/src/common/torgzip.c b/src/common/torgzip.c
index 4328c63c8b..15451ee30d 100644
--- a/src/common/torgzip.c
+++ b/src/common/torgzip.c
@@ -68,6 +68,22 @@ is_gzip_supported(void)
return gzip_is_supported;
}
+/** Return a string representation of the version of the currently running
+ * version of zlib. */
+const char *
+tor_zlib_get_version_str(void)
+{
+ return zlibVersion();
+}
+
+/** Return a string representation of the version of the version of zlib
+* used at compilation. */
+const char *
+tor_zlib_get_header_version_str(void)
+{
+ return ZLIB_VERSION;
+}
+
/** Return the 'bits' value to tell zlib to use <b>method</b>.*/
static INLINE int
method_bits(compress_method_t method)
diff --git a/src/common/torgzip.h b/src/common/torgzip.h
index be1016445b..5db03fe6e0 100644
--- a/src/common/torgzip.h
+++ b/src/common/torgzip.h
@@ -32,6 +32,12 @@ tor_gzip_uncompress(char **out, size_t *out_len,
int is_gzip_supported(void);
+const char *
+tor_zlib_get_version_str(void);
+
+const char *
+tor_zlib_get_header_version_str(void);
+
compress_method_t detect_compression_method(const char *in, size_t in_len);
/** Return values from tor_zlib_process; see that function's documentation for