Commit da49c4d7 authored by teor's avatar teor
Browse files

dirauth: Disable dirauth config when the module is disabled

Part of 32213.
parent 5950566f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -89,7 +89,6 @@ LIBTOR_APP_A_SOURCES = \
	src/feature/control/control_proto.c	\
	src/feature/control/fmt_serverstatus.c  \
	src/feature/control/getinfo_geoip.c	\
	src/feature/dirauth/dirauth_config.c	\
	src/feature/dircache/conscache.c	\
	src/feature/dircache/consdiffmgr.c	\
	src/feature/dircache/dircache.c		\
@@ -180,6 +179,7 @@ MODULE_DIRAUTH_SOURCES = \
	src/feature/dirauth/authmode.c				\
	src/feature/dirauth/bridgeauth.c			\
	src/feature/dirauth/bwauth.c				\
	src/feature/dirauth/dirauth_config.c			\
	src/feature/dirauth/dirauth_periodic.c			\
	src/feature/dirauth/dirauth_sys.c			\
	src/feature/dirauth/dircollate.c			\
+2 −7
Original line number Diff line number Diff line
@@ -75,14 +75,12 @@ options_validate_dirauth_mode(const or_options_t *old_options,
      REJECT("Versioning authoritative dir servers must set "
             "Recommended*Versions.");

#ifdef HAVE_MODULE_DIRAUTH
    char *t;
    /* Call these functions to produce warnings only. */
    t = format_recommended_version_list(options->RecommendedClientVersions, 1);
    tor_free(t);
    t = format_recommended_version_list(options->RecommendedServerVersions, 1);
    tor_free(t);
#endif /* defined(HAVE_MODULE_DIRAUTH) */

    if (options->UseEntryGuards) {
      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))
      REJECT("AuthoritativeDir is set, but none of "
             "(Bridge/V3)AuthoritativeDir is set.");
#ifdef HAVE_MODULE_DIRAUTH

    /* If we have a v3bandwidthsfile and it's broken, complain on startup */
    if (options->V3BandwidthsFile && !old_options) {
      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) {
      dirserv_read_guardfraction_file(options->GuardfractionFile, NULL);
    }
#else
    (void)old_options;
#endif /* defined(HAVE_MODULE_DIRAUTH) */
  }

  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>
 * affects the timing of the voting subsystem
 */
int
static int
options_transition_affects_dirauth_timing(const or_options_t *old_options,
                                          const or_options_t *new_options)
{
+42 −4
Original line number Diff line number Diff line
@@ -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) */
+1 −0
Original line number Diff line number Diff line
This tor was built with dirauth mode disabled.
+1 −0
Original line number Diff line number Diff line
This tor was built with dirauth mode disabled.
Loading