mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Change version parsing logic: a version is "obsolete" if it is not recommended and (1) there is a newer recommended version in the same series, or (2) there are no recommended versions in the same series, but there are some recommended versions in a newer series. A version is "new" if it is newer than any recommended version in the same series.
svn:r3716
This commit is contained in:
parent
b7b05dc1b2
commit
83743d64ab
13
doc/TODO
13
doc/TODO
@ -28,12 +28,15 @@ N . Switch to libevent
|
||||
. Find a way to make sure we have libevent 1.0 or later.
|
||||
o Implement patch to libevent
|
||||
o Submit patch to niels making this possible.
|
||||
- Implement Tor side once patch is accepted.
|
||||
. Log which poll method we're using.
|
||||
o Implement patch to libevent
|
||||
o Submit patch to niels making this possible.
|
||||
- Intercept libevent's "log" messages.
|
||||
- Implement Tor side once patch is accepted.
|
||||
. Intercept libevent's "log" messages.
|
||||
o Ask Niels whether a patch would be accepted.
|
||||
- Implement patch, if so.
|
||||
o Implement patch, if so.
|
||||
- Implement Tor side once patch is accepted.
|
||||
o Check return from event_set, event_add, event_del.
|
||||
- Keep pushing to get a windows patch accepted.
|
||||
|
||||
@ -60,14 +63,14 @@ N . Implement pending controller features.
|
||||
o Map A->B.
|
||||
- Map DontCare->B.
|
||||
- Event for "new descriptors"
|
||||
- Better streams IDs
|
||||
o Better stream IDs
|
||||
- EXTENDCIRCUIT <depends on revised circ selection stuff.>
|
||||
- ATTACHSTREAM <depends on making streams have 'unattached' state.>
|
||||
- Stream status changed: "new" state.
|
||||
R . HTTPS proxy for OR CONNECT stuff. (For outgoing SSL connections to
|
||||
other ORs.)
|
||||
- Changes for forward compatibility
|
||||
N - If a version is later than the last in its series, but a version
|
||||
o Changes for forward compatibility
|
||||
o If a version is later than the last in its series, but a version
|
||||
in the next series is recommended, that doesn't mean it's bad.
|
||||
- Do end reasons better
|
||||
- Start using RESOURCELIMIT more.
|
||||
|
@ -142,6 +142,7 @@ static int check_directory_signature(const char *digest,
|
||||
static crypto_pk_env_t *find_dir_signing_key(const char *str);
|
||||
/* static */ int is_obsolete_version(const char *myversion,
|
||||
const char *versionlist);
|
||||
static int tor_version_same_series(tor_version_t *a, tor_version_t *b);
|
||||
|
||||
/** Set <b>digest</b> to the SHA-1 digest of the hash of the directory in
|
||||
* <b>s</b>. Return 0 on success, nonzero on failure.
|
||||
@ -199,6 +200,12 @@ get_recommended_software_from_directory(const char *str)
|
||||
|
||||
/** Return 1 if <b>myversion</b> is not in <b>versionlist</b>, and if at least
|
||||
* one version of Tor on <b>versionlist</b> is newer than <b>myversion</b>.
|
||||
|
||||
* Return 1 if no version from the same series as <b>myversion</b> is
|
||||
* in <b>versionlist</b> (and <b>myversion</b> is not the newest
|
||||
* version), or if a newer version from the same series is in
|
||||
* <b>versionlist</b>.
|
||||
*
|
||||
* Otherwise return 0.
|
||||
* (versionlist is a comma-separated list of version strings,
|
||||
* optionally prefixed with "Tor". Versions that can't be parsed are
|
||||
@ -207,9 +214,11 @@ get_recommended_software_from_directory(const char *str)
|
||||
const char *versionlist) {
|
||||
const char *vl;
|
||||
tor_version_t mine, other;
|
||||
int found_newer = 0, r, ret;
|
||||
int found_newer = 0, found_newer_in_series = 0, found_any_in_series = 0,
|
||||
r, ret, same;
|
||||
static int warned_too_new=0;
|
||||
smartlist_t *version_sl;
|
||||
int XXXpath;
|
||||
|
||||
vl = versionlist;
|
||||
|
||||
@ -229,26 +238,63 @@ get_recommended_software_from_directory(const char *str)
|
||||
if (tor_version_parse(cp, &other)) {
|
||||
/* Couldn't parse other; it can't be a match. */
|
||||
} else {
|
||||
same = tor_version_same_series(&mine, &other);
|
||||
if (same)
|
||||
found_any_in_series = 1;
|
||||
r = tor_version_compare(&mine, &other);
|
||||
if (r==0) {
|
||||
ret = 0;
|
||||
goto done;
|
||||
} else if (r<0) {
|
||||
found_newer = 1;
|
||||
if (same)
|
||||
found_newer_in_series = 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!found_newer) {
|
||||
if (!warned_too_new) {
|
||||
log(LOG_WARN, "This version of Tor (%s) is newer than any on the recommended list (%s)",
|
||||
myversion, versionlist);
|
||||
warned_too_new=1;
|
||||
/* We didn't find the listed version. Is it new or old? */
|
||||
|
||||
if (found_any_in_series) {
|
||||
if (!found_newer_in_series) {
|
||||
/* We belong to a series with recommended members, and we are newer than
|
||||
* any recommended member. We're probably okay. */
|
||||
if (!warned_too_new) {
|
||||
log(LOG_WARN, "This version of Tor (%s) is newer than any in the same series on the reccomended list (%s)",
|
||||
myversion, versionlist);
|
||||
warned_too_new = 1;
|
||||
}
|
||||
ret = 0;
|
||||
XXXpath = 1;
|
||||
} else {
|
||||
/* We found a newer one in the same series; we're obsolete. */
|
||||
ret = 1;
|
||||
XXXpath = 2;
|
||||
}
|
||||
ret = 0;
|
||||
} else {
|
||||
ret = 1;
|
||||
if (found_newer) {
|
||||
/* We belong to a series with no recommended members, and
|
||||
* a newer series is recommended. We're obsolete. */
|
||||
ret = 1;
|
||||
XXXpath = 3;
|
||||
} else {
|
||||
/* We belong to a series with no recommended members, and it's
|
||||
* newer than any recommended series. We're probably okay. */
|
||||
if (!warned_too_new) {
|
||||
log(LOG_WARN, "This version of Tor (%s) is newer than any on the reccomended list (%s)",
|
||||
myversion, versionlist);
|
||||
warned_too_new = 1;
|
||||
}
|
||||
ret = 0;
|
||||
XXXpath = 4;
|
||||
}
|
||||
}
|
||||
/*
|
||||
log_fn(LOG_DEBUG,
|
||||
"Decided that %s is %sobsolete relative to %s: %d, %d, %d\n",
|
||||
myversion, ret?"":"not ", versionlist, found_newer,
|
||||
found_any_in_series, found_newer_in_series);
|
||||
*/
|
||||
|
||||
done:
|
||||
SMARTLIST_FOREACH(version_sl, char *, version, tor_free(version));
|
||||
@ -1486,13 +1532,16 @@ int tor_version_parse(const char *s, tor_version_t *out)
|
||||
{
|
||||
char *eos=NULL, *cp=NULL;
|
||||
/* Format is:
|
||||
* NUM dot NUM dot NUM [ ( pre | rc | dot ) NUM [ -cvs ] ]
|
||||
* "Tor " ? NUM dot NUM dot NUM [ ( pre | rc | dot ) NUM [ -cvs ] ]
|
||||
*/
|
||||
tor_assert(s);
|
||||
tor_assert(out);
|
||||
|
||||
memset(out, 0, sizeof(tor_version_t));
|
||||
|
||||
if (!strcasecmpstart(s, "Tor "))
|
||||
cp += 4;
|
||||
|
||||
/* Get major. */
|
||||
out->major = strtol(s,&eos,10);
|
||||
if (!eos || eos==s || *eos != '.') return -1;
|
||||
@ -1571,3 +1620,12 @@ int tor_version_compare(tor_version_t *a, tor_version_t *b)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
tor_version_same_series(tor_version_t *a, tor_version_t *b)
|
||||
{
|
||||
tor_assert(a);
|
||||
tor_assert(b);
|
||||
return ((a->major == b->major) &&
|
||||
(a->minor == b->minor) &&
|
||||
(a->micro == b->micro));
|
||||
}
|
||||
|
@ -1239,11 +1239,22 @@ test_dir_format(void)
|
||||
test_eq(1, is_obsolete_version("0.0.1", "0.0.2,Tor 0.0.3"));
|
||||
test_eq(1, is_obsolete_version("0.0.1", "0.0.3,BetterTor 0.0.1"));
|
||||
test_eq(0, is_obsolete_version("0.0.2", "Tor 0.0.2,Tor 0.0.3"));
|
||||
test_eq(1, is_obsolete_version("0.0.2", "Tor 0.0.2pre1,Tor 0.0.3"));
|
||||
test_eq(0, is_obsolete_version("0.0.2", "Tor 0.0.2pre1,Tor 0.0.3"));
|
||||
test_eq(1, is_obsolete_version("0.0.2", "Tor 0.0.2.1,Tor 0.0.3"));
|
||||
test_eq(0, is_obsolete_version("0.1.0", "Tor 0.0.2,Tor 0.0.3"));
|
||||
test_eq(0, is_obsolete_version("0.0.7rc2", "0.0.7,Tor 0.0.7rc2,Tor 0.0.8"));
|
||||
test_eq(0, is_obsolete_version("0.0.5", "0.0.5-cvs"));
|
||||
test_eq(0, is_obsolete_version("0.0.5.1-cvs", "0.0.5"));
|
||||
/* Not on list, but newer than any in same series. */
|
||||
test_eq(0, is_obsolete_version("0.1.0.3", "Tor 0.1.0.2,Tor 0.0.9.5,Tor 0.1.1.0"));
|
||||
/* Series newer than any on list. */
|
||||
test_eq(0, is_obsolete_version("0.1.1.3", "Tor 0.1.0.2,Tor 0.0.9.5,Tor 0.1.1.0"));
|
||||
/* Series older than any on list. */
|
||||
test_eq(1, is_obsolete_version("0.0.1.3", "Tor 0.1.0.2,Tor 0.0.9.5,Tor 0.1.1.0"));
|
||||
/* Not on list, not newer than any on same series. */
|
||||
test_eq(1, is_obsolete_version("0.1.0.1", "Tor 0.1.0.2,Tor 0.0.9.5,Tor 0.1.1.0"));
|
||||
/* On list, not newer than any on same series. */
|
||||
test_eq(1, is_obsolete_version("0.1.0.1", "Tor 0.1.0.2,Tor 0.0.9.5,Tor 0.1.1.0"));
|
||||
|
||||
test_eq(0, tor_version_as_new_as("Tor 0.0.5", "0.0.9pre1-cvs"));
|
||||
test_eq(1, tor_version_as_new_as(
|
||||
|
Loading…
Reference in New Issue
Block a user