From: hno <> Date: Sat, 17 Nov 2001 18:09:24 +0000 (+0000) Subject: Some WIN32 enhancements on WIN32 GetOSVersion code by Guido X-Git-Tag: SQUID_3_0_PRE1~1282 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be20dac753e9441e5fbc327f1f8bc4db0288784d;p=thirdparty%2Fsquid.git Some WIN32 enhancements on WIN32 GetOSVersion code by Guido --- diff --git a/src/defines.h b/src/defines.h index aed24d9228..1edba7ace8 100644 --- a/src/defines.h +++ b/src/defines.h @@ -1,6 +1,6 @@ /* - * $Id: defines.h,v 1.96 2001/10/08 16:55:25 hno Exp $ + * $Id: defines.h,v 1.97 2001/11/17 11:09:24 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -296,15 +296,4 @@ #define O_BINARY 0 #endif -/* CygWin & Windows NT Port */ -#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) -#define _WIN_OS_UNKNOWN 0 -#define _WIN_OS_WIN32S 1 -#define _WIN_OS_WIN95 2 -#define _WIN_OS_WIN98 3 -#define _WIN_OS_WINNT 4 -#define _WIN_OS_WIN2K 5 -#define _WIN_OS_WINXP 6 -#endif - #endif /* SQUID_DEFINES_H */ diff --git a/src/dns_internal.cc b/src/dns_internal.cc index 91a74ce8b6..bdd897698e 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -1,6 +1,6 @@ /* - * $Id: dns_internal.cc,v 1.44 2001/10/24 07:45:34 hno Exp $ + * $Id: dns_internal.cc,v 1.45 2001/11/17 11:09:24 hno Exp $ * * DEBUG: section 78 DNS lookups; interacts with lib/rfc1035.c * AUTHOR: Duane Wessels @@ -289,6 +289,7 @@ idnsParseWIN32Registry(void) break; case _WIN_OS_WIN95: case _WIN_OS_WIN98: + case _WIN_OS_WINME: /* get nameservers from the Windows 9X registry */ if (RegOpenKey(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP", diff --git a/src/enums.h b/src/enums.h index 6729acacfc..fe1a80be79 100644 --- a/src/enums.h +++ b/src/enums.h @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.200 2001/11/16 17:02:20 hno Exp $ + * $Id: enums.h,v 1.201 2001/11/17 11:09:24 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -729,4 +729,22 @@ enum { VARY_CANCEL }; +/* CygWin & Windows NT Port */ +#if defined(_SQUID_MSWIN_) || defined(_SQUID_CYGWIN_) +/* + * Supported Windows OS types codes + */ +enum { + _WIN_OS_UNKNOWN, + _WIN_OS_WIN32S, + _WIN_OS_WIN95, + _WIN_OS_WIN98, + _WIN_OS_WINME, + _WIN_OS_WINNT, + _WIN_OS_WIN2K, + _WIN_OS_WINXP +}; + +#endif + #endif /* SQUID_ENUMS_H */ diff --git a/src/tools.cc b/src/tools.cc index 4885139a05..6106f79427 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1,6 +1,6 @@ /* - * $Id: tools.cc,v 1.212 2001/11/15 15:01:37 hno Exp $ + * $Id: tools.cc,v 1.213 2001/11/17 11:09:25 hno Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -513,7 +513,7 @@ safeunlink(const char *s, int quiet) void leave_suid(void) { - debug(21, 3) ("leave_suid: PID %d called\n", (int)getpid()); + debug(21, 3) ("leave_suid: PID %d called\n", (int) getpid()); if (geteuid() != 0) return; /* Started as a root, check suid option */ @@ -525,7 +525,7 @@ leave_suid(void) if (setgid(Config2.effectiveGroupID) < 0) debug(50, 0) ("ALERT: setgid: %s\n", xstrerror()); debug(21, 3) ("leave_suid: PID %d giving up root, becoming '%s'\n", - (int)getpid(), Config.effectiveUser); + (int) getpid(), Config.effectiveUser); #if HAVE_SETRESUID if (setresuid(Config2.effectiveUserID, Config2.effectiveUserID, 0) < 0) debug(50, 0) ("ALERT: setresuid: %s\n", xstrerror()); @@ -542,7 +542,7 @@ leave_suid(void) void enter_suid(void) { - debug(21, 3) ("enter_suid: PID %d taking root priveleges\n", (int)getpid()); + debug(21, 3) ("enter_suid: PID %d taking root priveleges\n", (int) getpid()); #if HAVE_SETRESUID setresuid(-1, 0, -1); #else @@ -559,7 +559,7 @@ no_suid(void) uid_t uid; leave_suid(); uid = geteuid(); - debug(21, 3) ("leave_suid: PID %d giving up root priveleges forever\n", (int)getpid()); + debug(21, 3) ("leave_suid: PID %d giving up root priveleges forever\n", (int) getpid()); #if HAVE_SETRESUID if (setresuid(uid, uid, uid) < 0) debug(50, 1) ("no_suid: setresuid: %s\n", xstrerror()); @@ -1019,7 +1019,7 @@ parseEtcHosts(void) lt = nt + 1; } fqdncacheAddEntryFromHosts(addr, hosts); -skip: + skip: wordlistDestroy(&hosts); } } diff --git a/src/win32.cc b/src/win32.cc index fa5a8f9000..4faa5ee507 100644 --- a/src/win32.cc +++ b/src/win32.cc @@ -1,6 +1,6 @@ /* - * $Id: win32.cc,v 1.3 2001/10/19 22:34:49 hno Exp $ + * $Id: win32.cc,v 1.4 2001/11/17 11:09:25 hno Exp $ * * * * * * * * * Legal stuff * * * * * * * * @@ -49,30 +49,37 @@ GetOSVersion() WIN32_OS_string = xstrdup("Windows NT"); return _WIN_OS_WINNT; } + if ((osvi.dwMajorVersion == 5) && (osvi.dwMinorVersion == 0)) { + WIN32_OS_string = xstrdup("Windows 2000"); + return _WIN_OS_WIN2K; + } if ((osvi.dwMajorVersion == 5) && (osvi.dwMinorVersion == 1)) { WIN32_OS_string = xstrdup("Windows XP"); return _WIN_OS_WINXP; } - WIN32_OS_string = xstrdup("Windows 2000"); - return _WIN_OS_WIN2K; break; case VER_PLATFORM_WIN32_WINDOWS: - if ((osvi.dwMajorVersion > 4) || - ((osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion > 0))) { + if ((osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion == 0)) { + WIN32_OS_string = xstrdup("Windows 95"); + return _WIN_OS_WIN95; + } + if ((osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion == 10)) { WIN32_OS_string = xstrdup("Windows 98"); return _WIN_OS_WIN98; } - WIN32_OS_string = xstrdup("Windows 95"); - return _WIN_OS_WIN95; + if ((osvi.dwMajorVersion == 4) && (osvi.dwMinorVersion == 90)) { + WIN32_OS_string = xstrdup("Windows Me"); + return _WIN_OS_WINME; + } break; case VER_PLATFORM_WIN32s: WIN32_OS_string = xstrdup("Windows 3.1 with WIN32S"); return _WIN_OS_WIN32S; break; default: - return _WIN_OS_UNKNOWN; + break; } - WIN32_OS_string = xstrdup("Unknown"); + WIN32_OS_string = xstrdup("Unknown Windows system"); return _WIN_OS_UNKNOWN; }