You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Tony Finch <do...@dotat.at> on 2000/07/07 05:14:36 UTC

more 1.3 ServerName gripes

OK, maybe my configuration is screwy, but I'm being bitten by this
code in find_fqdn() in util.c:

    if (!strchr(p->h_name, '.')) {
	for (x = 0; p->h_aliases[x]; ++x) {
	    if (strchr(p->h_aliases[x], '.') &&
		(!strncasecmp(p->h_aliases[x], p->h_name, strlen(p->h_name))))
		return ap_pstrdup(a, p->h_aliases[x]);
	    }
	}
	return NULL;
    }
    return ap_pstrdup(a, (void *) p->h_name);

On my laptop hand.dotat.at I have arranged for the hostname to usually
resolve to 127.0.0.1 so that things work OK when the net isn't there;
a reverse lookup of 127.0.0.1 returns the primary name "localhost" and
the aliases "hand" and "hand.dotat.at". Obviously I would like
find_fqdn() to return "hand.dotat.at" but the strncasecmp() prevents
this.

I want to remove it; can anyone think of a reason why I shouldn't?

Tony.
-- 
f.a.n.finch    fanf@covalent.net    dot@dotat.at
415 increasingly frequent forays into flaccidity

RE: more 1.3 ServerName gripes

Posted by "William A. Rowe, Jr." <wr...@lnd.com>.
> From: Tony Finch [mailto:dot@dotat.at]
> Sent: Thursday, July 06, 2000 10:15 PM
> 
> OK, maybe my configuration is screwy, but I'm being bitten by this
> code in find_fqdn() in util.c:
> 
>     if (!strchr(p->h_name, '.')) {
> 	for (x = 0; p->h_aliases[x]; ++x) {
> 	    if (strchr(p->h_aliases[x], '.') &&
> 		(!strncasecmp(p->h_aliases[x], p->h_name, strlen(p->h_name))))
> 		return ap_pstrdup(a, p->h_aliases[x]);
> 	    }
> 	}
> 	return NULL;
>     }
>     return ap_pstrdup(a, (void *) p->h_name);
> 
> On my laptop hand.dotat.at I have arranged for the hostname to usually
> resolve to 127.0.0.1 so that things work OK when the net isn't there;
> a reverse lookup of 127.0.0.1 returns the primary name "localhost" and
> the aliases "hand" and "hand.dotat.at". Obviously I would like
> find_fqdn() to return "hand.dotat.at" but the strncasecmp() prevents
> this.
> 
> I want to remove it; can anyone think of a reason why I shouldn't?

Yes... I'd look at a patch like this instead:

    if (!strchr(p->h_name, '.')) {
      for (x = 0; p->h_aliases[x]; ++x) {
        if (strchr(p->h_aliases[x], '.') &&
            (!strncasecmp(p->h_aliases[x], p->h_name, strlen(p->h_name))))
           return ap_pstrdup(a, p->h_aliases[x]);
      }
      for (x = 0; p->h_aliases[x]; ++x) {
        if (strchr(p->h_aliases[x], '.'))
           return ap_pstrdup(a, p->h_aliases[x]);
      }
    }

This way, if you had a localhost.dotat.at - then it would pick it up as
the primary preference.  Since you don't, it will pick up the first dotted
alias it can find.