Merge remote-tracking branch 'tor-gitlab/mr/59'

This commit is contained in:
Nick Mathewson 2020-07-20 16:37:11 -04:00
commit d6570eaf5d
16 changed files with 122 additions and 17 deletions

6
changes/feature40047 Normal file
View File

@ -0,0 +1,6 @@
o Minor features (logging):
- Adds the running glibc version to the log. Also adds the
running and compiled glibc version to the library list
returned when using the flag --library-versions. Patch
from Daniel Pinto. Closes ticket 40047; bugfix on
0.4.5.0-alpha-dev.

View File

@ -34,10 +34,10 @@
# Remember: It is better to fix the problem than to add a new exception! # Remember: It is better to fix the problem than to add a new exception!
problem file-size /src/app/config/config.c 7525 problem file-size /src/app/config/config.c 7525
problem include-count /src/app/config/config.c 80 problem include-count /src/app/config/config.c 81
problem function-size /src/app/config/config.c:options_act() 381 problem function-size /src/app/config/config.c:options_act() 381
problem function-size /src/app/config/config.c:options_validate_cb() 794 problem function-size /src/app/config/config.c:options_validate_cb() 794
problem function-size /src/app/config/config.c:options_init_from_torrc() 192 problem function-size /src/app/config/config.c:options_init_from_torrc() 198
problem function-size /src/app/config/config.c:options_init_from_string() 103 problem function-size /src/app/config/config.c:options_init_from_string() 103
problem function-size /src/app/config/config.c:options_init_logs() 125 problem function-size /src/app/config/config.c:options_init_logs() 125
problem function-size /src/app/config/config.c:parse_bridge_line() 104 problem function-size /src/app/config/config.c:parse_bridge_line() 104
@ -48,9 +48,9 @@ problem function-size /src/app/config/config.c:port_parse_config() 435
problem function-size /src/app/config/config.c:parse_ports() 132 problem function-size /src/app/config/config.c:parse_ports() 132
problem function-size /src/app/config/resolve_addr.c:resolve_my_address_v4() 197 problem function-size /src/app/config/resolve_addr.c:resolve_my_address_v4() 197
problem file-size /src/app/config/or_options_st.h 1050 problem file-size /src/app/config/or_options_st.h 1050
problem include-count /src/app/main/main.c 68 problem include-count /src/app/main/main.c 71
problem function-size /src/app/main/main.c:dumpstats() 102 problem function-size /src/app/main/main.c:dumpstats() 102
problem function-size /src/app/main/main.c:tor_init() 101 problem function-size /src/app/main/main.c:tor_init() 109
problem function-size /src/app/main/main.c:sandbox_init_filter() 291 problem function-size /src/app/main/main.c:sandbox_init_filter() 291
problem function-size /src/app/main/main.c:run_tor_main_loop() 105 problem function-size /src/app/main/main.c:run_tor_main_loop() 105
problem function-size /src/app/main/ntmain.c:nt_service_install() 126 problem function-size /src/app/main/ntmain.c:nt_service_install() 126

View File

@ -140,6 +140,7 @@
#include "lib/meminfo/meminfo.h" #include "lib/meminfo/meminfo.h"
#include "lib/osinfo/uname.h" #include "lib/osinfo/uname.h"
#include "lib/osinfo/libc.h"
#include "lib/process/daemon.h" #include "lib/process/daemon.h"
#include "lib/process/pidfile.h" #include "lib/process/pidfile.h"
#include "lib/process/restrict.h" #include "lib/process/restrict.h"
@ -4365,6 +4366,12 @@ options_init_from_torrc(int argc, char **argv)
tor_compress_version_str(ZSTD_METHOD), tor_compress_version_str(ZSTD_METHOD),
tor_compress_header_version_str(ZSTD_METHOD)); tor_compress_header_version_str(ZSTD_METHOD));
} }
if (tor_libc_get_name()) {
printf("%-7s \t\t%-15s\t\t%s\n",
tor_libc_get_name(),
tor_libc_get_header_version_str(),
tor_libc_get_version_str());
}
//TODO: Hex versions? //TODO: Hex versions?
return 1; return 1;
} }

View File

@ -67,6 +67,7 @@
#include "lib/meminfo/meminfo.h" #include "lib/meminfo/meminfo.h"
#include "lib/osinfo/uname.h" #include "lib/osinfo/uname.h"
#include "lib/osinfo/libc.h"
#include "lib/sandbox/sandbox.h" #include "lib/sandbox/sandbox.h"
#include "lib/fs/lockfile.h" #include "lib/fs/lockfile.h"
#include "lib/tls/tortls.h" #include "lib/tls/tortls.h"
@ -574,7 +575,8 @@ tor_init(int argc, char *argv[])
const char *version = get_version(); const char *version = get_version();
log_notice(LD_GENERAL, "Tor %s running on %s with Libevent %s, " log_notice(LD_GENERAL, "Tor %s running on %s with Libevent %s, "
"%s %s, Zlib %s, Liblzma %s, and Libzstd %s.", version, "%s %s, Zlib %s, Liblzma %s, Libzstd %s and %s %s as libc.",
version,
get_uname(), get_uname(),
tor_libevent_get_version_str(), tor_libevent_get_version_str(),
crypto_get_library_name(), crypto_get_library_name(),
@ -584,7 +586,10 @@ tor_init(int argc, char *argv[])
tor_compress_supports_method(LZMA_METHOD) ? tor_compress_supports_method(LZMA_METHOD) ?
tor_compress_version_str(LZMA_METHOD) : "N/A", tor_compress_version_str(LZMA_METHOD) : "N/A",
tor_compress_supports_method(ZSTD_METHOD) ? tor_compress_supports_method(ZSTD_METHOD) ?
tor_compress_version_str(ZSTD_METHOD) : "N/A"); tor_compress_version_str(ZSTD_METHOD) : "N/A",
tor_libc_get_name() ?
tor_libc_get_name() : "Unknown",
tor_libc_get_version_str());
log_notice(LD_GENERAL, "Tor can't help you if you use it wrong! " log_notice(LD_GENERAL, "Tor can't help you if you use it wrong! "
"Learn how to be safe at " "Learn how to be safe at "

View File

@ -7,7 +7,8 @@ endif
# ADD_C_FILE: INSERT SOURCES HERE. # ADD_C_FILE: INSERT SOURCES HERE.
src_lib_libtor_osinfo_a_SOURCES = \ src_lib_libtor_osinfo_a_SOURCES = \
src/lib/osinfo/uname.c src/lib/osinfo/uname.c \
src/lib/osinfo/libc.c
src_lib_libtor_osinfo_testing_a_SOURCES = \ src_lib_libtor_osinfo_testing_a_SOURCES = \
$(src_lib_libtor_osinfo_a_SOURCES) $(src_lib_libtor_osinfo_a_SOURCES)
@ -16,4 +17,5 @@ src_lib_libtor_osinfo_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
# ADD_C_FILE: INSERT HEADERS HERE. # ADD_C_FILE: INSERT HEADERS HERE.
noinst_HEADERS += \ noinst_HEADERS += \
src/lib/osinfo/uname.h src/lib/osinfo/uname.h \
src/lib/osinfo/libc.h

66
src/lib/osinfo/libc.c Normal file
View File

@ -0,0 +1,66 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
* Copyright (c) 2007-2020, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
* @file libc.c
* @brief Functions to get the name and version of the system libc.
**/
#include "orconfig.h"
#include "lib/osinfo/libc.h"
#include <stdlib.h>
#ifdef HAVE_GNU_LIBC_VERSION_H
#include <gnu/libc-version.h>
#endif
#ifdef HAVE_GNU_LIBC_VERSION_H
#ifdef HAVE_GNU_GET_LIBC_VERSION
#define CHECK_LIBC_VERSION
#endif
#endif
#define STR_IMPL(x) #x
#define STR(x) STR_IMPL(x)
/** Return the name of the compile time libc. Returns NULL if we
* cannot identify the libc. */
const char *
tor_libc_get_name(void)
{
#ifdef __GLIBC__
return "Glibc";
#else /* !defined(__GLIBC__) */
return NULL;
#endif /* defined(__GLIBC__) */
}
/** Return a string representation of the version of the currently running
* version of Glibc. */
const char *
tor_libc_get_version_str(void)
{
#ifdef CHECK_LIBC_VERSION
const char *version = gnu_get_libc_version();
if (version == NULL)
return "N/A";
return version;
#else /* !defined(CHECK_LIBC_VERSION) */
return "N/A";
#endif /* defined(CHECK_LIBC_VERSION) */
}
/** Return a string representation of the version of Glibc that was used at
* compilation time. */
const char *
tor_libc_get_header_version_str(void)
{
#ifdef __GLIBC__
return STR(__GLIBC__) "." STR(__GLIBC_MINOR__);
#else
return "N/A";
#endif /* defined(__GLIBC__) */
}

19
src/lib/osinfo/libc.h Normal file
View File

@ -0,0 +1,19 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
* Copyright (c) 2007-2020, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
* @file libc.h
* @brief Header for lib/osinfo/libc.c
**/
#ifndef TOR_LIB_OSINFO_LIBC_H
#define TOR_LIB_OSINFO_LIBC_H
const char *tor_libc_get_name(void);
const char *tor_libc_get_version_str(void);
const char *tor_libc_get_header_version_str(void);
#endif /* !defined(TOR_LIB_OSINFO_LIBC_H) */

View File

@ -1 +1 @@
Tor 0.* running on .* with Libevent .*, NSS .*, Zlib .*, Liblzma .*, and Libzstd .* Tor 0.* running on .* with Libevent .*, NSS .*, Zlib .*, Liblzma .*, Libzstd .* and .* .* as libc

View File

@ -1 +1 @@
Tor 0.* running on .* with Libevent .*, NSS .*, Zlib .*, Liblzma .*, and Libzstd .* Tor 0.* running on .* with Libevent .*, NSS .*, Zlib .*, Liblzma .*, Libzstd .* and .* .* as libc

View File

@ -1 +1 @@
Tor 0.* running on .* with Libevent .*, .*, Zlib .*, Liblzma N/A, and Libzstd N/A Tor 0.* running on .* with Libevent .*, .*, Zlib .*, Liblzma N/A, Libzstd N/A and .* .* as libc

View File

@ -1 +1 @@
Tor 0.* running on .* with Libevent .*, .*, Zlib .*, Liblzma .*, and Libzstd N/A Tor 0.* running on .* with Libevent .*, .*, Zlib .*, Liblzma .*, Libzstd N/A and .* .* as libc

View File

@ -1 +1 @@
Tor 0.* running on .* with Libevent .*, .*, Zlib .*, Liblzma .*, and Libzstd .* Tor 0.* running on .* with Libevent .*, .*, Zlib .*, Liblzma .*, Libzstd .* and .* .* as libc

View File

@ -1 +1 @@
Tor 0.* running on .* with Libevent .*, .*, Zlib .*, Liblzma N/A, and Libzstd .* Tor 0.* running on .* with Libevent .*, .*, Zlib .*, Liblzma N/A, Libzstd .* and .* .* as libc

View File

@ -1 +1 @@
Tor 0.* running on .* with Libevent .*, OpenSSL .*, Zlib .*, Liblzma .*, and Libzstd .* Tor 0.* running on .* with Libevent .*, OpenSSL .*, Zlib .*, Liblzma .*, Libzstd .* and .* .* as libc

View File

@ -1 +1 @@
Tor 0.* running on .* with Libevent .*, NSS .*, Zlib .*, Liblzma .*, and Libzstd .* Tor 0.* running on .* with Libevent .*, NSS .*, Zlib .*, Liblzma .*, Libzstd .* and .* .* as libc

View File

@ -202,7 +202,7 @@ STANDARD_LIBS="libevent\\|openssl\\|zlib"
# shellcheck disable=SC2018,SC2019 # shellcheck disable=SC2018,SC2019
TOR_LIBS_ENABLED="$("$TOR_BINARY" --verify-config \ TOR_LIBS_ENABLED="$("$TOR_BINARY" --verify-config \
-f "$EMPTY" --defaults-torrc "$EMPTY" \ -f "$EMPTY" --defaults-torrc "$EMPTY" \
| sed -n 's/.* Tor .* running on .* with\(.*\)\./\1/p' \ | sed -n 's/.* Tor .* running on .* with\(.*\) and .* .* as libc\./\1/p' \
| tr 'A-Z' 'a-z' | tr ',' '\n' \ | tr 'A-Z' 'a-z' | tr ',' '\n' \
| grep -v "$STANDARD_LIBS" | grep -v "n/a" \ | grep -v "$STANDARD_LIBS" | grep -v "n/a" \
| sed 's/\( and\)* \(lib\)*\([a-z0-9]*\) .*/\3/' \ | sed 's/\( and\)* \(lib\)*\([a-z0-9]*\) .*/\3/' \