From 3dd738d5f943a188eb91d6753e055cb44c9c3cdb Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 18 Jan 2017 10:07:55 -0500 Subject: [PATCH 1/3] Simplify the VPORT() macro in config.c It's always called with the same arguments, and there wouldn't be much point to calling it differently. --- src/or/config.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/or/config.c b/src/or/config.c index 3693cdf83c..3b70b979f7 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -133,8 +133,8 @@ static config_abbrev_t option_abbrevs_[] = { /** An entry for config_vars: "The option name is obsolete." */ #define OBSOLETE(name) { name, CONFIG_TYPE_OBSOLETE, 0, NULL } -#define VPORT(member,conftype,initvalue) \ - VAR(#member, conftype, member ## _lines, initvalue) +#define VPORT(member) \ + VAR(#member, LINELIST, member ## _lines, NULL) /** Array of configuration options. Until we disallow nonstandard * abbreviations, order is significant, since the first matching option will @@ -203,7 +203,7 @@ static config_var_t option_vars_[] = { V(ConstrainedSockSize, MEMUNIT, "8192"), V(ContactInfo, STRING, NULL), V(ControlListenAddress, LINELIST, NULL), - VPORT(ControlPort, LINELIST, NULL), + VPORT(ControlPort), V(ControlPortFileGroupReadable,BOOL, "0"), V(ControlPortWriteToFile, FILENAME, NULL), V(ControlSocket, LINELIST, NULL), @@ -221,7 +221,7 @@ static config_var_t option_vars_[] = { V(TestingAuthDirTimeToLearnReachability, INTERVAL, "30 minutes"), V(DirListenAddress, LINELIST, NULL), V(DirPolicy, LINELIST, NULL), - VPORT(DirPort, LINELIST, NULL), + VPORT(DirPort), V(DirPortFrontPage, FILENAME, NULL), VAR("DirReqStatistics", BOOL, DirReqStatistics_option, "1"), VAR("DirAuthority", LINELIST, DirAuthorities, NULL), @@ -232,7 +232,7 @@ static config_var_t option_vars_[] = { OBSOLETE("DisableIOCP"), OBSOLETE("DisableV2DirectoryInfo_"), OBSOLETE("DynamicDHGroups"), - VPORT(DNSPort, LINELIST, NULL), + VPORT(DNSPort), V(DNSListenAddress, LINELIST, NULL), V(DownloadExtraInfo, BOOL, "0"), V(TestingEnableConnBwEvent, BOOL, "0"), @@ -252,7 +252,7 @@ static config_var_t option_vars_[] = { V(ExitPortStatistics, BOOL, "0"), V(ExtendAllowPrivateAddresses, BOOL, "0"), V(ExitRelay, AUTOBOOL, "auto"), - VPORT(ExtORPort, LINELIST, NULL), + VPORT(ExtORPort), V(ExtORPortCookieAuthFile, STRING, NULL), V(ExtORPortCookieAuthFileGroupReadable, BOOL, "0"), V(ExtraInfoStatistics, BOOL, "1"), @@ -338,7 +338,7 @@ static config_var_t option_vars_[] = { V(NewCircuitPeriod, INTERVAL, "30 seconds"), OBSOLETE("NamingAuthoritativeDirectory"), V(NATDListenAddress, LINELIST, NULL), - VPORT(NATDPort, LINELIST, NULL), + VPORT(NATDPort), V(Nickname, STRING, NULL), V(PredictedPortsRelevanceTime, INTERVAL, "1 hour"), V(WarnUnsafeSocks, BOOL, "1"), @@ -348,7 +348,7 @@ static config_var_t option_vars_[] = { V(NumEntryGuards, UINT, "0"), V(OfflineMasterKey, BOOL, "0"), V(ORListenAddress, LINELIST, NULL), - VPORT(ORPort, LINELIST, NULL), + VPORT(ORPort), V(OutboundBindAddress, LINELIST, NULL), OBSOLETE("PathBiasDisableRate"), @@ -420,7 +420,7 @@ static config_var_t option_vars_[] = { V(ShutdownWaitLength, INTERVAL, "30 seconds"), V(SocksListenAddress, LINELIST, NULL), V(SocksPolicy, LINELIST, NULL), - VPORT(SocksPort, LINELIST, NULL), + VPORT(SocksPort), V(SocksTimeout, INTERVAL, "2 minutes"), V(SSLKeyLifetime, INTERVAL, "0"), OBSOLETE("StrictEntryNodes"), @@ -435,7 +435,7 @@ static config_var_t option_vars_[] = { V(TrackHostExits, CSV, NULL), V(TrackHostExitsExpire, INTERVAL, "30 minutes"), V(TransListenAddress, LINELIST, NULL), - VPORT(TransPort, LINELIST, NULL), + VPORT(TransPort), V(TransProxyType, STRING, "default"), OBSOLETE("TunnelDirConns"), V(UpdateBridgesFromAuthority, BOOL, "0"), From 9469aaaa82b353655c8e17f654954231ba3b09c8 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 18 Jan 2017 10:24:37 -0500 Subject: [PATCH 2/3] Handle __NonSavedOptions correctly inside LINELIST_V blocks. --- src/or/confparse.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/or/confparse.c b/src/or/confparse.c index efcf4f981e..2d6cc7ac62 100644 --- a/src/or/confparse.c +++ b/src/or/confparse.c @@ -1148,6 +1148,11 @@ config_dump(const config_format_t *fmt, const void *default_options, config_get_assigned_option(fmt, options, fmt->vars[i].name, 1); for (; line; line = line->next) { + if (!strcmpstart(line->key, "__")) { + /* This check detects "hidden" variables inside LINELIST_V structures. + */ + continue; + } smartlist_add_asprintf(elements, "%s%s %s\n", comment_option ? "# " : "", line->key, line->value); From 83307fc267e7de5fd3a9ccc0c51d6d377f454495 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 18 Jan 2017 10:21:33 -0500 Subject: [PATCH 3/3] Add __SocksPort etc variants for non-persistent use Implements feature 20956. --- changes/feature20956 | 6 ++++++ doc/tor.1.txt | 13 +++++++++++++ src/or/config.c | 13 +++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 changes/feature20956 diff --git a/changes/feature20956 b/changes/feature20956 new file mode 100644 index 0000000000..1ebddb1662 --- /dev/null +++ b/changes/feature20956 @@ -0,0 +1,6 @@ + o Minor features (configuration, controller): + - Each of the *Port options, such as SocksPort, ORPort, ControlPort, + and so on, now comes with a __*Port variant that will not be + saved to the torrc file by the controller's SAVECONF command. + This change allows TorBrowser to set up a single-use domain socket + for each time it launches Tor. Closes ticket 20956. diff --git a/doc/tor.1.txt b/doc/tor.1.txt index f1068cedc6..330cdd4492 100644 --- a/doc/tor.1.txt +++ b/doc/tor.1.txt @@ -2668,6 +2668,19 @@ The following options are used for running a testing Tor network. we replace it and issue a new key? (Default: 3 hours for link and auth; 1 day for signing.) +NON-PERSISTENT OPTIONS +---------------------- + +These options are not saved to the torrc file by the "SAVECONF" controller +command. Other options of this type are documented in control-spec.txt, +section 5.4. End-users should mostly ignore them. + +[[UnderscorePorts]] **\_\_ControlPort**, **\_\_DirPort**, **\_\_DNSPort**, **\_\_ExtORPort**, **\_\_NATDPort**, **\_\_ORPort**, **\_\_SocksPort**, **\_\_TransPort**:: + These underscore-prefixed options are variants of the regular Port + options. They behave the same, except they are not saved to the + torrc file by the controller's SAVECONF command. + + SIGNALS ------- diff --git a/src/or/config.c b/src/or/config.c index 3b70b979f7..fe6aa786e7 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -133,8 +133,17 @@ static config_abbrev_t option_abbrevs_[] = { /** An entry for config_vars: "The option name is obsolete." */ #define OBSOLETE(name) { name, CONFIG_TYPE_OBSOLETE, 0, NULL } -#define VPORT(member) \ - VAR(#member, LINELIST, member ## _lines, NULL) +/** + * Macro to declare *Port options. Each one comes in three entries. + * For example, most users should use "SocksPort" to configure the + * socks port, but TorBrowser wants to use __SocksPort so that it + * isn't stored by SAVECONF. The SocksPortLines virtual option is + * used to query both options from the controller. + */ +#define VPORT(member) \ + VAR(#member "Lines", LINELIST_V, member ## _lines, NULL), \ + VAR(#member, LINELIST_S, member ## _lines, NULL), \ + VAR("__" #member, LINELIST_S, member ## _lines, NULL) /** Array of configuration options. Until we disallow nonstandard * abbreviations, order is significant, since the first matching option will