]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
mountd: Support IPv6 in mountlist_list()
authorChuck Lever <chuck.lever@oracle.com>
Thu, 16 Sep 2010 17:54:21 +0000 (13:54 -0400)
committerSteve Dickson <steved@redhat.com>
Thu, 16 Sep 2010 18:33:51 +0000 (14:33 -0400)
Replace inet_aton(3) and gethostbyaddr(3) calls in mountlist_list()
with calls to the new host_foo() DNS helpers.

The new functions will support IPv6 without additional changes, once
IPv6 is enabled in the generic hostname helpers.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
utils/mountd/rmtab.c

index cd6abc8823c59f340181690c202d2017a4f8a178..d3392968ab6b4c18b3422f9f7edf6c693b17d9c0 100644 (file)
@@ -194,8 +194,6 @@ mountlist_list(void)
        struct rmtabent         *rep;
        struct stat             stb;
        int                     lockid;
-       struct in_addr          addr;
-       struct hostent          *he;
 
        if ((lockid = xflock(_PATH_RMTABLCK, "r")) < 0)
                return NULL;
@@ -220,11 +218,15 @@ mountlist_list(void)
                                break;
                        }
 
-                       if (reverse_resolve &&
-                          inet_aton((const char *) rep->r_client, &addr) &&
-                          (he = gethostbyaddr(&addr, sizeof(addr), AF_INET)))
-                               m->ml_hostname = strdup(he->h_name);
-                       else
+                       if (reverse_resolve) {
+                               struct addrinfo *ai;
+                               ai = host_pton(rep->r_client);
+                               if (ai != NULL) {
+                                       m->ml_hostname = host_canonname(ai->ai_addr);
+                                       freeaddrinfo(ai);
+                               }
+                       }
+                       if (m->ml_hostname == NULL)
                                m->ml_hostname = strdup(rep->r_client);
 
                        m->ml_directory = strdup(rep->r_path);