]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
call gethostbyaddr to make sure that we have canonical hostname
authorneilbrown <neilbrown>
Thu, 20 Sep 2001 00:10:49 +0000 (00:10 +0000)
committerneilbrown <neilbrown>
Thu, 20 Sep 2001 00:10:49 +0000 (00:10 +0000)
for all exports

ChangeLog
support/export/client.c
utils/exportfs/exportfs.c

index 2dc842f1d79d1479f3ff89cd8458c0c86dfcd2d8..3826e5eccdbe945aafdeef52d0adbf264ed1a00f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2001-09020 NeilBrown <neilb@cse.unsw.edu.au>
+           Anne Milicia <milicia@missioncriticallinux.com>
+
+       * 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 <neilb@cse.unsw.edu.au>
 
        * support/nfs/exports.c (putexportent): \octal quote any spaces
index 1fd42697f04ab812f5e6e858d7cc73b9cc32d08a..076b0c069dd1ff2991d374ee8c498087601321e8 100644 (file)
@@ -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) {
index 050470987c8e8ec883715a9fd44033ed92816940..c012961871cd86bc4d96d9d4d992c986c47780a9 100644 (file)
@@ -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);