]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - support/export/client.c
call gethostbyaddr to make sure that we have canonical hostname
[nfs-utils.git] / support / export / client.c
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) {