]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
introduce MinimalAcceptedServerVersion
authortrinity-1686a <trinity@deuxfleurs.fr>
Sat, 7 Oct 2023 15:35:57 +0000 (17:35 +0200)
committertrinity-1686a <trinity@deuxfleurs.fr>
Sat, 7 Oct 2023 15:35:57 +0000 (17:35 +0200)
src/feature/dirauth/dirauth_config.c
src/feature/dirauth/dirauth_options.inc
src/feature/dirauth/process_descs.c

index f98513ef756c1aadcb5b24fd630a91c5f1ab7e67..826b0431d76ab2ec398c74ffa4662328fbe1bd00 100644 (file)
@@ -19,6 +19,8 @@
 
 /* Required for dirinfo_type_t in or_options_t */
 #include "core/or/or.h"
+#include "core/or/tor_version_st.h"
+#include "core/or/versions.h"
 #include "app/config/config.h"
 #include "app/config/resolve_addr.h"
 
@@ -426,6 +428,7 @@ static int
 dirauth_options_validate(const void *arg, char **msg)
 {
   const dirauth_options_t *options = arg;
+  tor_version_t minimal_accepted_server_version, recommended_version;
 
   if (options->VersioningAuthoritativeDirectory &&
       (!options->RecommendedClientVersions ||
@@ -439,12 +442,41 @@ dirauth_options_validate(const void *arg, char **msg)
     REJECT("Guard bandwdith threshold fraction is invalid.");
   }
 
-  char *t;
+  char *recommended_versions;
   /* 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);
+  recommended_versions = format_recommended_version_list(
+      options->RecommendedClientVersions, 1);
+  tor_free(recommended_versions);
+
+  recommended_versions = format_recommended_version_list(
+      options->RecommendedServerVersions, 1);
+
+  if (tor_version_parse(options->MinimalAcceptedServerVersion,
+        &minimal_accepted_server_version) != 0) {
+    REJECT("Invalid MinimalAcceptedServerVersion");
+  }
+
+  smartlist_t *version_sl = smartlist_new();
+  smartlist_split_string(version_sl, recommended_versions, ",",
+      SPLIT_SKIP_SPACE, 0);
+  SMARTLIST_FOREACH_BEGIN(version_sl, const char *, version) {
+    if (tor_version_parse(version,
+          &recommended_version) != 0) {
+      COMPLAIN("Found unparseable version in RecommendedServerVersions");
+      continue;
+    }
+
+    if (tor_version_compare(&recommended_version,
+          &minimal_accepted_server_version) < 0) {
+      REJECT("MinimalAcceptedServerVersion wants to reject a recommended "
+          "version");
+      break;
+    }
+  } SMARTLIST_FOREACH_END(version);
+
+  SMARTLIST_FOREACH(version_sl, char *, version, tor_free(version));
+  smartlist_free(version_sl);
+  tor_free(recommended_versions);
 
   if (options->TestingAuthDirTimeToLearnReachability > 2*60*60) {
     COMPLAIN("TestingAuthDirTimeToLearnReachability is insanely high.");
index e2056c9cc7ad4a1409fc350c05abafb44775d5d7..9284c31a59f8483015ea3defd10b668791744cc0 100644 (file)
@@ -76,6 +76,9 @@ CONF_VAR(RecommendedClientVersions, LINELIST, 0, NULL)
 /** Which versions of tor should we tell users to run on relays? */
 CONF_VAR(RecommendedServerVersions, LINELIST, 0, NULL)
 
+/** Which minimal version of tor do we accept relay descriptors from? */
+CONF_VAR(MinimalAcceptedServerVersion, STRING, 0, "0.4.7.0-alpha-dev")
+
 /** Relays which should be voted Guard regardless of uptime and bandwidth. */
 CONF_VAR(AuthDirVoteGuard, ROUTERSET, 0, NULL)
 
index 7fd930e246e0f8da33b57f623554d192344aba56..95acb311736494d6fc12c0f538da7b67c0dc6c06 100644 (file)
@@ -404,8 +404,8 @@ dirserv_rejects_tor_version(const char *platform,
   static const char please_upgrade_string[] =
     "Tor version is insecure or unsupported. Please upgrade!";
 
-  /* Anything before 0.4.7.0 is unsupported. Reject them. */
-  if (!tor_version_as_new_as(platform,"0.4.7.0-alpha-dev")) {
+  if (!tor_version_as_new_as(platform,
+        dirauth_get_options()->MinimalAcceptedServerVersion)) {
     if (msg) {
       *msg = please_upgrade_string;
     }