Commit 53d3f812 authored by Nick Mathewson's avatar Nick Mathewson 🎨
Browse files

Add new internal-use-only option for controllers to use to prevent SIGHUP from...

Add new internal-use-only option for controllers to use to prevent SIGHUP from reloading the configuration.  Fixes bug 856.

svn:r17567
parent 9aa706e2
...@@ -19,6 +19,8 @@ Changes in version 0.2.1.9-alpha - 200?-??-?? ...@@ -19,6 +19,8 @@ Changes in version 0.2.1.9-alpha - 200?-??-??
- When we realize that another process has modified our cached - When we realize that another process has modified our cached
descriptors, print out a more useful error message rather than descriptors, print out a more useful error message rather than
triggering an assertion. Fixes bug 885. Patch from Karsten. triggering an assertion. Fixes bug 885. Patch from Karsten.
- Add an internal-use-only __ReloadTorrcOnSIGHUP option for controllers
to prevent SIGHUP from reloading the configuration. Fixes bug 856.
o Minor bugfixes: o Minor bugfixes:
- Resume using the correct "REASON=" stream when telling the - Resume using the correct "REASON=" stream when telling the
......
...@@ -1650,6 +1650,16 @@ $Id$ ...@@ -1650,6 +1650,16 @@ $Id$
As HashedControlPassword, but is not saved to the torrc file by As HashedControlPassword, but is not saved to the torrc file by
SAVECONF. Added in Tor 0.2.0.20-rc. SAVECONF. Added in Tor 0.2.0.20-rc.
__ReloadTorrcOnSIGHUP
If this option is true (the default), we reload the torrc from disk
every time we get a SIGHUP (from the controller or via a signal).
Otherwise, we don't. This option exists so that controllers can keep
their options from getting overwritten when a user sends Tor a HUP for
some other reason (for example, to rotate the logs).
(Boolean. Default: "1")
5.5. Phases from the Bootstrap status event. 5.5. Phases from the Bootstrap status event.
This section describes the various bootstrap phases currently reported This section describes the various bootstrap phases currently reported
......
...@@ -333,6 +333,7 @@ static config_var_t _option_vars[] = { ...@@ -333,6 +333,7 @@ static config_var_t _option_vars[] = {
VAR("VersioningAuthoritativeDirectory",BOOL,VersioningAuthoritativeDir, "0"), VAR("VersioningAuthoritativeDirectory",BOOL,VersioningAuthoritativeDir, "0"),
V(VirtualAddrNetwork, STRING, "127.192.0.0/10"), V(VirtualAddrNetwork, STRING, "127.192.0.0/10"),
V(WarnPlaintextPorts, CSV, "23,109,110,143"), V(WarnPlaintextPorts, CSV, "23,109,110,143"),
VAR("__ReloadTorrcOnSIGHUP", BOOL, ReloadTorrcOnSIGHUP, "1"),
VAR("__AllDirActionsPrivate", BOOL, AllDirActionsPrivate, "0"), VAR("__AllDirActionsPrivate", BOOL, AllDirActionsPrivate, "0"),
VAR("__DisablePredictedCircuits",BOOL,DisablePredictedCircuits, "0"), VAR("__DisablePredictedCircuits",BOOL,DisablePredictedCircuits, "0"),
VAR("__LeaveStreamsUnattached",BOOL, LeaveStreamsUnattached, "0"), VAR("__LeaveStreamsUnattached",BOOL, LeaveStreamsUnattached, "0"),
......
...@@ -1321,7 +1321,8 @@ do_hup(void) ...@@ -1321,7 +1321,8 @@ do_hup(void)
dmalloc_log_changed(0, 1, 0, 0); dmalloc_log_changed(0, 1, 0, 0);
#endif #endif
log_notice(LD_GENERAL,"Received reload signal (hup). Reloading config."); log_notice(LD_GENERAL,"Received reload signal (hup). Reloading config and "
"resetting internal state.");
if (accounting_is_enabled(options)) if (accounting_is_enabled(options))
accounting_record_bandwidth_usage(time(NULL), get_or_state()); accounting_record_bandwidth_usage(time(NULL), get_or_state());
...@@ -1329,13 +1330,18 @@ do_hup(void) ...@@ -1329,13 +1330,18 @@ do_hup(void)
routerlist_reset_warnings(); routerlist_reset_warnings();
addressmap_clear_transient(); addressmap_clear_transient();
/* first, reload config variables, in case they've changed */ /* first, reload config variables, in case they've changed */
/* no need to provide argc/v, they've been cached inside init_from_config */ if (options->ReloadTorrcOnSIGHUP) {
if (options_init_from_torrc(0, NULL) < 0) { /* no need to provide argc/v, they've been cached inside init_from_config */
log_err(LD_CONFIG,"Reading config failed--see warnings above. " if (options_init_from_torrc(0, NULL) < 0) {
"For usage, try -h."); log_err(LD_CONFIG,"Reading config failed--see warnings above. "
return -1; "For usage, try -h.");
return -1;
}
options = get_options(); /* they have changed now */
} else {
log_notice(LD_GENERAL, "Not reloading config file: the controller told "
"us not to.");
} }
options = get_options(); /* they have changed now */
if (authdir_mode_handles_descs(options, -1)) { if (authdir_mode_handles_descs(options, -1)) {
/* reload the approved-routers file */ /* reload the approved-routers file */
if (dirserv_load_fingerprint_file() < 0) { if (dirserv_load_fingerprint_file() < 0) {
......
...@@ -2496,6 +2496,10 @@ typedef struct { ...@@ -2496,6 +2496,10 @@ typedef struct {
/** Optionally, a file with GeoIP data. */ /** Optionally, a file with GeoIP data. */
char *GeoIPFile; char *GeoIPFile;
/** If true, SIGHUP should reload the torrc. Sometimes controllers want
* to make this false. */
int ReloadTorrcOnSIGHUP;
} or_options_t; } or_options_t;
/** Persistent state for an onion router, as saved to disk. */ /** Persistent state for an onion router, as saved to disk. */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment