X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=support%2Fexport%2Fclient.c;h=076b0c069dd1ff2991d374ee8c498087601321e8;hp=3afd4f2940c0455af93975d55b39590a09389b0f;hb=4d961554071d2308017062c8bc39f37f5de55b5f;hpb=a19d80373216f3257c1b5ef59e41279f94744377 diff --git a/support/export/client.c b/support/export/client.c index 3afd4f2..076b0c0 100644 --- a/support/export/client.c +++ b/support/export/client.c @@ -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) { @@ -239,12 +249,23 @@ client_check(nfs_client *clp, struct hostent *hp) { char *dot; int match; + struct hostent *nhp = NULL; + struct sockaddr_in addr; /* First, try to match the hostname without * splitting off the domain */ if (innetgr(cname+1, hname, NULL, NULL)) return 1; + /* If hname is ip address convert to FQDN */ + if (inet_aton(hname, &addr.sin_addr) && + (nhp = gethostbyaddr((const char *)&(addr.sin_addr), + sizeof(addr.sin_addr), AF_INET))) { + hname = (char *)nhp->h_name; + if (innetgr(cname+1, hname, NULL, NULL)) + return 1; + } + /* Okay, strip off the domain (if we have one) */ if ((dot = strchr(hname, '.')) == NULL) return 0; @@ -291,7 +312,7 @@ client_gettype(char *ident) { char *sp; - if (ident[0] == '\0') + if (ident[0] == '\0' || strcmp(ident, "*")==0) return MCL_ANONYMOUS; if (ident[0] == '@') { #ifndef HAVE_INNETGR