mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 20:33:31 +01:00
Check for even more windows version flags, and note any we do not recognize.
svn:r5297
This commit is contained in:
parent
e2c6d6ce20
commit
a20835ac92
@ -695,6 +695,7 @@ get_uname(void)
|
|||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
OSVERSIONINFOEX info;
|
OSVERSIONINFOEX info;
|
||||||
int i;
|
int i;
|
||||||
|
unsigned int leftover_mask;
|
||||||
const char *plat = NULL;
|
const char *plat = NULL;
|
||||||
static struct {
|
static struct {
|
||||||
int major; int minor; const char *version;
|
int major; int minor; const char *version;
|
||||||
@ -710,6 +711,21 @@ get_uname(void)
|
|||||||
{ 3, 51, "Windows NT 3.51" },
|
{ 3, 51, "Windows NT 3.51" },
|
||||||
{ -1, -1, NULL }
|
{ -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);
|
info.dwOSVersionInfoSize = sizeof(info);
|
||||||
GetVersionEx((LPOSVERSIONINFO)&info);
|
GetVersionEx((LPOSVERSIONINFO)&info);
|
||||||
if (info.dwMajorVersion == 4 && info.dwMinorVersion == 0) {
|
if (info.dwMajorVersion == 4 && info.dwMinorVersion == 0) {
|
||||||
@ -733,12 +749,14 @@ get_uname(void)
|
|||||||
if (info.dwMajorVersion > 6 ||
|
if (info.dwMajorVersion > 6 ||
|
||||||
(info.dwMajorVersion==6 && info.dwMinorVersion>0))
|
(info.dwMajorVersion==6 && info.dwMinorVersion>0))
|
||||||
tor_snprintf(uname_result, sizeof(uname_result),
|
tor_snprintf(uname_result, sizeof(uname_result),
|
||||||
"Very recent version of Windows [major=%d,minor=%d]",
|
"Very recent version of Windows [major=%d,minor=%d] %s",
|
||||||
(int)info.dwMajorVersion,(int)info.dwMinorVersion);
|
(int)info.dwMajorVersion,(int)info.dwMinorVersion,
|
||||||
|
info.szCSDVersion);
|
||||||
else
|
else
|
||||||
tor_snprintf(uname_result, sizeof(uname_result),
|
tor_snprintf(uname_result, sizeof(uname_result),
|
||||||
"Unrecognized version of Windows [major=%d,minor=%d]",
|
"Unrecognized version of Windows [major=%d,minor=%d] %s",
|
||||||
(int)info.dwMajorVersion,(int)info.dwMinorVersion);
|
(int)info.dwMajorVersion,(int)info.dwMinorVersion,
|
||||||
|
infor.szCSDVersion);
|
||||||
}
|
}
|
||||||
if (info.wProductType == VER_NT_DOMAIN_CONTROLLER) {
|
if (info.wProductType == VER_NT_DOMAIN_CONTROLLER) {
|
||||||
strlcat(uname_result, " [domain controller]", sizeof(uname_result));
|
strlcat(uname_result, " [domain controller]", sizeof(uname_result));
|
||||||
@ -747,20 +765,17 @@ get_uname(void)
|
|||||||
} else if (info.wProductType == VER_NT_WORKSTATION) {
|
} else if (info.wProductType == VER_NT_WORKSTATION) {
|
||||||
strlcat(uname_result, " [workstation]", sizeof(uname_result));
|
strlcat(uname_result, " [workstation]", sizeof(uname_result));
|
||||||
}
|
}
|
||||||
if (info.wSuiteMask & VER_SUITE_DATACENTER) {
|
leftover_mask = info.wSuiteMask;
|
||||||
strlcat(uname_result, " {datacenter}", sizeof(uname_result));
|
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_ENTERPRISE) {
|
|
||||||
strlcat(uname_result, " {enterprise}", sizeof(uname_result));
|
|
||||||
}
|
}
|
||||||
if (info.wSuiteMask & VER_SUITE_PERSONAL) {
|
if (leftover_mask) {
|
||||||
strlcat(uname_result, " {personal}", sizeof(uname_result));
|
size_t len = strlen(uname_result);
|
||||||
}
|
tor_snprintf(uname_result+len, sizeof(uname_result)-len,
|
||||||
if (info.wSuiteMask & VER_SUITE_EMBEDDEDNT) {
|
" {0x%x}", info.wSuiteMask);
|
||||||
strlcat(uname_result, " {personal}", sizeof(uname_result));
|
|
||||||
}
|
|
||||||
if (info.wSuiteMask & VER_SUITE_PERSONAL) {
|
|
||||||
strlcat(uname_result, " {personal}", sizeof(uname_result));
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
strlcpy(uname_result, "Unknown platform", sizeof(uname_result));
|
strlcpy(uname_result, "Unknown platform", sizeof(uname_result));
|
||||||
|
@ -52,8 +52,7 @@
|
|||||||
|
|
||||||
/* Logging domains */
|
/* Logging domains */
|
||||||
|
|
||||||
/** Catch-all for miscellaneous events and internal errors and fatal
|
/** Catch-all for miscellaneous events and fatal errors */
|
||||||
* errors. */
|
|
||||||
#define LD_GENERAL 0
|
#define LD_GENERAL 0
|
||||||
/** The cryptography subsytem */
|
/** The cryptography subsytem */
|
||||||
#define LD_CRYPTO 1
|
#define LD_CRYPTO 1
|
||||||
@ -77,6 +76,10 @@
|
|||||||
#define LD_CIRC 10
|
#define LD_CIRC 10
|
||||||
/** Hidden services */
|
/** Hidden services */
|
||||||
#define LD_REND 11
|
#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);
|
typedef void (*log_callback)(int severity, int domain, const char *msg);
|
||||||
|
|
||||||
|
@ -689,7 +689,7 @@ log_cert_lifetime(X509 *cert, const char *problem)
|
|||||||
problem);
|
problem);
|
||||||
|
|
||||||
if (!(bio = BIO_new(BIO_s_mem()))) {
|
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)))) {
|
if (!(ASN1_TIME_print(bio, X509_get_notBefore(cert)))) {
|
||||||
tls_log_errors(LOG_WARN, "printing certificate lifetime");
|
tls_log_errors(LOG_WARN, "printing certificate lifetime");
|
||||||
|
@ -909,7 +909,7 @@ check_private_dir(const char *dirname, cpd_check_t check)
|
|||||||
if (st.st_mode & 0077) {
|
if (st.st_mode & 0077) {
|
||||||
log(LOG_WARN, LD_FS, "Fixing permissions on directory %s", dirname);
|
log(LOG_WARN, LD_FS, "Fixing permissions on directory %s", dirname);
|
||||||
if (chmod(dirname, 0700)) {
|
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));
|
strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
@ -930,8 +930,8 @@ write_str_to_file(const char *fname, const char *str, int bin)
|
|||||||
{
|
{
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
if (!bin && strchr(str, '\r')) {
|
if (!bin && strchr(str, '\r')) {
|
||||||
warn(LD_GENERAL,
|
warn(LD_BUG,
|
||||||
"How odd. Writing a string that does contain CR already.");
|
"Bug: we're writing a text string that already contains a CR.");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return write_bytes_to_file(fname, str, strlen(str), bin);
|
return write_bytes_to_file(fname, str, strlen(str), bin);
|
||||||
@ -1243,6 +1243,9 @@ tor_listdir(const char *dirname)
|
|||||||
}
|
}
|
||||||
result = smartlist_create();
|
result = smartlist_create();
|
||||||
while (1) {
|
while (1) {
|
||||||
|
if (!strcmp(findData.cFileName, ".") ||
|
||||||
|
!strcmp(findData.cFileName, ".."))
|
||||||
|
continue;
|
||||||
smartlist_add(result, tor_strdup(findData.cFileName));
|
smartlist_add(result, tor_strdup(findData.cFileName));
|
||||||
if (!FindNextFile(handle, &findData)) {
|
if (!FindNextFile(handle, &findData)) {
|
||||||
if (GetLastError() != ERROR_NO_MORE_FILES) {
|
if (GetLastError() != ERROR_NO_MORE_FILES) {
|
||||||
|
Loading…
Reference in New Issue
Block a user