X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmountd%2Frmtab.c;h=527377f8cd408c3e5899ab6040e295e76a69ea78;hp=cd6abc8823c59f340181690c202d2017a4f8a178;hb=014e00dfaea0efc92150e2aedc5ca43aa337545e;hpb=76209cdbe989ee4cdfbf489f2695ac779457e763 diff --git a/utils/mountd/rmtab.c b/utils/mountd/rmtab.c index cd6abc8..527377f 100644 --- a/utils/mountd/rmtab.c +++ b/utils/mountd/rmtab.c @@ -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; @@ -207,6 +205,7 @@ mountlist_list(void) } if (stb.st_mtime != last_mtime) { mountlist_freeall(mlist); + mlist = NULL; last_mtime = stb.st_mtime; setrmtabent("r"); @@ -220,11 +219,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);