mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
trace: Emit a warning if tracing is built in
Built in tracing should _not_ be run if it was not set on purpose. Warn as loud as we can in order to inform the user that they are running a version with tracing capabilities built in. This commit also adds a subsys stub because utlimately the logging will happen in the init phase but because the default log file is not set in the sys_logging init function, the stub is not useful for now. Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
parent
3604d86a01
commit
b049cc3ace
@ -273,9 +273,9 @@ if test "x$enable_tracing_instrumentation_lttng" = "xyes"; then
|
|||||||
On Debian, apt install liblttng-ust-dev"])], [])
|
On Debian, apt install liblttng-ust-dev"])], [])
|
||||||
AC_DEFINE([USE_TRACING_INSTRUMENTATION_LTTNG], [1], [Using LTTng instrumentation])
|
AC_DEFINE([USE_TRACING_INSTRUMENTATION_LTTNG], [1], [Using LTTng instrumentation])
|
||||||
TOR_TRACE_LIBS="-llttng-ust -ldl"
|
TOR_TRACE_LIBS="-llttng-ust -ldl"
|
||||||
|
have_tracing=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
dnl USDT instrumentation option.
|
dnl USDT instrumentation option.
|
||||||
AC_ARG_ENABLE(tracing-instrumentation-usdt,
|
AC_ARG_ENABLE(tracing-instrumentation-usdt,
|
||||||
AS_HELP_STRING([--enable-tracing-instrumentation-usdt],
|
AS_HELP_STRING([--enable-tracing-instrumentation-usdt],
|
||||||
@ -291,6 +291,7 @@ if test "x$enable_tracing_instrumentation_usdt" = "xyes"; then
|
|||||||
dnl --with-sdt. There is unfortunately no way to check that so we always
|
dnl --with-sdt. There is unfortunately no way to check that so we always
|
||||||
dnl build the USDT probes even though LTTng instrumentation was requested.
|
dnl build the USDT probes even though LTTng instrumentation was requested.
|
||||||
AC_DEFINE([USE_TRACING_INSTRUMENTATION_USDT], [1], [Using USDT instrumentation])
|
AC_DEFINE([USE_TRACING_INSTRUMENTATION_USDT], [1], [Using USDT instrumentation])
|
||||||
|
have_tracing=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
dnl Tracepoints event to debug logs.
|
dnl Tracepoints event to debug logs.
|
||||||
@ -301,6 +302,9 @@ AC_ARG_ENABLE(tracing-instrumentation-log-debug,
|
|||||||
[Tracepoints to log debug]), [])
|
[Tracepoints to log debug]), [])
|
||||||
AM_CONDITIONAL([USE_TRACING_INSTRUMENTATION_LOG_DEBUG],
|
AM_CONDITIONAL([USE_TRACING_INSTRUMENTATION_LOG_DEBUG],
|
||||||
[test "x$enable_tracing_instrumentation_log_debug" = "xyes"])
|
[test "x$enable_tracing_instrumentation_log_debug" = "xyes"])
|
||||||
|
if test "x$enable_tracing_instrumentation_log_debug" = "xyes"; then
|
||||||
|
have_tracing=1
|
||||||
|
fi
|
||||||
|
|
||||||
dnl Define that tracing is supported if any instrumentation is used.
|
dnl Define that tracing is supported if any instrumentation is used.
|
||||||
AM_COND_IF([USE_TRACING_INSTRUMENTATION_LOG_DEBUG],
|
AM_COND_IF([USE_TRACING_INSTRUMENTATION_LOG_DEBUG],
|
||||||
@ -309,6 +313,7 @@ AM_COND_IF([USE_TRACING_INSTRUMENTATION_USDT],
|
|||||||
AC_DEFINE([HAVE_TRACING], [1], [Compiled with tracing support]))
|
AC_DEFINE([HAVE_TRACING], [1], [Compiled with tracing support]))
|
||||||
AM_COND_IF([USE_TRACING_INSTRUMENTATION_LTTNG],
|
AM_COND_IF([USE_TRACING_INSTRUMENTATION_LTTNG],
|
||||||
AC_DEFINE([HAVE_TRACING], [1], [Compiled with tracing support]))
|
AC_DEFINE([HAVE_TRACING], [1], [Compiled with tracing support]))
|
||||||
|
AM_CONDITIONAL([USE_TRACING], [test "x$have_tracing" = x1 ])
|
||||||
|
|
||||||
dnl Finally, define the trace libs.
|
dnl Finally, define the trace libs.
|
||||||
AC_SUBST([TOR_TRACE_LIBS])
|
AC_SUBST([TOR_TRACE_LIBS])
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
#include "lib/crypt_ops/crypto_rand.h"
|
#include "lib/crypt_ops/crypto_rand.h"
|
||||||
#include "lib/crypt_ops/crypto_s2k.h"
|
#include "lib/crypt_ops/crypto_s2k.h"
|
||||||
#include "lib/net/resolve.h"
|
#include "lib/net/resolve.h"
|
||||||
|
#include "lib/trace/trace.h"
|
||||||
|
|
||||||
#include "lib/process/waitpid.h"
|
#include "lib/process/waitpid.h"
|
||||||
#include "lib/pubsub/pubsub_build.h"
|
#include "lib/pubsub/pubsub_build.h"
|
||||||
@ -602,6 +603,9 @@ tor_init(int argc, char *argv[])
|
|||||||
rust_log_welcome_string();
|
rust_log_welcome_string();
|
||||||
#endif /* defined(HAVE_RUST) */
|
#endif /* defined(HAVE_RUST) */
|
||||||
|
|
||||||
|
/* Warn _if_ the tracing subsystem is built in. */
|
||||||
|
tracing_log_warning();
|
||||||
|
|
||||||
int init_rv = options_init_from_torrc(argc,argv);
|
int init_rv = options_init_from_torrc(argc,argv);
|
||||||
if (init_rv < 0) {
|
if (init_rv < 0) {
|
||||||
log_err(LD_CONFIG,"Reading config failed--see warnings above.");
|
log_err(LD_CONFIG,"Reading config failed--see warnings above.");
|
||||||
|
@ -26,6 +26,10 @@ if USE_TRACING_INSTRUMENTATION_LTTNG
|
|||||||
include src/lib/trace/lttng/include.am
|
include src/lib/trace/lttng/include.am
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
if USE_TRACING
|
||||||
src_lib_libtor_trace_a_SOURCES = $(LIBTOR_TRACE_A_SOURCES)
|
src_lib_libtor_trace_a_SOURCES = $(LIBTOR_TRACE_A_SOURCES)
|
||||||
|
else
|
||||||
|
src_lib_libtor_trace_a_SOURCES = src/lib/trace/trace_stub.c
|
||||||
|
endif
|
||||||
|
|
||||||
noinst_HEADERS+= $(TRACEHEADERS)
|
noinst_HEADERS+= $(TRACEHEADERS)
|
||||||
|
@ -9,7 +9,28 @@
|
|||||||
#ifndef TOR_LIB_TRACE_TRACE_H
|
#ifndef TOR_LIB_TRACE_TRACE_H
|
||||||
#define TOR_LIB_TRACE_TRACE_H
|
#define TOR_LIB_TRACE_TRACE_H
|
||||||
|
|
||||||
|
#include "orconfig.h"
|
||||||
|
|
||||||
void tor_trace_init(void);
|
void tor_trace_init(void);
|
||||||
void tor_trace_free_all(void);
|
void tor_trace_free_all(void);
|
||||||
|
|
||||||
|
#ifdef HAVE_TRACING
|
||||||
|
|
||||||
|
#include "lib/log/log.h"
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
tracing_log_warning(void)
|
||||||
|
{
|
||||||
|
log_warn(LD_GENERAL,
|
||||||
|
"Tracing capabilities have been built in. If this is NOT on "
|
||||||
|
"purpose, your tor is NOT safe to run.");
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* NOP it. */
|
||||||
|
#define tracing_log_warning()
|
||||||
|
|
||||||
|
#endif /* defined(HAVE_TRACING) */
|
||||||
|
|
||||||
#endif /* !defined(TOR_LIB_TRACE_TRACE_H) */
|
#endif /* !defined(TOR_LIB_TRACE_TRACE_H) */
|
||||||
|
19
src/lib/trace/trace_stub.c
Normal file
19
src/lib/trace/trace_stub.c
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/* Copyright (c) 2020, The Tor Project, Inc. */
|
||||||
|
/* See LICENSE for licensing information */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file trace_stub.c
|
||||||
|
* \brief Stub declaratinos for use when trace library is disabled.
|
||||||
|
**/
|
||||||
|
|
||||||
|
#include "lib/subsys/subsys.h"
|
||||||
|
|
||||||
|
#include "lib/trace/trace_sys.h"
|
||||||
|
|
||||||
|
const subsys_fns_t sys_tracing = {
|
||||||
|
SUBSYS_DECLARE_LOCATION(),
|
||||||
|
|
||||||
|
.name = "tracing",
|
||||||
|
.supported = false,
|
||||||
|
.level = TRACE_SUBSYS_LEVEL,
|
||||||
|
};
|
@ -25,9 +25,12 @@ subsys_tracing_shutdown(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
const subsys_fns_t sys_tracing = {
|
const subsys_fns_t sys_tracing = {
|
||||||
|
SUBSYS_DECLARE_LOCATION(),
|
||||||
|
|
||||||
.name = "tracing",
|
.name = "tracing",
|
||||||
.supported = true,
|
.supported = true,
|
||||||
.level = -85,
|
.level = TRACE_SUBSYS_LEVEL,
|
||||||
|
|
||||||
.initialize = subsys_tracing_initialize,
|
.initialize = subsys_tracing_initialize,
|
||||||
.shutdown = subsys_tracing_shutdown,
|
.shutdown = subsys_tracing_shutdown,
|
||||||
};
|
};
|
||||||
|
@ -11,4 +11,12 @@
|
|||||||
|
|
||||||
extern const struct subsys_fns_t sys_tracing;
|
extern const struct subsys_fns_t sys_tracing;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subsystem level for the tracing system.
|
||||||
|
*
|
||||||
|
* Defined here so that it can be shared between the real and stub
|
||||||
|
* definitions.
|
||||||
|
**/
|
||||||
|
#define TRACE_SUBSYS_LEVEL (-85)
|
||||||
|
|
||||||
#endif /* !defined(TOR_TRACE_SYS_H) */
|
#endif /* !defined(TOR_TRACE_SYS_H) */
|
||||||
|
Loading…
Reference in New Issue
Block a user