diff --git a/changes/bug2988 b/changes/bug2988 index 88911e3e2ad9aa81ab3dfeeb5ed96f2eeadefd15..aa141e8c978448f7da2c7cba7ab330796a603ba3 100644 --- a/changes/bug2988 +++ b/changes/bug2988 @@ -3,4 +3,8 @@ operating system's name (e.g., "Linux", "Darwin", "Windows 7"), and not its service pack level (for Windows), or its CPU architecture (for Unix). This is part of ticket 2988. - + - Do not include the (git-XYZ) tag in published server descriptor + platform lines. This is part of ticket 2988. + - Allow packagers to insert an extra string in server descriptor + platform lines by setting the preprocessor variable TOR_BUILD_TAG. + This is part of ticket 2988. diff --git a/src/or/config.c b/src/or/config.c index d11835463b1c5e73e130ce556fbc1d3251d178b1..dcc57f8e774a2b016eb747d0debecedb7ace8390 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -783,6 +783,7 @@ extern const char tor_git_revision[]; /* from tor_main.c */ /** The version of this Tor process, as parsed. */ static char *the_tor_version = NULL; +static char *the_short_tor_version = NULL; /** Return the current Tor version. */ const char * @@ -790,14 +791,31 @@ get_version(void) { if (the_tor_version == NULL) { if (strlen(tor_git_revision)) { - tor_asprintf(&the_tor_version, "%s (git-%s)", VERSION, tor_git_revision); + tor_asprintf(&the_tor_version, "%s (git-%s)", get_short_version(), + tor_git_revision); } else { - the_tor_version = tor_strdup(VERSION); + the_tor_version = tor_strdup(get_short_version()); } } return the_tor_version; } +/** Return the current Tor version, without any git tag. */ +const char * +get_short_version(void) +{ + + if (the_short_tor_version == NULL) { +#ifdef TOR_BUILD_TAG + tor_asprintf(&the_short_tor_version, "%s (%s)", VERSION, TOR_BUILD_TAG); +#else + the_short_tor_version = tor_strdup(VERSION); +#endif + } + return the_short_tor_version; +} + + /** Release additional memory allocated in options */ static void diff --git a/src/or/config.h b/src/or/config.h index 0495186514acd0206c45965d6e3ab4fa730db16a..a68a3e3113a1fa4c4c5c41929501bf68a74d0c97 100644 --- a/src/or/config.h +++ b/src/or/config.h @@ -22,6 +22,7 @@ const char *safe_str(const char *address); const char *escaped_safe_str_client(const char *address); const char *escaped_safe_str(const char *address); const char *get_version(void); +const char *get_short_version(void); int config_get_lines(const char *string, config_line_t **result, int extended); void config_free_lines(config_line_t *front); diff --git a/src/or/router.c b/src/or/router.c index 4468c7b26a7ad8e678d8ceb2fdf6b3b9ac39712e..a967f0dc4b10e035fe0516190f135e8188127a3d 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -1949,7 +1949,7 @@ router_guess_address_from_dir_headers(uint32_t *guess) void get_platform_str(char *platform, size_t len) { - tor_snprintf(platform, len, "Tor %s on %s", get_version(), get_uname()); + tor_snprintf(platform, len, "Tor %s on %s", get_short_version(), get_uname()); } /* XXX need to audit this thing and count fenceposts. maybe