]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
No longer exit for missing required protocolversions on an old consensus
authorNick Mathewson <nickm@torproject.org>
Sun, 25 Nov 2018 01:40:48 +0000 (20:40 -0500)
committerNick Mathewson <nickm@torproject.org>
Sun, 25 Nov 2018 01:44:37 +0000 (20:44 -0500)
Specifically, if the consensus is older than the (estimted or
measured) release date for this version of tor, we assume that the
required versions may have changed in between that consensus and
this release.

Implements ticket 27735 and proposal 297.

changes/prop297 [new file with mode: 0644]
src/core/or/versions.c
src/core/or/versions.h
src/feature/nodelist/networkstatus.c

diff --git a/changes/prop297 b/changes/prop297
new file mode 100644 (file)
index 0000000..4f93b23
--- /dev/null
@@ -0,0 +1,7 @@
+  o Minor features (required protocols):
+    - Tor no longer exits if it is missing a required protocol, if the
+      consensus that requires the protocol predates the release date of the
+      version of Tor. This change prevents Tor releases from exiting because
+      of an old cached consensus, on the theory that a newer cached
+      consensus might not require the protocol.  Implements proposal 297;
+      closes ticket 27735.
index 5d4effcaf843ad699505ee6d38d08492cdcc81f3..d978935f4f6b3a6310365888a53cd8f0fde26a02 100644 (file)
 
 #include "core/or/tor_version_st.h"
 
+/**
+ * Return the approximate date when this release came out, or was
+ * scheduled to come out, according to the APPROX_RELEASE_DATE set in
+ * configure.ac
+ **/
+time_t
+tor_get_approx_release_date(void)
+{
+  char tbuf[ISO_TIME_LEN+1];
+  tor_snprintf(tbuf, sizeof(tbuf),
+               "%s 00:00:00", APPROX_RELEASE_DATE);
+  time_t result = 0;
+  int r = parse_iso_time(tbuf, &result);
+  if (BUG(r < 0)) {
+    result = 0;
+  }
+  return result;
+}
+
 /** Return VS_RECOMMENDED if <b>myversion</b> is contained in
  * <b>versionlist</b>.  Else, return VS_EMPTY if versionlist has no
  * entries. Else, return VS_OLD if every member of
index 4fc50a00185a7eb8abbeee4786506bba73db2779..acd8998918ee05dfd29d690d8ee241ceb9213bfb 100644 (file)
@@ -26,6 +26,8 @@ typedef enum version_status_t {
   VS_UNKNOWN, /**< We have no idea. */
 } version_status_t;
 
+time_t tor_get_approx_release_date(void);
+
 version_status_t tor_version_is_obsolete(const char *myversion,
                                          const char *versionlist);
 int tor_version_parse_platform(const char *platform,
index f1def9afb16672e7aaf1c94465279cf33e4886b5..a25a539cd8a62e92376e5fd5eb505796d06837dc 100644 (file)
@@ -2684,6 +2684,9 @@ networkstatus_check_required_protocols(const networkstatus_t *ns,
   const char *required, *recommended;
   char *missing = NULL;
 
+  const bool consensus_postdates_this_release =
+    ns->valid_after >= tor_get_approx_release_date();
+
   tor_assert(warning_out);
 
   if (client_mode) {
@@ -2701,7 +2704,7 @@ networkstatus_check_required_protocols(const networkstatus_t *ns,
                  "%s on the Tor network. The missing protocols are: %s",
                  func, missing);
     tor_free(missing);
-    return 1;
+    return consensus_postdates_this_release ? 1 : 0;
   }
 
   if (! protover_all_supported(recommended, &missing)) {