dirauth: Disable dirauth config when the module is disabled

Part of 32213.
This commit is contained in:
teor 2019-10-29 00:29:00 +10:00
parent 5950566f1d
commit da49c4d78d
11 changed files with 49 additions and 38 deletions

View File

@ -89,7 +89,6 @@ LIBTOR_APP_A_SOURCES = \
src/feature/control/control_proto.c \ src/feature/control/control_proto.c \
src/feature/control/fmt_serverstatus.c \ src/feature/control/fmt_serverstatus.c \
src/feature/control/getinfo_geoip.c \ src/feature/control/getinfo_geoip.c \
src/feature/dirauth/dirauth_config.c \
src/feature/dircache/conscache.c \ src/feature/dircache/conscache.c \
src/feature/dircache/consdiffmgr.c \ src/feature/dircache/consdiffmgr.c \
src/feature/dircache/dircache.c \ src/feature/dircache/dircache.c \
@ -180,6 +179,7 @@ MODULE_DIRAUTH_SOURCES = \
src/feature/dirauth/authmode.c \ src/feature/dirauth/authmode.c \
src/feature/dirauth/bridgeauth.c \ src/feature/dirauth/bridgeauth.c \
src/feature/dirauth/bwauth.c \ src/feature/dirauth/bwauth.c \
src/feature/dirauth/dirauth_config.c \
src/feature/dirauth/dirauth_periodic.c \ src/feature/dirauth/dirauth_periodic.c \
src/feature/dirauth/dirauth_sys.c \ src/feature/dirauth/dirauth_sys.c \
src/feature/dirauth/dircollate.c \ src/feature/dirauth/dircollate.c \

View File

@ -75,14 +75,12 @@ options_validate_dirauth_mode(const or_options_t *old_options,
REJECT("Versioning authoritative dir servers must set " REJECT("Versioning authoritative dir servers must set "
"Recommended*Versions."); "Recommended*Versions.");
#ifdef HAVE_MODULE_DIRAUTH
char *t; char *t;
/* Call these functions to produce warnings only. */ /* Call these functions to produce warnings only. */
t = format_recommended_version_list(options->RecommendedClientVersions, 1); t = format_recommended_version_list(options->RecommendedClientVersions, 1);
tor_free(t); tor_free(t);
t = format_recommended_version_list(options->RecommendedServerVersions, 1); t = format_recommended_version_list(options->RecommendedServerVersions, 1);
tor_free(t); tor_free(t);
#endif /* defined(HAVE_MODULE_DIRAUTH) */
if (options->UseEntryGuards) { if (options->UseEntryGuards) {
log_info(LD_CONFIG, "Authoritative directory servers can't set " log_info(LD_CONFIG, "Authoritative directory servers can't set "
@ -98,7 +96,7 @@ options_validate_dirauth_mode(const or_options_t *old_options,
options->V3AuthoritativeDir)) options->V3AuthoritativeDir))
REJECT("AuthoritativeDir is set, but none of " REJECT("AuthoritativeDir is set, but none of "
"(Bridge/V3)AuthoritativeDir is set."); "(Bridge/V3)AuthoritativeDir is set.");
#ifdef HAVE_MODULE_DIRAUTH
/* If we have a v3bandwidthsfile and it's broken, complain on startup */ /* If we have a v3bandwidthsfile and it's broken, complain on startup */
if (options->V3BandwidthsFile && !old_options) { if (options->V3BandwidthsFile && !old_options) {
dirserv_read_measured_bandwidths(options->V3BandwidthsFile, NULL, NULL, dirserv_read_measured_bandwidths(options->V3BandwidthsFile, NULL, NULL,
@ -108,9 +106,6 @@ options_validate_dirauth_mode(const or_options_t *old_options,
if (options->GuardfractionFile && !old_options) { if (options->GuardfractionFile && !old_options) {
dirserv_read_guardfraction_file(options->GuardfractionFile, NULL); dirserv_read_guardfraction_file(options->GuardfractionFile, NULL);
} }
#else
(void)old_options;
#endif /* defined(HAVE_MODULE_DIRAUTH) */
} }
if (options->AuthoritativeDir && !options->DirPort_set) if (options->AuthoritativeDir && !options->DirPort_set)
@ -283,7 +278,7 @@ options_validate_dirauth_testing(const or_options_t *old_options,
* Return true if changing the configuration from <b>old</b> to <b>new</b> * Return true if changing the configuration from <b>old</b> to <b>new</b>
* affects the timing of the voting subsystem * affects the timing of the voting subsystem
*/ */
int static int
options_transition_affects_dirauth_timing(const or_options_t *old_options, options_transition_affects_dirauth_timing(const or_options_t *old_options,
const or_options_t *new_options) const or_options_t *new_options)
{ {

View File

@ -14,6 +14,8 @@
typedef struct or_options_t or_options_t; typedef struct or_options_t or_options_t;
#ifdef HAVE_MODULE_DIRAUTH
int options_validate_dirauth_mode(const or_options_t *old_options, int options_validate_dirauth_mode(const or_options_t *old_options,
or_options_t *options, or_options_t *options,
char **msg); char **msg);
@ -26,10 +28,46 @@ int options_validate_dirauth_testing(const or_options_t *old_options,
or_options_t *options, or_options_t *options,
char **msg); char **msg);
int options_transition_affects_dirauth_timing(
const or_options_t *old_options,
const or_options_t *new_options);
int options_act_dirauth(const or_options_t *old_options); int options_act_dirauth(const or_options_t *old_options);
#else
/** When tor is compiled with the dirauth module disabled, it can't be
* configured as a directory authority.
*
* Returns -1 and sets msg to a newly allocated string, if AuthoritativeDir
* is set in options. Otherwise returns 0. */
static inline int
options_validate_dirauth_mode(const or_options_t *old_options,
or_options_t *options,
char **msg)
{
(void)old_options;
/* Only check the primary option for now, #29211 will disable more
* options. */
if (options->AuthoritativeDir) {
/* REJECT() this configuration */
*msg = tor_strdup("This tor was built with dirauth mode disabled. "
"It can not be configured with AuthoritativeDir 1.");
return -1;
}
return 0;
}
#define options_validate_dirauth_schedule(old_options, options, msg) \
(((void)(old_options)),((void)(options)),((void)(msg)),0)
#define options_validate_dirauth_testing(old_options, options, msg) \
(((void)(old_options)),((void)(options)),((void)(msg)),0)
#define options_validate_dirauth_testing(old_options, options, msg) \
(((void)(old_options)),((void)(options)),((void)(msg)),0)
#define options_act_dirauth(old_options) \
(((void)(old_options)),0)
#endif /* defined(HAVE_MODULE_DIRAUTH) */
#endif /* !defined(TOR_FEATURE_DIRAUTH_DIRAUTH_CONFIG_H) */ #endif /* !defined(TOR_FEATURE_DIRAUTH_DIRAUTH_CONFIG_H) */

View File

@ -0,0 +1 @@
This tor was built with dirauth mode disabled.

View File

@ -0,0 +1 @@
This tor was built with dirauth mode disabled.

View File

@ -1,7 +0,0 @@
Address 198.51.100.123
AuthoritativeDirectory 1
BridgeAuthoritativeDir 1
ContactInfo tor_parse_test@example.com
DirPort 80
Nickname Unnamed
ORPort 443

View File

@ -1,6 +0,0 @@
Address 198.51.100.123
AuthoritativeDirectory 1
BridgeAuthoritativeDir 1
ContactInfo tor_parse_test@example.com
DirPort 80
ORPort 443

View File

@ -0,0 +1 @@
This tor was built with dirauth mode disabled.

View File

@ -0,0 +1 @@
This tor was built with dirauth mode disabled.

View File

@ -1,7 +0,0 @@
Address 192.0.2.1
AuthoritativeDirectory 1
ContactInfo tor_parse_test@example.net
DirPort 9030
Nickname Unnamed
ORPort 9001
V3AuthoritativeDirectory 1

View File

@ -1,6 +0,0 @@
Address 192.0.2.1
AuthoritativeDirectory 1
ContactInfo tor_parse_test@example.net
DirPort 9030
ORPort 9001
V3AuthoritativeDirectory 1