Merge remote-tracking branch 'tor-github/pr/1487'

Combine V_IMMUTABLE and FILENAME changes on PidFile.
This commit is contained in:
teor 2019-11-05 14:26:23 +10:00
commit 655603c779
No known key found for this signature in database
GPG Key ID: 10FEAA0E7075672A
2 changed files with 21 additions and 22 deletions

View File

@ -0,0 +1,4 @@
o Code simplification and refactoring:
- Instead of keeping a list of configuration options to check for
relative paths, check all the options whose type is "FILENAME".
Solves part of ticket 32339.

View File

@ -386,7 +386,7 @@ static const config_var_t option_vars_[] = {
V(UnixSocksGroupWritable, BOOL, "0"), V(UnixSocksGroupWritable, BOOL, "0"),
V(CookieAuthentication, BOOL, "0"), V(CookieAuthentication, BOOL, "0"),
V(CookieAuthFileGroupReadable, BOOL, "0"), V(CookieAuthFileGroupReadable, BOOL, "0"),
V(CookieAuthFile, STRING, NULL), V(CookieAuthFile, FILENAME, NULL),
V(CountPrivateBandwidth, BOOL, "0"), V(CountPrivateBandwidth, BOOL, "0"),
VAR_IMMUTABLE("DataDirectory", FILENAME, DataDirectory_option, NULL), VAR_IMMUTABLE("DataDirectory", FILENAME, DataDirectory_option, NULL),
V(DataDirectoryGroupReadable, BOOL, "0"), V(DataDirectoryGroupReadable, BOOL, "0"),
@ -456,7 +456,7 @@ static const config_var_t option_vars_[] = {
V(ExtendAllowPrivateAddresses, BOOL, "0"), V(ExtendAllowPrivateAddresses, BOOL, "0"),
V(ExitRelay, AUTOBOOL, "auto"), V(ExitRelay, AUTOBOOL, "auto"),
VPORT(ExtORPort), VPORT(ExtORPort),
V(ExtORPortCookieAuthFile, STRING, NULL), V(ExtORPortCookieAuthFile, FILENAME, NULL),
V(ExtORPortCookieAuthFileGroupReadable, BOOL, "0"), V(ExtORPortCookieAuthFileGroupReadable, BOOL, "0"),
V(ExtraInfoStatistics, BOOL, "1"), V(ExtraInfoStatistics, BOOL, "1"),
V(ExtendByEd25519ID, AUTOBOOL, "auto"), V(ExtendByEd25519ID, AUTOBOOL, "auto"),
@ -594,7 +594,7 @@ static const config_var_t option_vars_[] = {
V(PathsNeededToBuildCircuits, DOUBLE, "-1"), V(PathsNeededToBuildCircuits, DOUBLE, "-1"),
V(PerConnBWBurst, MEMUNIT, "0"), V(PerConnBWBurst, MEMUNIT, "0"),
V(PerConnBWRate, MEMUNIT, "0"), V(PerConnBWRate, MEMUNIT, "0"),
V_IMMUTABLE(PidFile, STRING, NULL), V_IMMUTABLE(PidFile, FILENAME, NULL),
V_IMMUTABLE(TestingTorNetwork, BOOL, "0"), V_IMMUTABLE(TestingTorNetwork, BOOL, "0"),
V(TestingMinExitFlagThreshold, MEMUNIT, "0"), V(TestingMinExitFlagThreshold, MEMUNIT, "0"),
V(TestingMinFastFlagThreshold, MEMUNIT, "0"), V(TestingMinFastFlagThreshold, MEMUNIT, "0"),
@ -639,7 +639,7 @@ static const config_var_t option_vars_[] = {
V(ServerDNSAllowNonRFC953Hostnames, BOOL,"0"), V(ServerDNSAllowNonRFC953Hostnames, BOOL,"0"),
V(ServerDNSDetectHijacking, BOOL, "1"), V(ServerDNSDetectHijacking, BOOL, "1"),
V(ServerDNSRandomizeCase, BOOL, "1"), V(ServerDNSRandomizeCase, BOOL, "1"),
V(ServerDNSResolvConfFile, STRING, NULL), V(ServerDNSResolvConfFile, FILENAME, NULL),
V(ServerDNSSearchDomains, BOOL, "0"), V(ServerDNSSearchDomains, BOOL, "0"),
V(ServerDNSTestAddresses, CSV, V(ServerDNSTestAddresses, CSV,
"www.google.com,www.mit.edu,www.yahoo.com,www.slashdot.org"), "www.google.com,www.mit.edu,www.yahoo.com,www.slashdot.org"),
@ -3007,25 +3007,20 @@ warn_about_relative_paths(const or_options_t *options)
{ {
tor_assert(options); tor_assert(options);
int n = 0; int n = 0;
const config_mgr_t *mgr = get_options_mgr();
n += warn_if_option_path_is_relative("CookieAuthFile", smartlist_t *vars = config_mgr_list_vars(mgr);
options->CookieAuthFile); SMARTLIST_FOREACH_BEGIN(vars, const config_var_t *, cv) {
n += warn_if_option_path_is_relative("ExtORPortCookieAuthFile", config_line_t *line;
options->ExtORPortCookieAuthFile); if (cv->member.type != CONFIG_TYPE_FILENAME)
n += warn_if_option_path_is_relative("DirPortFrontPage", continue;
options->DirPortFrontPage); const char *name = cv->member.name;
n += warn_if_option_path_is_relative("V3BandwidthsFile", line = config_get_assigned_option(mgr, options, name, 0);
options->V3BandwidthsFile); if (line)
n += warn_if_option_path_is_relative("ControlPortWriteToFile", n += warn_if_option_path_is_relative(name, line->value);
options->ControlPortWriteToFile); config_free_lines(line);
n += warn_if_option_path_is_relative("GeoIPFile",options->GeoIPFile); } SMARTLIST_FOREACH_END(cv);
n += warn_if_option_path_is_relative("GeoIPv6File",options->GeoIPv6File); smartlist_free(vars);
n += warn_if_option_path_is_relative("Log",options->DebugLogFile);
n += warn_if_option_path_is_relative("AccelDir",options->AccelDir);
n += warn_if_option_path_is_relative("DataDirectory",options->DataDirectory);
n += warn_if_option_path_is_relative("PidFile",options->PidFile);
n += warn_if_option_path_is_relative("ClientOnionAuthDir",
options->ClientOnionAuthDir);
for (config_line_t *hs_line = options->RendConfigLines; hs_line; for (config_line_t *hs_line = options->RendConfigLines; hs_line;
hs_line = hs_line->next) { hs_line = hs_line->next) {