From 8de48f3093a0e84bb732b24e7355780368f25a67 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Tue, 22 Apr 2003 07:28:41 +0000 Subject: Make our 'get DNS domain name' code try a bit harder - if gethostname() doesn't include a domain portion, do a gethostbyname() lookup on that name. Use this name in our PolicyPrimaryDomainInformation reply (_lsa_query_info2) that Win2k uses when trying to trust us as a trusted domain. (We need to do a better mapping between our Netbios and Win2k domain names, but this will do for now - particularly annoying is the way this possibly needs to map with our kerberos realm). Andrew Bartlett (This used to be commit 3be03271030208a69da29c6e2a7b92cdbaa8c6aa) --- source3/lib/util.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'source3/lib/util.c') diff --git a/source3/lib/util.c b/source3/lib/util.c index 1adda85354..e58f5274df 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1012,6 +1012,7 @@ BOOL get_mydomname(fstring my_domname) { pstring hostname; char *p; + struct hostent *hp; *hostname = 0; /* get my host name */ @@ -1023,17 +1024,31 @@ BOOL get_mydomname(fstring my_domname) /* Ensure null termination. */ hostname[sizeof(hostname)-1] = '\0'; + p = strchr_m(hostname, '.'); - if (!p) - return False; + if (p) { + p++; + + if (my_domname) + fstrcpy(my_domname, p); + } - p++; + if (!(hp = sys_gethostbyname(hostname))) { + return False; + } - if (my_domname) - fstrcpy(my_domname, p); + p = strchr_m(hp->h_name, '.'); - return True; + if (p) { + p++; + + if (my_domname) + fstrcpy(my_domname, p); + return True; + } + + return False; } /**************************************************************************** -- cgit