svn commit: samba r16997 - branches/SAMBA_3_0/source/lib
trunk/source/lib
jerry at samba.org
jerry at samba.org
Wed Jul 12 21:02:23 GMT 2006
Author: jerry
Date: 2006-07-12 21:02:22 +0000 (Wed, 12 Jul 2006)
New Revision: 16997
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16997
Log:
Simo's patch (based on repotr from Seth Elssworth of Quest) to try to be more robust in the precense of more broken /etc/hosts files when determining our fwdn
Modified:
branches/SAMBA_3_0/source/lib/util.c
trunk/source/lib/util.c
Changeset:
Modified: branches/SAMBA_3_0/source/lib/util.c
===================================================================
--- branches/SAMBA_3_0/source/lib/util.c 2006-07-12 20:16:44 UTC (rev 16996)
+++ branches/SAMBA_3_0/source/lib/util.c 2006-07-12 21:02:22 UTC (rev 16997)
@@ -2830,9 +2830,28 @@
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 i fthe 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) {
+ 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);
Modified: trunk/source/lib/util.c
===================================================================
--- trunk/source/lib/util.c 2006-07-12 20:16:44 UTC (rev 16996)
+++ trunk/source/lib/util.c 2006-07-12 21:02:22 UTC (rev 16997)
@@ -2830,9 +2830,28 @@
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 i fthe 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) {
+ 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);
More information about the samba-cvs
mailing list