From 0be1e825d606cc5715620fd702f9a921b8646375 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Sun, 11 Jan 2004 01:29:03 +0000 Subject: [PATCH] Problem: When an NFS server is port-scanned nfsd sometimes exits. This has happened 3 times the last few weeks. Nfsd has been written to exit when accept(2) fails. Unfortunately accept can sometimes make a "normal" return with errno ECONNABORTED and in this case nfsd exits prematurely. Solution: Check for ECONNABORTED (and also EINTR, since nfsd uses signals) and continue. Submitted by: Bjoern Groenvall PR: 61084 --- usr.sbin/nfsd/nfsd.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/usr.sbin/nfsd/nfsd.c b/usr.sbin/nfsd/nfsd.c index fcf53db97c28..c8f3a420f261 100644 --- a/usr.sbin/nfsd/nfsd.c +++ b/usr.sbin/nfsd/nfsd.c @@ -658,6 +658,8 @@ main(argc, argv, envp) if (select(maxsock + 1, &ready, NULL, NULL, NULL) < 1) { syslog(LOG_ERR, "select failed: %m"); + if (errno == EINTR) + continue; nfsd_exit(1); } } @@ -668,6 +670,9 @@ main(argc, argv, envp) if ((msgsock = accept(tcpsock, (struct sockaddr *)&inetpeer, &len)) < 0) { syslog(LOG_ERR, "accept failed: %m"); + if (errno == ECONNABORTED || + errno == EINTR) + continue; nfsd_exit(1); } memset(inetpeer.sin_zero, 0, @@ -688,6 +693,9 @@ main(argc, argv, envp) &len)) < 0) { syslog(LOG_ERR, "accept failed: %m"); + if (errno == ECONNABORTED || + errno == EINTR) + continue; nfsd_exit(1); } if (setsockopt(msgsock, SOL_SOCKET,