aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-10-24 18:37:09 +0000
committerNick Mathewson <nickm@torproject.org>2005-10-24 18:37:09 +0000
commita20835ac920b446e808116dad8ba6cf9c7d18a7e (patch)
tree10d3e916da8377298aa1244568af8e3ce9b1b6de
parente2c6d6ce201f228fc3f0c48cdbb06c9934369c81 (diff)
downloadtor-a20835ac920b446e808116dad8ba6cf9c7d18a7e.tar
tor-a20835ac920b446e808116dad8ba6cf9c7d18a7e.tar.gz
Check for even more windows version flags, and note any we do not recognize.
svn:r5297
-rw-r--r--src/common/compat.c49
-rw-r--r--src/common/log.h7
-rw-r--r--src/common/tortls.c2
-rw-r--r--src/common/util.c9
4 files changed, 44 insertions, 23 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index 20df1b71b..6a8368fef 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -695,6 +695,7 @@ get_uname(void)
#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 @@ get_uname(void)
{ 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 @@ get_uname(void)
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 @@ get_uname(void)
} 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));
diff --git a/src/common/log.h b/src/common/log.h
index d31d866c7..a33dd4ccd 100644
--- a/src/common/log.h
+++ b/src/common/log.h
@@ -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);
diff --git a/src/common/tortls.c b/src/common/tortls.c
index 90aa5cacf..a4cd730b3 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -689,7 +689,7 @@ log_cert_lifetime(X509 *cert, const char *problem)
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");
diff --git a/src/common/util.c b/src/common/util.c
index 5d08cd6de..09fdd9841 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -909,7 +909,7 @@ check_private_dir(const char *dirname, cpd_check_t check)
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 @@ write_str_to_file(const char *fname, const char *str, int bin)
{
#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 @@ tor_listdir(const char *dirname)
}
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) {