From 865a1070166deac80930229cd97bb7f99482a340 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Mon, 18 Dec 2006 15:43:16 -0500 Subject: [PATCH] Don't rely on old info in my_client 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 Signed-off-by: Neil Brown --- utils/mountd/auth.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/utils/mountd/auth.c b/utils/mountd/auth.c index 44d9980..4f803d7 100644 --- a/utils/mountd/auth.c +++ b/utils/mountd/auth.c @@ -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; -- 2.39.5