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

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