summaryrefslogtreecommitdiffstats
path: root/source/lib/util.c
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2006-10-01 21:20:14 +0000
committerGerald Carter <jerry@samba.org>2006-10-01 21:20:14 +0000
commit6cd6987fc504a8056295113c12f629ad5c4b2868 (patch)
tree1cb4088f4b88d086f5b0bc84ffa99aa3c537e0b2 /source/lib/util.c
parent2f4cccbf3b63db498bde48679c228747f1838f91 (diff)
downloadsamba-6cd6987fc504a8056295113c12f629ad5c4b2868.tar.gz
samba-6cd6987fc504a8056295113c12f629ad5c4b2868.tar.xz
samba-6cd6987fc504a8056295113c12f629ad5c4b2868.zip
r19018: staging for a 3.0.23d on Tuesday (I think we have sufficient changes to warrant one)
Diffstat (limited to 'source/lib/util.c')
-rw-r--r--source/lib/util.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/source/lib/util.c b/source/lib/util.c
index a1efecfbbba..12be5bc6c04 100644
--- a/source/lib/util.c
+++ b/source/lib/util.c
@@ -2828,9 +2828,36 @@ BOOL unix_wild_match(const char *pattern, const char *string)
void name_to_fqdn(fstring fqdn, const char *name)
{
struct hostent *hp = sys_gethostbyname(name);
+
if ( hp && hp->h_name && *hp->h_name ) {
- DEBUG(10,("name_to_fqdn: lookup for %s -> %s.\n", name, hp->h_name));
- fstrcpy(fqdn,hp->h_name);
+ char *full = NULL;
+
+ /* find out if the fqdn is returned as an alias
+ * to cope with /etc/hosts files where the first
+ * name is not the fqdn but the short name */
+ if (hp->h_aliases && (! strchr_m(hp->h_name, '.'))) {
+ int i;
+ for (i = 0; hp->h_aliases[i]; i++) {
+ if (strchr_m(hp->h_aliases[i], '.')) {
+ full = hp->h_aliases[i];
+ break;
+ }
+ }
+ }
+ if (full && (StrCaseCmp(full, "localhost.localdomain") == 0)) {
+ DEBUG(1, ("WARNING: your /etc/hosts file may be broken!\n"));
+ DEBUGADD(1, (" Specifing the machine hostname for address 127.0.0.1 may lead\n"));
+ DEBUGADD(1, (" to Kerberos authentication probelms as localhost.localdomain\n"));
+ DEBUGADD(1, (" may end up being used instead of the real machine FQDN.\n"));
+ full = hp->h_name;
+ }
+
+ if (!full) {
+ full = hp->h_name;
+ }
+
+ DEBUG(10,("name_to_fqdn: lookup for %s -> %s.\n", name, full));
+ fstrcpy(fqdn, full);
} else {
DEBUG(10,("name_to_fqdn: lookup for %s failed.\n", name));
fstrcpy(fqdn, name);
@@ -2987,4 +3014,3 @@ int this_is_smp(void)
return 0;
#endif
}
-