]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - support/export/client.c
2001-05-06 Anne Milicia <milicia@missioncriticallinux.com>
[nfs-utils.git] / support / export / client.c
index a7f9d020c390a3e6f25643e32ce6cb959281b2da..1fd42697f04ab812f5e6e858d7cc73b9cc32d08a 100644 (file)
@@ -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,12 +239,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;
@@ -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