Summary: wu-ftpd and Dead Processes

From: Al Aldrich (aaldrich@wpine.com)
Date: Fri Feb 23 1996 - 08:19:40 CST


I asked about old ftp processes hanging around and got one
patche to ftpd itself and two scripts to clean up after it..
I decided to go with the simple patch.. It seems to be
working so far. The 3 things I got are as follows:

Thanks to everyone who helped..
what a nice group :-)

al

Scenario:
client sends "PASV"
client sends "RETR file"
client doesn't open a connection, instead the client aborts.

Patch 1
---------
*** ftpd.c.org Thu Apr 14 22:05:35 1994
--- ftpd.c Mon Nov 21 19:40:59 1994
***************
*** 1710,1717 ****
--- 1710,1731 ----
          int s,
            fromlen = sizeof(from);

+ #ifdef FD_ZERO
+ struct timeval timeout;
+ fd_set set;
+
+ FD_ZERO(&set);
+ FD_SET(pdata, &set);
+
+ timeout.tv_usec = 0;
+ timeout.tv_sec = 120;
+
+ if (select(pdata+1, &set, (fd_set *) 0, (fd_set *) 0, &timeout) == 0 ||
+ (s = accept(pdata, (struct sockaddr *) &from, &fromlen)) < 0) {
+ #else
          s = accept(pdata, (struct sockaddr *) &from, &fromlen);
          if (s < 0) {
+ #endif
              reply(425, "Can't open data connection.");
              (void) close(pdata);
              pdata = -1;

A cleanup script:
-----------------
#!/bin/sh
PID = `ps -aux | grep ftp | grep -v grep | awk '{ print $2 " " $9 }' | \
       grep [A-Z][a-z][a-z] | awk ' { print $1 } ' `
kill $PID

Another cleanup scipt:
----------------------
#!/usr/local/bin/perl
#
# kill old ftpd's
#

$sig = 'TERM';
$BSD = -f '/vmunix';
$pscmd = $BSD ? "ps -auxww" : "ps -ef";

open(PS, "$pscmd|") || die "can't run $pscmd: $!";

while ($cand = <PS>) {
    chop($cand);
    ($user, $pid) = split(' ', $cand);
    next if $pid == $$;
    $found = ( $cand =~ /^ftp/ || $cand =~ /\(in.ftpd\)$/);
    next if (!$found);
    $time = (split(' ', $cand))[8];
    next if $time =~ /:/;
    print "$cand\n";
    kill $sig, $pid;
}

Al Aldrich aaldrich@wpine.com
Director of Operations 603-886-9050
White Pine Software



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:54 CDT