Subject: Potential patch for hanging sockets

From: Dan Thorson <[email-masked]>
Date: 3 May 95 13:04:43 EDT

Hi,
Here's a diff -e for what I did.  It's (as yet) untested, but it looks like
it should work.  I've not tested it cuz I would have to make my main ftp site
the "beta" test!  If somebody's got a system they can try this out on, that'd
be cool.  The comments within the patch have stuff for testing the bug.

The file is "ftpd.c" from the wustl-ftpd release v2.4.

Question:
Is anybody making "official" patches to 2.4?  This is a serious enough problem
(and seems easy enough to fix) that it should become "official".  The docs
w/2.4 say that Wash Univ isn't planing on doing anything more to it (something
about working on 3.x, I guess).

Dan T

p.s. Your comments appreciated!

Here's the diff ---------------------------------------------------------------
{aegis} diff -e ftpd.c ftpd-dan.c
1709a
        { /* D. Thorson hack - */
          /*    Establish a timeout for PASV mode clients who never actually */
          /*    connect.  This should help reduce the number "zombie"        */
          /*    processes and open sockets.  This problem was first seen (by */
          /*    Dan) on a Sun SPARC-1+ running SunOS 4.1.3_U1.               */
          /* Problem replication:                                            */
          /*    type the following:                                          */
          /*       telnet thishost 21                                        */
          /*       user anonymous                                            */
          /*       pass me@thishost                                          */
          /*       pasv                  <- port is defined on server        */
          /*       list                  <- request is made & port opened    */
          /*    If you now ^]-z out of telnet, and type:                     */
          /*       netstat -fn inet | grep <port-number-returned-from-pasv>  */
          /*    you'll see the open connection.  The high numbered open port */
          /*    may be cleared by typing:                                    */
          /*       telnet thishost <pasv-port-number>                        */
          /*                                                                 */
            fd_set fds;
            struct timeval timeout_str;
            int status;
            timeout_str.tv_sec = 120;
            timeout_str.tv_usec= 0;
            FD_ZERO(&fds);
            FD_SET(pdata, &fds);
            status = select(1, &fds, NULL, NULL, &timeout_str);
            if (status <= 0) {
                if (status == 0)    /* timeout during select() */
                    reply(421, "Timeout (%d sec): closing data connection.", 
                                                   timeout_str.tv_sec);
                else                /* misc error from select() */
                    perror_reply(451, "Local resource failure: select()");
                (void) close(pdata);
                pdata = -1;
                return (NULL);
            }
        }

---

From: [email-masked] (NW Hinkle-DeGroot)
Date: Fri, 5 May 1995 09:06:31 -0400

> Date: Wed, 3 May 1995 13:58:27 CDT
> From: [email-masked] (Stan Barber)
> To: [email-masked]
> Subject: Re: Potential patch for hanging sockets
> X-Listprocessor-Version: 7.1 -- ListProcessor by CREN
> 
> I'd be happy to maintain an official patch site for 2.4 if folks are interested
> in seeing that done.
> 
> -- 
> Stan   | Academ Consulting Services        |internet: [email-masked]
> Olan   | For more info on academ, see this |uucp: bcm!academ!sob
> Barber | URL- http://www.academ.com/academ |Opinions expressed are only mine.

I'm interested in an official patch site. I see a variety of patch levels all
over the net. Is there a list of recommended patches or fixes somewhere?

Thanks.

/Nick
+-------------- "For with much wisdom comes much sorrow; ----------------+
| Nicholas Hinkle-De Groot             http://www.isr.umich.edu/~nhinkle |
| Institute for Social Research, SRC              University of Michigan |
+----------- the more knowledge, the more grief." Ecc 1:18 --------------+