[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Add an option to disable signal handler installation.
commit 20f802ea3cd5d8b3993a101da03dfec95bc9049e
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Fri Dec 15 12:48:29 2017 -0500
Add an option to disable signal handler installation.
Closes ticket 24588.
---
changes/ticket24588 | 5 +++++
src/or/config.c | 7 +++++++
src/or/main.c | 4 +++-
src/or/or.h | 5 +++++
4 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/changes/ticket24588 b/changes/ticket24588
new file mode 100644
index 000000000..e64872d74
--- /dev/null
+++ b/changes/ticket24588
@@ -0,0 +1,5 @@
+ o Minor features (embedding, mobile):
+ - Applications that want to embed Tor can now tell Tor not to register
+ any of its own POSIX signal handlers, using the __DisableSignalHandlers
+ option. This option is not meant for general use. Closes ticket 24588.
+
diff --git a/src/or/config.c b/src/or/config.c
index 016d87f81..ebbe726c7 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -564,6 +564,7 @@ static config_var_t option_vars_[] = {
VAR("__ReloadTorrcOnSIGHUP", BOOL, ReloadTorrcOnSIGHUP, "1"),
VAR("__AllDirActionsPrivate", BOOL, AllDirActionsPrivate, "0"),
VAR("__DisablePredictedCircuits",BOOL,DisablePredictedCircuits, "0"),
+ VAR("__DisableSignalHandlers", BOOL, DisableSignalHandlers, "0"),
VAR("__LeaveStreamsUnattached",BOOL, LeaveStreamsUnattached, "0"),
VAR("__HashedControlSessionPassword", LINELIST, HashedControlSessionPassword,
NULL),
@@ -4652,6 +4653,12 @@ options_transition_allowed(const or_options_t *old,
return -1;
}
+ if (old->DisableSignalHandlers != new_val->DisableSignalHandlers) {
+ *msg = tor_strdup("While Tor is running, changing DisableSignalHandlers "
+ "is not allowed.");
+ return -1;
+ }
+
if (strcmp(old->DataDirectory,new_val->DataDirectory)!=0) {
tor_asprintf(msg,
"While Tor is running, changing DataDirectory "
diff --git a/src/or/main.c b/src/or/main.c
index 38f25cae5..9adad0794 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -3057,8 +3057,10 @@ void
handle_signals(void)
{
int i;
+ const int enabled = !get_options()->DisableSignalHandlers;
+
for (i = 0; signal_handlers[i].signal_value >= 0; ++i) {
- if (signal_handlers[i].try_to_register) {
+ if (enabled && signal_handlers[i].try_to_register) {
signal_handlers[i].signal_event =
tor_evsignal_new(tor_libevent_get_base(),
signal_handlers[i].signal_value,
diff --git a/src/or/or.h b/src/or/or.h
index 9c5394987..91d643638 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -4651,6 +4651,11 @@ typedef struct {
/** List of files that were opened by %include in torrc and torrc-defaults */
smartlist_t *FilesOpenedByIncludes;
+
+ /** If true, Tor shouldn't install any posix signal handlers, since it is
+ * running embedded inside another process.
+ */
+ int DisableSignalHandlers;
} or_options_t;
#define LOG_PROTOCOL_WARN (get_protocol_warning_severity_level())
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits