From: neilbrown Date: Mon, 12 Dec 2005 03:55:53 +0000 (+0000) Subject: Fix rpc_init so it isn't confused by ssh X-Git-Tag: nfs-utils-1-0-8-rc1~2 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=e36b61ba46d34841a6ad99857c7cc43fc8c1ee89;p=nfs-utils.git Fix rpc_init so it isn't confused by ssh --- diff --git a/ChangeLog b/ChangeLog index 3d8aca2..1557e90 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-12-12 Usha Ketineni , NeilBrown + *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 NeilBrown *utils/idmapd/idmaps.c: diff --git a/support/nfs/rpcmisc.c b/support/nfs/rpcmisc.c index ca63c81..1c02364 100644 --- a/support/nfs/rpcmisc.c +++ b/support/nfs/rpcmisc.c @@ -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; }