Commit 5ac2f4b5 authored by Alexandre Julliard's avatar Alexandre Julliard

wineboot: Fall back to initial hostname if the name lookup fails.

parent df0c5d23
...@@ -820,18 +820,18 @@ static void create_environment_registry_keys( void ) ...@@ -820,18 +820,18 @@ static void create_environment_registry_keys( void )
static void create_computer_name_keys(void) static void create_computer_name_keys(void)
{ {
struct addrinfo hints = {0}, *res; struct addrinfo hints = {0}, *res;
char *dot, buffer[256]; char *dot, buffer[256], *name = buffer;
HKEY key, subkey; HKEY key, subkey;
if (gethostname( buffer, sizeof(buffer) )) return; if (gethostname( buffer, sizeof(buffer) )) return;
hints.ai_flags = AI_CANONNAME; hints.ai_flags = AI_CANONNAME;
if (getaddrinfo( buffer, NULL, &hints, &res )) return; if (!getaddrinfo( buffer, NULL, &hints, &res )) name = res->ai_canonname;
dot = strchr( res->ai_canonname, '.' ); dot = strchr( name, '.' );
if (dot) *dot++ = 0; if (dot) *dot++ = 0;
else dot = res->ai_canonname + strlen(res->ai_canonname); else dot = name + strlen(name);
SetComputerNameExA( ComputerNamePhysicalDnsDomain, dot ); SetComputerNameExA( ComputerNamePhysicalDnsDomain, dot );
SetComputerNameExA( ComputerNamePhysicalDnsHostname, res->ai_canonname ); SetComputerNameExA( ComputerNamePhysicalDnsHostname, name );
freeaddrinfo( res ); if (name != buffer) freeaddrinfo( res );
if (RegOpenKeyW( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\ComputerName", &key )) if (RegOpenKeyW( HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\ComputerName", &key ))
return; return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment