Subject: Lingering ftp connections

From: [email-masked] (Robert McDaniel)
Date: Tue, 16 Jan 1996 13:30:44 +0100

I have set up wu-ftp for my system, and have been having lingering ftp
connections.  As per messages to this list, I obtained the latest beta
release, which was supposed to solve this problem. (at least that is the
impression I received)

What should I do now?

_______________________

Robert McDaniel
Webmaster
The Palace Group
Time Warner

www.thepalace.com
[email-masked]
(818) 295 6624

_______________________

---

From: Vidiot <[email-masked]>
Date: Wed, 17 Jan 1996 09:37:13 -0600 (CST)

<I have set up wu-ftp for my system, and have been having lingering ftp
<connections.  As per messages to this list, I obtained the latest beta
<release, which was supposed to solve this problem. (at least that is the
<impression I received)
<
<What should I do now?
<Robert McDaniel

Install the patch below to the wu-ftpd-2.4.2-beta-8 src directory.

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

*** ftpd.c.dist	Thu Oct 26 22:58:59 1995
--- ftpd.c	Thu Oct 26 23:08:30 1995
***************
*** 44,45 ****
--- 44,46 ----
  #include <sys/types.h>
+ #include <sys/uio.h>
  #include <sys/param.h>
***************
*** 130,131 ****
--- 131,134 ----
  
+ extern int timeout;
+ 
  /* File containing login names NOT to be used on this machine. Commonly used
***************
*** 233,234 ****
--- 236,238 ----
  extern int authenticated;
+ static void TPtoolong();
  
***************
*** 1078,1079 ****
--- 1082,1099 ----
  
+ 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
***************
*** 1992,1993 ****
--- 2012,2014 ----
      byte_count = 0;
+     (void) signal(SIGALRM, TPtoolong);
      if (size != (off_t) - 1)
***************
*** 2000,2003 ****
            fromlen = sizeof(from);
! 
          s = accept(pdata, (struct sockaddr *) &from, &fromlen);
          if (s < 0) {
--- 2021,2025 ----
            fromlen = sizeof(from);
! 	alarm(timeout);
          s = accept(pdata, (struct sockaddr *) &from, &fromlen);
+ 	alarm(0);
          if (s < 0) {
***************
*** 2067,2068 ****
--- 2089,2091 ----
  {
+ 
      register int c,
***************
*** 2073,2075 ****
--- 2096,2101 ----
  
+     (void) signal(SIGALRM, TPtoolong);
+ 
      transflag++;
+ 
      if (setjmp(urgcatch)) {
***************
*** 2081,2082 ****
--- 2107,2109 ----
      case TYPE_A:
+         alarm(timeout);
          while ((c = getc(instr)) != EOF) {
***************
*** 2087,2088 ****
--- 2114,2116 ----
                  (void) putc('\r', outstr);
+ 		alarm(timeout);
              }
***************
*** 2089,2092 ****
              (void) putc(c, outstr);
!         }
          fflush(outstr);
          transflag = 0;
--- 2117,2121 ----
              (void) putc(c, outstr);
! 	}
          fflush(outstr);
+ 	alarm(0);
          transflag = 0;
***************
*** 2119,2121 ****
          while ((cnt = read(filefd, buf, (u_int) blksize)) > 0 &&
!                write(netfd, buf, cnt) == cnt)
              byte_count += cnt;
--- 2148,2150 ----
          while ((cnt = read(filefd, buf, (u_int) blksize)) > 0 &&
!                TPwrite(netfd, buf, cnt) == cnt)
              byte_count += cnt;
***************
*** 2139,2140 ****
--- 2168,2170 ----
      transflag = 0;
+     alarm(0);
      perror_reply(426, "Data connection");
***************
*** 2144,2145 ****
--- 2174,2176 ----
      transflag = 0;
+     alarm(0);
      perror_reply(551, "Error on input file");
***************
*** 2164,2166 ****
--- 2195,2200 ----
  
+     (void) signal(SIGALRM, TPtoolong);
+ 
      transflag++;
+ 
      if (setjmp(urgcatch)) {
***************
*** 2173,2175 ****
      case TYPE_L:
!         while ((cnt = read(fileno(instr), buf, sizeof buf)) > 0) {
              if (write(fileno(outstr), buf, cnt) != cnt)
--- 2207,2209 ----
      case TYPE_L:
!         while ((cnt = TPread(fileno(instr), buf, sizeof buf)) > 0) {
              if (write(fileno(outstr), buf, cnt) != cnt)
***************
*** 2189,2190 ****
--- 2223,2225 ----
      case TYPE_A:
+ 	alarm(timeout);
          while ((c = getc(instr)) != EOF) {
***************
*** 2191,2194 ****
              byte_count++;
!             if (c == '\n')
                  bare_lfs++;
              while (c == '\r') {
--- 2226,2231 ----
              byte_count++;
!             if (c == '\n') {
                  bare_lfs++;
+ 	        alarm(timeout);
+ 	     }
              while (c == '\r') {
***************
*** 2198,2199 ****
--- 2235,2237 ----
                      (void) putc('\r', outstr);
+ 		    alarm(timeout);
                      if (c == '\0' || c == EOF)
***************
*** 2206,2207 ****
--- 2244,2246 ----
          fflush(outstr);
+ 	alarm(0);
          if (ferror(instr))
***************
*** 2224,2225 ****
--- 2263,2265 ----
      transflag = 0;
+     alarm(0);
      perror_reply(426, "Data Connection");
***************
*** 2229,2230 ****
--- 2269,2271 ----
      transflag = 0;
+     alarm(0);
      perror_reply(452, "Error writing file");
***************
*** 3273 ****
--- 3314,3339 ----
  #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;
+ }