]> git.decadent.org.uk Git - nfs-utils.git/commitdiff
Fix rpc_init so it isn't confused by ssh
authorneilbrown <neilbrown>
Mon, 12 Dec 2005 03:55:53 +0000 (03:55 +0000)
committerneilbrown <neilbrown>
Mon, 12 Dec 2005 03:55:53 +0000 (03:55 +0000)
ChangeLog
support/nfs/rpcmisc.c

index 3d8aca2ca9e38f306cf623e731142ac3c688a1f2..1557e9074fa80a2099cbd4e84f4b46175ba06704 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-12-12 Usha Ketineni <ketineni@us.ibm.com>, NeilBrown <neilb@suse.de>
+       *support/nfs/rpcmisc.c(rpc_init): is stdin is a socket, but
+       is already connected (as e.g. from ssh), don't assume we
+       were started by inetd.
+
 2005-11-03 Steve Dickson <SteveD@redhat.com> NeilBrown <neilb@suse.de>
        *utils/idmapd/idmaps.c:
        
index ca63c8142975940557ba6ed9470e594d720f284a..1c02364cecb153e6f33886b3b40499d97268d4ea 100644 (file)
@@ -53,12 +53,19 @@ rpc_init(char *name, int prog, int vers, void (*dispatch)(), int defport)
        if (getsockname(0, (struct sockaddr *) &saddr, &asize) == 0
            && saddr.sin_family == AF_INET) {
                int ssize = sizeof (int);
-               _rpcfdtype = 0;
+               int fdtype = 0;
                if (getsockopt(0, SOL_SOCKET, SO_TYPE,
-                               (char *)&_rpcfdtype, &ssize) == -1)
+                               (char *)&fdtype, &ssize) == -1)
                        xlog(L_FATAL, "getsockopt failed: %s", strerror(errno));
-               _rpcpmstart = 1;
-       } else {
+               /* inetd passes a UDP socket or a listening TCP socket.
+                * listen will fail on a connected TCP socket(passed by rsh).
+                */
+               if (!(fdtype == SOCK_STREAM && listen(0,5) == -1)) {
+                       _rpcfdtype = fdtype;
+                       _rpcpmstart = 1;
+               }
+       }
+       if (!_rpcpmstart) {
                pmap_unset(prog, vers);
                sock = RPC_ANYSOCK;
        }