2000-10-17 Scott McDermott <mcdermot@questra.com>
authorhjl <hjl>
Wed, 18 Oct 2000 06:16:02 +0000 (06:16 +0000)
committerhjl <hjl>
Wed, 18 Oct 2000 06:16:02 +0000 (06:16 +0000)
* support/export/client.c (client_init): Support CIDR netmask
in /etc/exports.

ChangeLog
support/export/client.c

index 6088634..ab7c336 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2000-10-17  Scott McDermott <mcdermot@questra.com>
+
+       * support/export/client.c (client_init): Support CIDR netmask
+       in /etc/exports.
+
 2000-10-11  H.J. Lu <hjl@lucon.org>
 
        * aclocal.m4 (AC_TCP_WRAPPER): Fix a typo.
index a7f9d02..3afd4f2 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) {