X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=support%2Fexport%2Fclient.c;h=03f791721774b5937642cf83d150a8c8442636f4;hp=1fd42697f04ab812f5e6e858d7cc73b9cc32d08a;hb=0bd51f4c931eb68c355140c721763be64213a3ca;hpb=86ae664e66c439354cb4f959e9f289059e7760a4 diff --git a/support/export/client.c b/support/export/client.c index 1fd4269..03f7917 100644 --- a/support/export/client.c +++ b/support/export/client.c @@ -32,8 +32,12 @@ static int client_checkaddr(nfs_client *clp, struct in_addr addr); nfs_client *clientlist[MCL_MAXTYPES] = { NULL, }; +/* if canonical is set, then we *know* this is already a canonical name + * so hostname lookup is avoided. + * This is used when reading /proc/fs/nfs/exports + */ nfs_client * -client_lookup(char *hname) +client_lookup(char *hname, int canonical) { nfs_client *clp = NULL; int htype; @@ -41,13 +45,23 @@ client_lookup(char *hname) htype = client_gettype(hname); - if (htype == MCL_FQDN) { + if (htype == MCL_FQDN && !canonical) { + 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) { @@ -56,7 +70,7 @@ client_lookup(char *hname) } } else { for (clp = clientlist[htype]; clp; clp = clp->m_next) { - if (strcmp(hname, clp->m_hostname)==0) + if (strcasecmp(hname, clp->m_hostname)==0) break; } }