mirror of https://github.com/moparisthebest/curl
Dominick Meglio host file path discovery patch for windows
This commit is contained in:
parent
cb80670885
commit
12dc142a28
14
ares/CHANGES
14
ares/CHANGES
|
@ -1,5 +1,19 @@
|
||||||
Changelog for the c-ares project
|
Changelog for the c-ares project
|
||||||
|
|
||||||
|
* September 26
|
||||||
|
|
||||||
|
- Dominick Meglio patched: C-ares on Windows assumed that the HOSTS file is
|
||||||
|
located in a static location. It assumed
|
||||||
|
C:\Windows\System32\Drivers\Etc. This is a poor assumption to make. In fact,
|
||||||
|
the location of the HOSTS file can be changed via a registry setting.
|
||||||
|
|
||||||
|
There is a key called DatabasePath which specifies the path to the HOSTS
|
||||||
|
file:
|
||||||
|
http://www.microsoft.com/technet/itsolutions/network/deploy/depovg/tcpip2k.mspx
|
||||||
|
|
||||||
|
The patch will make c-ares correctly consult the registry for the location
|
||||||
|
of this file.
|
||||||
|
|
||||||
* August 29
|
* August 29
|
||||||
|
|
||||||
- Gisle Vanem fixed the MSVC build files.
|
- Gisle Vanem fixed the MSVC build files.
|
||||||
|
|
|
@ -150,12 +150,23 @@ static int file_lookup(struct in_addr *addr, struct hostent **host)
|
||||||
|
|
||||||
char PATH_HOSTS[MAX_PATH];
|
char PATH_HOSTS[MAX_PATH];
|
||||||
if (IsNT) {
|
if (IsNT) {
|
||||||
GetSystemDirectory(PATH_HOSTS, MAX_PATH);
|
char tmp[MAX_PATH];
|
||||||
strcat(PATH_HOSTS, PATH_HOSTS_NT);
|
HKEY hkeyHosts;
|
||||||
} else {
|
|
||||||
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
|
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hkeyHosts)
|
||||||
strcat(PATH_HOSTS, PATH_HOSTS_9X);
|
== ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
DWORD dwLength = MAX_PATH;
|
||||||
|
RegQueryValueEx(hkeyHosts, DATABASEPATH, NULL, NULL, tmp,
|
||||||
|
&dwLength);
|
||||||
|
ExpandEnvironmentStrings(tmp, PATH_HOSTS, MAX_PATH);
|
||||||
|
RegCloseKey(hkeyHosts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
|
||||||
|
|
||||||
|
strcat(PATH_HOSTS, WIN_PATH_HOSTS);
|
||||||
|
|
||||||
#elif defined(WATT32)
|
#elif defined(WATT32)
|
||||||
extern const char *_w32_GetHostsFile (void);
|
extern const char *_w32_GetHostsFile (void);
|
||||||
|
|
|
@ -220,15 +220,25 @@ static int file_lookup(const char *name, struct hostent **host)
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
|
|
||||||
char PATH_HOSTS[MAX_PATH];
|
char PATH_HOSTS[MAX_PATH];
|
||||||
if (IsNT) {
|
if (IsNT) {
|
||||||
GetSystemDirectory(PATH_HOSTS, MAX_PATH);
|
char tmp[MAX_PATH];
|
||||||
strcat(PATH_HOSTS, PATH_HOSTS_NT);
|
HKEY hkeyHosts;
|
||||||
} else {
|
|
||||||
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
|
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hkeyHosts)
|
||||||
strcat(PATH_HOSTS, PATH_HOSTS_9X);
|
== ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
DWORD dwLength = MAX_PATH;
|
||||||
|
RegQueryValueEx(hkeyHosts, DATABASEPATH, NULL, NULL, tmp,
|
||||||
|
&dwLength);
|
||||||
|
ExpandEnvironmentStrings(tmp, PATH_HOSTS, MAX_PATH);
|
||||||
|
RegCloseKey(hkeyHosts);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
|
||||||
|
|
||||||
|
strcat(PATH_HOSTS, WIN_PATH_HOSTS);
|
||||||
|
|
||||||
#elif defined(WATT32)
|
#elif defined(WATT32)
|
||||||
extern const char *_w32_GetHostsFile (void);
|
extern const char *_w32_GetHostsFile (void);
|
||||||
|
|
|
@ -46,8 +46,8 @@
|
||||||
#define WIN_NS_NT_KEY "System\\CurrentControlSet\\Services\\Tcpip\\Parameters"
|
#define WIN_NS_NT_KEY "System\\CurrentControlSet\\Services\\Tcpip\\Parameters"
|
||||||
#define NAMESERVER "NameServer"
|
#define NAMESERVER "NameServer"
|
||||||
#define DHCPNAMESERVER "DhcpNameServer"
|
#define DHCPNAMESERVER "DhcpNameServer"
|
||||||
#define PATH_HOSTS_NT "\\drivers\\etc\\hosts"
|
#define DATABASEPATH "DatabasePath"
|
||||||
#define PATH_HOSTS_9X "\\hosts"
|
#define WIN_PATH_HOSTS "\\hosts"
|
||||||
|
|
||||||
#elif defined(WATT32)
|
#elif defined(WATT32)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue