[tor-commits] [tor/master] Cut down on the OS information we give.

nickm at torproject.org nickm at torproject.org
Mon May 14 16:15:48 UTC 2012


commit a2f0e7a65bb2397087ce92cf23149686185de8e9
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri May 11 17:50:30 2012 -0400

    Cut down on the OS information we give.
    
    For uname-based detection, we now give only the OS name (e.g.,
    "Darwin", "Linux".)  For Windows, we give only the Operating System
    name as inferred from dw(Major|Minor)version, (e.g., "Windows XP",
    "Windows 7"), and whether the VER_NT_SERVER flag is set.
    
    For ticket 2988.
---
 changes/bug2988     |    6 ++++++
 src/common/compat.c |   49 ++++++++++++-------------------------------------
 2 files changed, 18 insertions(+), 37 deletions(-)

diff --git a/changes/bug2988 b/changes/bug2988
new file mode 100644
index 0000000..88911e3
--- /dev/null
+++ b/changes/bug2988
@@ -0,0 +1,6 @@
+  o Minor features:
+    - The advertised platform of a router now includes only its
+      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.
+
diff --git a/src/common/compat.c b/src/common/compat.c
index 1680f66..2cc3c06 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -2030,8 +2030,7 @@ get_uname(void)
 #ifdef HAVE_UNAME
     if (uname(&u) != -1) {
       /* (Linux says 0 is success, Solaris says 1 is success) */
-      tor_snprintf(uname_result, sizeof(uname_result), "%s %s",
-               u.sysname, u.machine);
+      strlcpy(uname_result, u.sysname, sizeof(uname_result));
     } else
 #endif
       {
@@ -2039,8 +2038,6 @@ get_uname(void)
         OSVERSIONINFOEX info;
         int i;
         const char *plat = NULL;
-        const char *extra = NULL;
-        char acsd[MAX_PATH] = {0};
         static struct {
           unsigned major; unsigned minor; const char *version;
         } win_version_table[] = {
@@ -2065,20 +2062,11 @@ get_uname(void)
           uname_result_is_set = 1;
           return uname_result;
         }
-#ifdef UNICODE
-        wcstombs(acsd, info.szCSDVersion, MAX_PATH);
-#else
-        strlcpy(acsd, info.szCSDVersion, sizeof(acsd));
-#endif
         if (info.dwMajorVersion == 4 && info.dwMinorVersion == 0) {
           if (info.dwPlatformId == VER_PLATFORM_WIN32_NT)
             plat = "Windows NT 4.0";
           else
             plat = "Windows 95";
-          if (acsd[1] == 'B')
-            extra = "OSR2 (B)";
-          else if (acsd[1] == 'C')
-            extra = "OSR2 (C)";
         } else {
           for (i=0; win_version_table[i].major>0; ++i) {
             if (win_version_table[i].major == info.dwMajorVersion &&
@@ -2088,39 +2076,26 @@ get_uname(void)
             }
           }
         }
-        if (plat && !strcmp(plat, "Windows 98")) {
-          if (acsd[1] == 'A')
-            extra = "SE (A)";
-          else if (acsd[1] == 'B')
-            extra = "SE (B)";
-        }
         if (plat) {
-          if (!extra)
-            extra = acsd;
-          tor_snprintf(uname_result, sizeof(uname_result), "%s %s",
-                       plat, extra);
+          strlcpy(uname_result, plat, sizeof(uname_result));
         } else {
           if (info.dwMajorVersion > 6 ||
               (info.dwMajorVersion==6 && info.dwMinorVersion>2))
             tor_snprintf(uname_result, sizeof(uname_result),
-                      "Very recent version of Windows [major=%d,minor=%d] %s",
-                      (int)info.dwMajorVersion,(int)info.dwMinorVersion,
-                      acsd);
+                         "Very recent version of Windows [major=%d,minor=%d]",
+                         (int)info.dwMajorVersion,(int)info.dwMinorVersion,
+                         );
           else
             tor_snprintf(uname_result, sizeof(uname_result),
-                      "Unrecognized version of Windows [major=%d,minor=%d] %s",
-                      (int)info.dwMajorVersion,(int)info.dwMinorVersion,
-                      acsd);
+                         "Unrecognized version of Windows [major=%d,minor=%d]",
+                         (int)info.dwMajorVersion,(int)info.dwMinorVersion);
         }
 #if !defined (WINCE)
-#ifdef VER_SUITE_BACKOFFICE
-        if (info.wProductType == VER_NT_DOMAIN_CONTROLLER) {
-          strlcat(uname_result, " [domain controller]", sizeof(uname_result));
-        } else if (info.wProductType == VER_NT_SERVER) {
-          strlcat(uname_result, " [server]", sizeof(uname_result));
-        } else if (info.wProductType == VER_NT_WORKSTATION) {
-          strlcat(uname_result, " [workstation]", sizeof(uname_result));
-        }
+#ifdef VER_NT_SERVER
+      if (info.wProductType == VER_NT_SERVER ||
+          info.wProductType == VER_NT_DOMAIN_CONTROLLER) {
+        strlcat(uname_result, " [server]", sizeof(uname_result));
+      }
 #endif
 #endif
 #else





More information about the tor-commits mailing list