introduce MinimalAcceptedServerVersion

This commit is contained in:
trinity-1686a 2023-10-07 17:35:57 +02:00
parent f9378eb5fa
commit 6dfb48894f
No known key found for this signature in database
GPG Key ID: 7F9D324B2661C978
3 changed files with 42 additions and 7 deletions

View 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.");

View 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)

View 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;
}