[or-cvs] Check for even more windows version flags, and note any we ...

Nick Mathewson nickm at seul.org
Mon Oct 24 18:37:11 UTC 2005


Update of /home/or/cvsroot/tor/src/common
In directory moria:/tmp/cvs-serv14791/src/common

Modified Files:
	compat.c log.h tortls.c util.c 
Log Message:
Check for even more windows version flags, and note any we do not recognize.

Index: compat.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/compat.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- compat.c	18 Oct 2005 21:58:19 -0000	1.74
+++ compat.c	24 Oct 2005 18:37:09 -0000	1.75
@@ -695,6 +695,7 @@
 #ifdef MS_WINDOWS
         OSVERSIONINFOEX info;
         int i;
+        unsigned int leftover_mask;
         const char *plat = NULL;
         static struct {
           int major; int minor; const char *version;
@@ -710,6 +711,21 @@
           { 3, 51, "Windows NT 3.51" },
           { -1, -1, NULL }
         };
+        static struct {
+          unsigned int mask; const char *str;
+        } win_mask_table[] = {
+          { VER_SUITE_BACKOFFICE,         " {backoffice}" },
+          { VER_SUITE_BLADE,              " {\"blade\" (2003, web edition)}" },
+          { VER_SUITE_DATACENTER,         " {datacenter}" },
+          { VER_SUITE_ENTERPRISE,         " {enterprise}" },
+          { VER_SUITE_EMBEDDEDNT,         " {embedded}" },
+          { VER_SUITE_PERSONAL,           " {personal}" },
+          { VER_SUITE_SINGLEUSERTS,       " {terminal services, single user}" },
+          { VER_SUITE_SMALLBUSINESS,      " {small business}" },
+          { VER_SUITE_SMALLBUSINESS_RESTRICTED, " {small business, restricted}" },
+          { VER_SUITE_TERMINAL,           " {terminal services}" },
+          { 0, NULL },
+        };
         info.dwOSVersionInfoSize = sizeof(info);
         GetVersionEx((LPOSVERSIONINFO)&info);
         if (info.dwMajorVersion == 4 && info.dwMinorVersion == 0) {
@@ -733,12 +749,14 @@
           if (info.dwMajorVersion > 6 ||
               (info.dwMajorVersion==6 && info.dwMinorVersion>0))
             tor_snprintf(uname_result, sizeof(uname_result),
-                         "Very recent version of Windows [major=%d,minor=%d]",
-                         (int)info.dwMajorVersion,(int)info.dwMinorVersion);
+                         "Very recent version of Windows [major=%d,minor=%d] %s",
+                         (int)info.dwMajorVersion,(int)info.dwMinorVersion,
+                         info.szCSDVersion);
           else
             tor_snprintf(uname_result, sizeof(uname_result),
-                         "Unrecognized version of Windows [major=%d,minor=%d]",
-                         (int)info.dwMajorVersion,(int)info.dwMinorVersion);
+                         "Unrecognized version of Windows [major=%d,minor=%d] %s",
+                         (int)info.dwMajorVersion,(int)info.dwMinorVersion,
+                         infor.szCSDVersion);
         }
         if (info.wProductType == VER_NT_DOMAIN_CONTROLLER) {
           strlcat(uname_result, " [domain controller]", sizeof(uname_result));
@@ -747,20 +765,17 @@
         } else if (info.wProductType == VER_NT_WORKSTATION) {
           strlcat(uname_result, " [workstation]", sizeof(uname_result));
         }
-        if (info.wSuiteMask & VER_SUITE_DATACENTER) {
-          strlcat(uname_result, " {datacenter}", sizeof(uname_result));
-        }
-        if (info.wSuiteMask & VER_SUITE_ENTERPRISE) {
-          strlcat(uname_result, " {enterprise}", sizeof(uname_result));
-        }
-        if (info.wSuiteMask & VER_SUITE_PERSONAL) {
-          strlcat(uname_result, " {personal}", sizeof(uname_result));
-        }
-        if (info.wSuiteMask & VER_SUITE_EMBEDDEDNT) {
-          strlcat(uname_result, " {personal}", sizeof(uname_result));
+        leftover_mask = info.wSuiteMask;
+        for (i = 0; win_mask_table[i].mask; ++i) {
+          if (info.wSuiteMask & win_mask_table[i]) {
+            strlcat(uname_result, win_mask_table[i].str, sizeof(uname_result));
+            leftover_mask &= ~win_mask_table[i].mask;
+          }
         }
-        if (info.wSuiteMask & VER_SUITE_PERSONAL) {
-          strlcat(uname_result, " {personal}", sizeof(uname_result));
+        if (leftover_mask) {
+          size_t len = strlen(uname_result);
+          tor_snprintf(uname_result+len, sizeof(uname_result)-len,
+                       " {0x%x}", info.wSuiteMask);
         }
 #else
         strlcpy(uname_result, "Unknown platform", sizeof(uname_result));

Index: log.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/log.h,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- log.h	18 Oct 2005 22:56:40 -0000	1.50
+++ log.h	24 Oct 2005 18:37:09 -0000	1.51
@@ -52,8 +52,7 @@
 
 /* Logging domains */
 
-/** Catch-all for miscellaneous events and internal errors and fatal
- * errors. */
+/** Catch-all for miscellaneous events and fatal errors */
 #define LD_GENERAL  0
 /** The cryptography subsytem */
 #define LD_CRYPTO   1
@@ -77,6 +76,10 @@
 #define LD_CIRC     10
 /** Hidden services */
 #define LD_REND     11
+/** Internal errors in this Tor process. */
+#define LD_BUG      12
+/** Learning and using information about Tor servers. */
+#define LD_DIR      13
 
 typedef void (*log_callback)(int severity, int domain, const char *msg);
 

Index: tortls.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/tortls.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -d -r1.108 -r1.109
--- tortls.c	18 Oct 2005 21:58:19 -0000	1.108
+++ tortls.c	24 Oct 2005 18:37:09 -0000	1.109
@@ -689,7 +689,7 @@
            problem);
 
   if (!(bio = BIO_new(BIO_s_mem()))) {
-    log_fn(LOG_WARN, LD_GENERAL, "Couldn't allocate BIO!"); goto end;
+    warn(LD_GENERAL, "Couldn't allocate BIO!"); goto end;
   }
   if (!(ASN1_TIME_print(bio, X509_get_notBefore(cert)))) {
     tls_log_errors(LOG_WARN, "printing certificate lifetime");

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.c,v
retrieving revision 1.229
retrieving revision 1.230
diff -u -d -r1.229 -r1.230
--- util.c	18 Oct 2005 21:58:19 -0000	1.229
+++ util.c	24 Oct 2005 18:37:09 -0000	1.230
@@ -909,7 +909,7 @@
   if (st.st_mode & 0077) {
     log(LOG_WARN, LD_FS, "Fixing permissions on directory %s", dirname);
     if (chmod(dirname, 0700)) {
-      log(LOG_WARN, LD_GENERAL, "Could not chmod directory %s: %s", dirname,
+      log(LOG_WARN, LD_FS, "Could not chmod directory %s: %s", dirname,
           strerror(errno));
       return -1;
     } else {
@@ -930,8 +930,8 @@
 {
 #ifdef MS_WINDOWS
   if (!bin && strchr(str, '\r')) {
-    warn(LD_GENERAL,
-           "How odd. Writing a string that does contain CR already.");
+    warn(LD_BUG,
+           "Bug: we're writing a text string that already contains a CR.");
   }
 #endif
   return write_bytes_to_file(fname, str, strlen(str), bin);
@@ -1243,6 +1243,9 @@
   }
   result = smartlist_create();
   while (1) {
+    if (!strcmp(findData.cFileName, ".") ||
+        !strcmp(findData.cFileName, ".."))
+      continue;
     smartlist_add(result, tor_strdup(findData.cFileName));
     if (!FindNextFile(handle, &findData)) {
       if (GetLastError() != ERROR_NO_MORE_FILES) {



More information about the tor-commits mailing list