X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=support%2Fexport%2Fclient.c;h=1fd42697f04ab812f5e6e858d7cc73b9cc32d08a;hp=8c5200af10ef36aba828ca74d89f9d7a8ba88dd7;hb=86ae664e66c439354cb4f959e9f289059e7760a4;hpb=8b7ad01b14df1e7529b9ba8a1ea17df0d6004ef9 diff --git a/support/export/client.c b/support/export/client.c index 8c5200a..1fd4269 100644 --- a/support/export/client.c +++ b/support/export/client.c @@ -118,7 +118,20 @@ client_init(nfs_client *clp, const char *hname, struct hostent *hp) *cp = '\0'; clp->m_addrlist[0].s_addr = inet_addr(clp->m_hostname); - clp->m_addrlist[1].s_addr = inet_addr(cp+1); + if (strchr(cp + 1, '.')) { + clp->m_addrlist[1].s_addr = inet_addr(cp+1); + } + else { + int netmask = atoi(cp + 1); + if (0 < netmask && netmask <= 32) { + clp->m_addrlist[1].s_addr = + htonl ((uint32_t) ~0 << (32 - netmask)); + } + else { + xlog(L_FATAL, "invalid netmask `%s' for %s", + cp + 1, clp->m_hostname); + } + } *cp = '/'; clp->m_naddr = 0; } else if (!hp) { @@ -226,18 +239,29 @@ 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; *dot = '\0'; - match = innetgr(cname+1, hname, NULL, dot + 1); + match = innetgr(cname+1, hname, NULL, NULL); *dot = '.'; return match; @@ -278,7 +302,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