diff options
author | teor <teor@torproject.org> | 2019-10-29 00:29:00 +1000 |
---|---|---|
committer | teor <teor@torproject.org> | 2019-10-31 12:34:19 +1000 |
commit | da49c4d78dee04aa493ebce2a60169034a48b464 (patch) | |
tree | cf18e994f360ce8dfc3b1bc43e99888e3b2d799a /src/feature/dirauth/dirauth_config.h | |
parent | 5950566f1de8f9b542e2ef862cc2ae94b04917f0 (diff) | |
download | tor-da49c4d78dee04aa493ebce2a60169034a48b464.tar.gz tor-da49c4d78dee04aa493ebce2a60169034a48b464.zip |
dirauth: Disable dirauth config when the module is disabled
Part of 32213.
Diffstat (limited to 'src/feature/dirauth/dirauth_config.h')
-rw-r--r-- | src/feature/dirauth/dirauth_config.h | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/src/feature/dirauth/dirauth_config.h b/src/feature/dirauth/dirauth_config.h index 21437ba248..95aef3de95 100644 --- a/src/feature/dirauth/dirauth_config.h +++ b/src/feature/dirauth/dirauth_config.h @@ -14,6 +14,8 @@ typedef struct or_options_t or_options_t; +#ifdef HAVE_MODULE_DIRAUTH + int options_validate_dirauth_mode(const or_options_t *old_options, or_options_t *options, char **msg); @@ -26,10 +28,46 @@ int options_validate_dirauth_testing(const or_options_t *old_options, or_options_t *options, 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); +#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) */ |