Subject: Re: Academ version of wu-ftpd 2.4 Release 2 Beta 9 available for testing

From: Dave Alden <[email-masked]>
Date: Fri, 9 Feb 1996 14:23:48 -0500 (EST)

Hi,

> BETA 9 is now available. It has been tested on the following systems:

The virtual patches need one small patch.  If you use "guest" accounts and
virtual mode, the "guest" accounts will always be placed into the virtual
root.

...dave

*** ftpd.c.ORIG	Tue Jan 23 01:09:11 1996
--- ftpd.c	Fri Feb  9 14:21:50 1996
***************
*** 1346,1352 ****
          /* We MUST do a chdir() after the chroot. Otherwise the old current
           * directory will be accessible as "." outside the new root! */
  #ifdef VIRTUAL
!       if (virtual_mode) {
          strcpy(pw->pw_dir, virtual_root);
        }
  #endif 
--- 1346,1352 ----
          /* We MUST do a chdir() after the chroot. Otherwise the old current
           * directory will be accessible as "." outside the new root! */
  #ifdef VIRTUAL
!       if (virtual_mode && !guest) {
          strcpy(pw->pw_dir, virtual_root);
        }
  #endif

---

From: Kent Landfield <[email-masked]>
Date: Sun, 11 Feb 96 13:31:39 CST

In the "For What It's Worth" department....

I, like others, have been seeing the "hanging connection problem" happen on 
a regular basis.  I never found it too big a problem until it started to 
restrict users from accessing my site due to the "too many logins" feature.  

I happened on a interesting occurrance recently.  I had, what appeared to be,
200 ftp sessions active.  I was in the process of sweeping my sites with
a tool called probe_tcp_ports to examine connection exposure.  When I looked 
immediately after running probe_tcp_ports I noticed I only had 48 established 
ftp sessions.  It seems that the probe_tcp_ports reset the hung ports and the 
sleeping processes terminated.  

This is repeatable here.  I have not taken the time to see why, but for 
those still encountering the problem,  this may interest you.  

The source to probe_tcp_ports can be found in the COAST archives.

ftp://coast.cs.purdue.edu/pub/tools/unix/probe_tcp_ports/probe_tcp_ports.c.Z
   			or
ftp://ftp.sterling.com/COAST/tools/unix/probe_tcp_ports/probe_tcp_ports.c.Z

Your mileage might vary...

End of "For What It's Worth".

			-Kent+
-- 
Kent Landfield                    INTERNET: [email-masked] 
Sterling Software                 FAX:      1-214-891-8655             
Phone: 1-214-891-8693             Pager:    1-800-386-0277   
Please send comp.sources.misc-related mail to [email-masked].

---

From: Vidiot <[email-masked]>
Date: Tue, 13 Feb 1996 11:13:21 -0600 (CST)

OK, I finally got around to getting Beta 9 up on my system.  Attached below
is the patch for killing off idle daemons.

Side note for Stan:  Please add to beta 10 release.

MB
-- 
System Administrator - Finnigan FT/MS - Madison WI. <URL:http://www.ftms.com/>
e-mail: [email-masked]
phone: (608) 273-8262  fax: (608) 273-8719  voice-mail: (800) 538-7067 ext 8451
Visit - <URL:http://www.cdsnet.net/vidiot/>  (Your link to Star Trek and UPN)

***** CUT HERE for ftpd.c.patch *****
*** ftpd.c.dist	Tue Jan 23 00:09:11 1996
--- ftpd.c	Tue Feb 13 10:56:43 1996
***************
*** 52,53 ****
--- 52,54 ----
  #include <sys/types.h>
+ #include <sys/uio.h>
  #include <sys/param.h>
***************
*** 162,163 ****
--- 163,166 ----
  
+ extern int timeout;
+ 
  /* File containing login names NOT to be used on this machine. Commonly used
***************
*** 269,270 ****
--- 272,274 ----
  extern int authenticated;
+ static void TPtoolong();
  
***************
*** 1120,1121 ****
--- 1124,1141 ----
  
+ static void
+ TPtoolong()
+ {
+     time_t now;
+ 
+     reply(421,
+       "Timeout (%d seconds): closing control connection.", timeout);
+     (void) time(&now);
+     if (logging) {
+         syslog(LOG_INFO,
+             "User %s timed out after %d seconds at %.24s",
+             (pw ? pw -> pw_name : "unknown"), timeout, ctime(&now));
+     }
+     dologout(1);
+ }
+ 
  int
***************
*** 2038,2039 ****
--- 2058,2060 ----
      byte_count = 0;
+     (void) signal(SIGALRM, TPtoolong);
      if (size != (off_t) - 1)
***************
*** 2046,2049 ****
            fromlen = sizeof(from);
! 
          s = accept(pdata, (struct sockaddr *) &from, &fromlen);
          if (s < 0) {
--- 2067,2071 ----
            fromlen = sizeof(from);
! 	alarm(timeout);
          s = accept(pdata, (struct sockaddr *) &from, &fromlen);
+ 	alarm(0);
          if (s < 0) {
***************
*** 2113,2114 ****
--- 2135,2137 ----
  {
+ 
      register int c,
***************
*** 2119,2121 ****
--- 2142,2147 ----
  
+     (void) signal(SIGALRM, TPtoolong);
+ 
      transflag++;
+ 
      if (setjmp(urgcatch)) {
***************
*** 2127,2128 ****
--- 2153,2155 ----
      case TYPE_A:
+         alarm(timeout);
          while ((c = getc(instr)) != EOF) {
***************
*** 2133,2134 ****
--- 2160,2162 ----
                  (void) putc('\r', outstr);
+ 		alarm(timeout);
              }
***************
*** 2135,2138 ****
              (void) putc(c, outstr);
!         }
          fflush(outstr);
          transflag = 0;
--- 2163,2167 ----
              (void) putc(c, outstr);
! 	}
          fflush(outstr);
+ 	alarm(0);
          transflag = 0;
***************
*** 2165,2167 ****
          while ((cnt = read(filefd, buf, (u_int) blksize)) > 0 &&
!                write(netfd, buf, cnt) == cnt)
              byte_count += cnt;
--- 2194,2196 ----
          while ((cnt = read(filefd, buf, (u_int) blksize)) > 0 &&
!                TPwrite(netfd, buf, cnt) == cnt)
              byte_count += cnt;
***************
*** 2185,2186 ****
--- 2214,2216 ----
      transflag = 0;
+     alarm(0);
      perror_reply(426, "Data connection");
***************
*** 2190,2191 ****
--- 2220,2222 ----
      transflag = 0;
+     alarm(0);
      perror_reply(551, "Error on input file");
***************
*** 2210,2212 ****
--- 2241,2246 ----
  
+     (void) signal(SIGALRM, TPtoolong);
+ 
      transflag++;
+ 
      if (setjmp(urgcatch)) {
***************
*** 2219,2221 ****
      case TYPE_L:
!         while ((cnt = read(fileno(instr), buf, sizeof buf)) > 0) {
              if (write(fileno(outstr), buf, cnt) != cnt)
--- 2253,2255 ----
      case TYPE_L:
!         while ((cnt = TPread(fileno(instr), buf, sizeof buf)) > 0) {
              if (write(fileno(outstr), buf, cnt) != cnt)
***************
*** 2235,2236 ****
--- 2269,2271 ----
      case TYPE_A:
+ 	alarm(timeout);
          while ((c = getc(instr)) != EOF) {
***************
*** 2237,2240 ****
              byte_count++;
!             if (c == '\n')
                  bare_lfs++;
              while (c == '\r') {
--- 2272,2277 ----
              byte_count++;
!             if (c == '\n') {
                  bare_lfs++;
+ 	        alarm(timeout);
+ 	     }
              while (c == '\r') {
***************
*** 2244,2245 ****
--- 2281,2283 ----
                      (void) putc('\r', outstr);
+ 		    alarm(timeout);
                      if (c == '\0' || c == EOF)
***************
*** 2252,2253 ****
--- 2290,2292 ----
          fflush(outstr);
+ 	alarm(0);
          if (ferror(instr))
***************
*** 2270,2271 ****
--- 2309,2311 ----
      transflag = 0;
+     alarm(0);
      perror_reply(426, "Data Connection");
***************
*** 2275,2276 ****
--- 2315,2317 ----
      transflag = 0;
+     alarm(0);
      perror_reply(452, "Error writing file");
***************
*** 3420 ****
--- 3461,3486 ----
  #endif /* ULTRIX_AUTH */
+ 
+ 
+ int TPwrite(fd, buf, nbyte)
+      int fd;
+      char *buf;
+      int nbyte;
+ {
+   int cnt;
+   alarm(timeout);
+   cnt = write(fd, buf, nbyte);
+   alarm(0);
+   return cnt;
+ }
+ 
+ int TPread(fd, buf, nbyte)
+      int fd;
+      char *buf;
+      int nbyte;
+ {
+   int cnt;
+   alarm(timeout);
+   cnt = read(fd, buf, nbyte);
+   alarm(0);
+   return cnt;
+ }
***** End of PATCH *****

---

From: Mitch Wright <[email-masked]>
Date: Tue, 13 Feb 1996 20:00:16 -0800

/* [email-masked] [[email-masked]] writes: */

>Side note for Stan:  Please add to beta 10 release.
I haven't tried this patch, but the one I use which is much more simple
is in ftpd.c around line 1715 or so, adding alarm() calls around the
accept().   

      (void) alarm((unsigned) 60);
      s = accept(pdata, (struct sockaddr *) &from, &fromlen);
      (void) alarm(0);

It hasn't been 100% effective, but boy has it helped!!!  I have maybe one
or two hung connections a month.  We normally have 30-40 concurrent FTP
users going 24 hours a day.  Not super heavy, but reasonably active...

-- 
do svidaniya,

  ~mitch

---

From: Vidiot <[email-masked]>
Date: Wed, 14 Feb 1996 09:17:46 -0600 (CST)

<
</* [email-masked] [[email-masked]] writes: */
<
<>OK, I finally got around to getting Beta 9 up on my system.  Attached below
<>is the patch for killing off idle daemons.
<>
<>Side note for Stan:  Please add to beta 10 release.
<>
<I haven't tried this patch, but the one I use which is much more simple
<is in ftpd.c around line 1715 or so, adding alarm() calls around the
<accept().   
<
<      (void) alarm((unsigned) 60);
<      s = accept(pdata, (struct sockaddr *) &from, &fromlen);
<      (void) alarm(0);
<
<It hasn't been 100% effective, but boy has it helped!!!  I have maybe one
<or two hung connections a month.  We normally have 30-40 concurrent FTP
<users going 24 hours a day.  Not super heavy, but reasonably active...
<  ~mitch

With the patch that I posted (written by someone else), I've had zero hangs.

MB