Blame SOURCES/autofs-5.1.1-fix-create_client-RPC-client-handling.patch

306fa1
autofs-5.1.1 - fix create_client() RPC client handling
306fa1
306fa1
From: Ian Kent <raven@themaw.net>
306fa1
306fa1
The autofs socket minimization strategy is to reuse the socket
306fa1
descriptor when creating an RPC client for the same protocol.
306fa1
306fa1
But in create_client() there is a case where the socket descriptor
306fa1
can be obtained from RPC client, the RPC client destroyed, but
306fa1
not cleared in the persistent data structure.
306fa1
306fa1
In create_client(), once an attempt is done to get the socket
306fa1
descriptor, the RPC client should always be destroyed and cleared
306fa1
in the persistent data structure.
306fa1
306fa1
Signed-off-by: Ian Kent <raven@themaw.net>
306fa1
---
306fa1
 CHANGELOG      |    1 +
306fa1
 lib/rpc_subs.c |   21 ++++++++-------------
306fa1
 2 files changed, 9 insertions(+), 13 deletions(-)
306fa1
306fa1
--- autofs-5.0.7.orig/CHANGELOG
306fa1
+++ autofs-5.0.7/CHANGELOG
306fa1
@@ -295,6 +295,7 @@
306fa1
 - fix prefix option handling in expand_entry().
306fa1
 - fix sublink option not set from defaults.
306fa1
 - fix error return in do_nfs_mount().
306fa1
+- fix create_client() RPC client handling.
306fa1
 
306fa1
 25/07/2012 autofs-5.0.7
306fa1
 =======================
306fa1
--- autofs-5.0.7.orig/lib/rpc_subs.c
306fa1
+++ autofs-5.0.7/lib/rpc_subs.c
306fa1
@@ -663,14 +663,12 @@ static int create_client(struct conn_inf
306fa1
 	*client = NULL;
306fa1
 
306fa1
 	if (info->client) {
306fa1
-		if (!clnt_control(info->client, CLGET_FD, (char *) &fd)) {
306fa1
-			fd = RPC_ANYSOCK;
306fa1
-			clnt_destroy(info->client);
306fa1
-			info->client = NULL;
306fa1
-		} else {
306fa1
+		if (clnt_control(info->client, CLGET_FD, (char *) &fd))
306fa1
 			clnt_control(info->client, CLSET_FD_NCLOSE, NULL);
306fa1
-			clnt_destroy(info->client);
306fa1
-		}
306fa1
+		else
306fa1
+			fd = RPC_ANYSOCK;
306fa1
+		clnt_destroy(info->client);
306fa1
+		info->client = NULL;
306fa1
 	}
306fa1
 
306fa1
 	if (info->addr) {
306fa1
@@ -686,7 +684,7 @@ static int create_client(struct conn_inf
306fa1
 			goto out_close;
306fa1
 		}
306fa1
 
306fa1
-		if (!info->client && fd != RPC_ANYSOCK) {
306fa1
+		if (fd != RPC_ANYSOCK) {
306fa1
 			close(fd);
306fa1
 			fd = RPC_ANYSOCK;
306fa1
 		}
306fa1
@@ -704,7 +702,6 @@ static int create_client(struct conn_inf
306fa1
 	if (ret) {
306fa1
 		error(LOGOPT_ANY,
306fa1
 		      "hostname lookup failed: %s", gai_strerror(ret));
306fa1
-		info->client = NULL;
306fa1
 		goto out_close;
306fa1
 	}
306fa1
 
306fa1
@@ -723,7 +720,7 @@ static int create_client(struct conn_inf
306fa1
 			goto out_close;
306fa1
 		}
306fa1
 
306fa1
-		if (!info->client && fd != RPC_ANYSOCK) {
306fa1
+		if (fd != RPC_ANYSOCK) {
306fa1
 			close(fd);
306fa1
 			fd = RPC_ANYSOCK;
306fa1
 		}
306fa1
@@ -735,7 +732,6 @@ static int create_client(struct conn_inf
306fa1
 
306fa1
 done:
306fa1
 	if (!*client) {
306fa1
-		info->client = NULL;
306fa1
 		ret = -ENOTCONN;
306fa1
 		goto out_close;
306fa1
 	}
306fa1
@@ -743,7 +739,6 @@ done:
306fa1
 	/* Close socket fd on destroy, as is default for rpcowned fds */
306fa1
 	if  (!clnt_control(*client, CLSET_FD_CLOSE, NULL)) {
306fa1
 		clnt_destroy(*client);
306fa1
-		info->client = NULL;
306fa1
 		ret = -ENOTCONN;
306fa1
 		goto out_close;
306fa1
 	}
306fa1
@@ -751,7 +746,7 @@ done:
306fa1
 	return 0;
306fa1
 
306fa1
 out_close:
306fa1
-	if (fd != -1)
306fa1
+	if (fd != RPC_ANYSOCK)
306fa1
 		close(fd);
306fa1
 	return ret;
306fa1
 }