From: neilbrown Date: Thu, 20 Sep 2001 00:10:49 +0000 (+0000) Subject: call gethostbyaddr to make sure that we have canonical hostname X-Git-Tag: nfs-utils-0-3-2-pre9~1 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=4d961554071d2308017062c8bc39f37f5de55b5f;p=nfs-utils.git call gethostbyaddr to make sure that we have canonical hostname for all exports --- diff --git a/ChangeLog b/ChangeLog index 2dc842f..3826e5e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2001-09020 NeilBrown + Anne Milicia + + * support/export/client.c (client_lookup) call gethostbyadd + to make sure that we have a canonical hostname, even for + dotted-quads + * utils/exportfs/exportfs.c (exportfs) Likewise + 2001-09-12 NeilBrown * support/nfs/exports.c (putexportent): \octal quote any spaces diff --git a/support/export/client.c b/support/export/client.c index 1fd4269..076b0c0 100644 --- a/support/export/client.c +++ b/support/export/client.c @@ -42,12 +42,22 @@ client_lookup(char *hname) htype = client_gettype(hname); if (htype == MCL_FQDN) { + struct hostent *hp2; hp = gethostbyname(hname); if (hp == NULL || hp->h_addrtype != AF_INET) { xlog(L_ERROR, "%s has non-inet addr", hname); return NULL; } - hp = hostent_dup (hp); + /* make sure we have canonical name */ + hp2 = hostent_dup(hp); + hp = gethostbyaddr(hp2->h_addr, hp2->h_length, + hp2->h_addrtype); + if (hp) { + free(hp2); + hp = hostent_dup(hp); + } else + hp = hp2; + hname = (char *) hp->h_name; for (clp = clientlist[htype]; clp; clp = clp->m_next) { diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c index 0504709..c012961 100644 --- a/utils/exportfs/exportfs.c +++ b/utils/exportfs/exportfs.c @@ -228,7 +228,14 @@ exportfs(char *arg, char *options, int verbose) if ((htype = client_gettype(hname)) == MCL_FQDN && (hp = gethostbyname(hname)) != NULL) { - hp = hostent_dup (hp); + struct hostent *hp2 = hostent_dup (hp); + hp = gethostbyaddr(hp2->h_addr, hp2->h_length, + hp2->h_addrtype); + if (hp) { + free(hp2); + hp = hostent_dup(hp); + } else + hp = hp2; exp = export_find(hp, path); } else { exp = export_lookup(hname, path);