All of lore.kernel.org
 help / color / mirror / Atom feed
* [NFS][PATCH] Fix to start nfs services through rsh
@ 2005-10-24 18:49 Usha Ketineni
  2005-10-24 23:17 ` James Yarbrough
  0 siblings, 1 reply; 3+ messages in thread
From: Usha Ketineni @ 2005-10-24 18:49 UTC (permalink / raw)
  To: nfs


When issuing "rsh hostname /sbin/service nfs start"
rsh gives the error message "Starting NFS mountd: svc_tcp.c - cannot
getsockname or listen: Invalid argument [FAILED]"

When mountd is invoked by rshd, file descriptor 0 is a socket, hence
getsockname in rpc_init() succeeds so, rpc_init() tries to listen on
that socket in svc_tcp_create(). The socket is a connected socket, but
this code is assuming the socket came from inetd (or xinetd) and listen
& accept can be called to establish a connection.

When mountd is invoked from the command line or sshd, file descriptor 0
is not a socket.

Here is a fix for starting the nfs services through rsh which checks
whether 0 is not a connected socket and if it is, sets socket to
RPC_ANYSOCK so, svc_tcp_create() will create a new socket. 

This patched code assumes that any udp socket, or a tcp socket that is
not connected came from inetd and can be passed to svc_udp_create() or
svc_tcp_create().

Signed-off-by: Usha Ketineni <uketinen@us.ibm.com>

--- nfs-utils-1.0.7.orig/support/nfs/rpcmisc.c	2005-10-24 17:19:07.000000000 -0700
+++ nfs-utils-1.0.7/support/nfs/rpcmisc.c	2005-10-24 18:48:23.000000000 -0700
@@ -53,10 +53,17 @@ rpc_init(char *name, int prog, int vers,
 	if (getsockname(0, (struct sockaddr *) &saddr, &asize) == 0
 	    && saddr.sin_family == AF_INET) {
 		int ssize = sizeof (int);
-		_rpcfdtype = 0;
+		int tmp_rpcfdtype = 0;
 		if (getsockopt(0, SOL_SOCKET, SO_TYPE,
 				(char *)&_rpcfdtype, &ssize) == -1)
 			xlog(L_FATAL, "getsockopt failed: %s", strerror(errno));
+		if (_rpcfdtype != SOCK_STREAM || listen(0,5) != -1) {
+			_rpcpmstart = 1;
+			_rpcfdtype = tmp_rpcfdtype;
+		} else {
+			sock = RPC_ANYSOCK;
+			pmap_unset(prog, vers);
+		}
 		_rpcpmstart = 1;
 	} else {
 		pmap_unset(prog, vers);




-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-10-25  2:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-10-24 18:49 [NFS][PATCH] Fix to start nfs services through rsh Usha Ketineni
2005-10-24 23:17 ` James Yarbrough
2005-10-25  2:19   ` Usha Ketineni

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.