mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-20 10:12:15 +01:00
Merge remote-tracking branch 'Ryman/bug6384'
Conflicts: src/or/config.c src/or/main.c
This commit is contained in:
commit
25a3ae922f
2
changes/bug6384
Normal file
2
changes/bug6384
Normal file
@ -0,0 +1,2 @@
|
||||
o Minor features:
|
||||
- Add support for `--library-versions` flag. Implements ticket #6384.
|
@ -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. */
|
||||
|
@ -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);
|
||||
|
@ -196,6 +196,27 @@ try_load_engine(const char *path, const char *engine)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Returns a trimmed and human-readable version of an openssl version string
|
||||
* <b>raw_version</b>. They are usually in the form of 'OpenSSL 1.0.0b 10
|
||||
* May 2012' and this will parse them into a form similar to '1.0.0b' */
|
||||
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 *
|
||||
@ -203,23 +224,24 @@ 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;
|
||||
}
|
||||
|
||||
static char *crypto_openssl_header_version_str = NULL;
|
||||
/* Return a human-readable version of the compile-time openssl version
|
||||
* number. */
|
||||
const char *
|
||||
crypto_openssl_get_header_version_str(void)
|
||||
{
|
||||
if (crypto_openssl_header_version_str == NULL) {
|
||||
crypto_openssl_header_version_str =
|
||||
parse_openssl_version_str(OPENSSL_VERSION_TEXT);
|
||||
}
|
||||
return crypto_openssl_header_version_str;
|
||||
}
|
||||
|
||||
/** Initialize the crypto library. Return 0 on success, -1 on failure.
|
||||
*/
|
||||
int
|
||||
@ -3100,6 +3122,7 @@ crypto_global_cleanup(void)
|
||||
}
|
||||
#endif
|
||||
tor_free(crypto_openssl_version_str);
|
||||
tor_free(crypto_openssl_header_version_str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include "statefile.h"
|
||||
#include "transports.h"
|
||||
#include "ext_orport.h"
|
||||
#include "torgzip.h"
|
||||
#ifdef _WIN32
|
||||
#include <shlobj.h>
|
||||
#endif
|
||||
@ -1808,6 +1809,7 @@ static const struct {
|
||||
{ "--quiet", 0 },
|
||||
{ "--hush", 0 },
|
||||
{ "--version", 0 },
|
||||
{ "--library-versions", 0 },
|
||||
{ "-h", 0 },
|
||||
{ "--help", 0 },
|
||||
{ "--list-torrc-options", 0 },
|
||||
@ -3932,6 +3934,7 @@ options_init_from_torrc(int argc, char **argv)
|
||||
printf("Tor version %s.\n",get_version());
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (config_line_find(cmdline_only_options, "--digests")) {
|
||||
printf("Tor version %s.\n",get_version());
|
||||
printf("%s", libor_get_digests());
|
||||
@ -3939,6 +3942,22 @@ options_init_from_torrc(int argc, char **argv)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (config_line_find(cmdline_only_options, "--library-versions")) {
|
||||
printf("Tor version %s. \n", get_version());
|
||||
printf("Library versions\tCompiled\t\tRuntime\n");
|
||||
printf("Libevent\t\t%-15s\t\t%s\n",
|
||||
tor_libevent_get_header_version_str(),
|
||||
tor_libevent_get_version_str());
|
||||
printf("OpenSSL \t\t%-15s\t\t%s\n",
|
||||
crypto_openssl_get_header_version_str(),
|
||||
crypto_openssl_get_version_str());
|
||||
printf("Zlib \t\t%-15s\t\t%s\n",
|
||||
tor_zlib_get_header_version_str(),
|
||||
tor_zlib_get_version_str());
|
||||
//TODO: Hex versions?
|
||||
exit(0);
|
||||
}
|
||||
|
||||
command = CMD_RUN_TOR;
|
||||
for (p_index = cmdline_only_options; p_index; p_index = p_index->next) {
|
||||
if (!strcmp(p_index->key,"--list-fingerprint")) {
|
||||
|
@ -2351,9 +2351,10 @@ tor_init(int argc, char *argv[])
|
||||
if (!strcmp(cl->key, "--quiet") ||
|
||||
!strcmp(cl->key, "--dump-config"))
|
||||
quiet = 2;
|
||||
/* --version, --digests, and --help imply --husth */
|
||||
/* --version, --digests, and --help imply --hush */
|
||||
if (!strcmp(cl->key, "--version") || !strcmp(cl->key, "--digests") ||
|
||||
!strcmp(cl->key, "--list-torrc-options") ||
|
||||
!strcmp(cl->key, "--library-versions") ||
|
||||
!strcmp(cl->key, "-h") || !strcmp(cl->key, "--help"))
|
||||
quiet = 1;
|
||||
}
|
||||
@ -2382,11 +2383,12 @@ tor_init(int argc, char *argv[])
|
||||
#else
|
||||
"";
|
||||
#endif
|
||||
log_notice(LD_GENERAL, "Tor v%s %srunning on %s with Libevent %s "
|
||||
"and OpenSSL %s.", version, bev_str,
|
||||
log_notice(LD_GENERAL, "Tor v%s %srunning on %s with Libevent %s, "
|
||||
"OpenSSL %s and Zlib %s.", version, bev_str,
|
||||
get_uname(),
|
||||
tor_libevent_get_version_str(),
|
||||
crypto_openssl_get_version_str());
|
||||
crypto_openssl_get_version_str(),
|
||||
tor_zlib_get_version_str());
|
||||
|
||||
log_notice(LD_GENERAL, "Tor can't help you if you use it wrong! "
|
||||
"Learn how to be safe at "
|
||||
|
Loading…
Reference in New Issue
Block a user