]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
Don't rely on old info in my_client
authorJeff Layton <jlayton@redhat.com>
Mon, 18 Dec 2006 20:43:16 +0000 (15:43 -0500)
committerNeil Brown <neilb@suse.de>
Mon, 18 Dec 2006 22:22:30 +0000 (09:22 +1100)
Here's a new set of patches to fix up "showmount -a", based on the approach
suggested by Neil. This first patch is fairly simple. It just stops
the current caching of my_client.

For an explanation, consider this situation with the current code:

1) Client mounts an NFS export from server that is restricted to a particular
hostname or netgroup.

2) DNS or netgroup changes so that the client would be denied.

3) Client attempts mount again. Mount succeeds, even though it shouldn't due
to the fact that mountd relies on cached info in my_client.

This situation can occur as long as no other client attempts a mount between
1 and 3 above. The patch below removes this caching, and causes a new
invocation of client_compose for each pass through auth_authenticate:

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Neil Brown <neilb@suse.de>
utils/mountd/auth.c

index 44d998016559c30057e6166a2b67267a69c9c9c6..4f803d7aa0511bac1e9c9fc163ee278dca25220d 100644 (file)
@@ -76,21 +76,15 @@ auth_authenticate_internal(char *what, struct sockaddr_in *caller,
        if (new_cache) {
                int i;
                /* return static nfs_export with details filled in */
-               if (my_client.m_naddr != 1 ||
-                   my_client.m_addrlist[0].s_addr != caller->sin_addr.s_addr) {
-                       /* different client to last time, so do a lookup */
-                       char *n;
-                       my_client.m_naddr = 0;
-                       my_client.m_addrlist[0] = caller->sin_addr;
-                       n = client_compose(caller->sin_addr);
-                       *error = unknown_host;
-                       if (!n)
-                               return NULL;
-                       strcpy(my_client.m_hostname, *n?n:"DEFAULT");
-                       free(n);
-                       my_client.m_naddr = 1;
-               }
-
+               char *n;
+               my_client.m_addrlist[0] = caller->sin_addr;
+               n = client_compose(caller->sin_addr);
+               *error = unknown_host;
+               if (!n)
+                       return NULL;
+               strcpy(my_client.m_hostname, *n?n:"DEFAULT");
+               free(n);
+               my_client.m_naddr = 1;
                my_exp.m_client = &my_client;
 
                exp = NULL;