]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
2.1 branch merge
authorwessels <>
Sat, 21 Nov 1998 23:54:25 +0000 (23:54 +0000)
committerwessels <>
Sat, 21 Nov 1998 23:54:25 +0000 (23:54 +0000)
ChangeLog
scripts/udp-banger.pl
src/StatHist.cc
src/cf.data.pre
src/dnsserver.cc
src/forward.cc
src/ftp.cc
src/pinger.cc
src/protos.h
src/structs.h
src/wais.cc

index 01454dd3bc13c72b70ade8ba27688e260e6c0788..fb6cda8aa7333dd26e9a3ea5351c4c19c1a0dba3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -29,7 +29,7 @@ Changes to Squid-2.2 ():
        - Added "-k parse" command line option: parses the config file
          but does not send a signal unlike other -k options.
 
-Changes to Squid-2.1 ():
+Changes to Squid-2.1 (November 16, 1998):
 
        - Changed delayPoolsUpdate() to be called as an event.
        - Replaced comm_select FD scanning loops with global fd_set
@@ -109,6 +109,14 @@ Changes to Squid-2.1 ():
          authentication information.  (Henrik Nordstrom)
        - Changed refreshCheck() so that objects with negative age
          are always stale.
+       - Fixed "plain" FTP listings (Henrik Nordstrom).
+       - Fixed showing banner/logon message for top-level FTP
+         directories (Henrik Nordstrom).
+       * Changes below have been made to SQUID_2_1_PATCH1
+       - Fixed pinger packet size assertion.
+       - Fixed WAIS forwarding.
+       - Fixed dnsserver coredump bug caused by using both -D and
+         -s options.
 
 Changes to Squid-2.0 (October 2, 1998):
 
index f54c8fd76314760145bb899e7900799947992348..069df4928a02d1f9532de6dae61a18ab344fa42e 100755 (executable)
 # URLs to request.  Run N of these at the same time to simulate a heavy
 # neighbor cache load.
 
-require 'getopts.pl';
-require 'fcntl.ph';
+use Fcntl;
+use Getopt::Std;
+use IO::Socket;
 
 $|=1;
 
-&Getopts('nr');
+getopts('qlnr');
 
 $host=(shift || 'localhost') ;
 $port=(shift || '3130') ;
@@ -49,24 +50,16 @@ $port=(shift || '3130') ;
     "ICP_END"
 );
 
-require 'sys/socket.ph';
-
-$sockaddr = 'S n a4 x8';
-($name, $aliases, $proto) = getprotobyname("udp");
-($fqdn, $aliases, $type, $len, $themaddr) = gethostbyname($host);
-$thissock = pack($sockaddr, &AF_INET, 0, "\0\0\0\0");
-$them = pack($sockaddr, &AF_INET, $port, $themaddr);
+$sock = IO::Socket::INET->new(PeerAddr => "$host:$port", Proto => 'udp');
+die "socket: $!\n" unless defined($sock);
 
 chop($me=`uname -a|cut -f2 -d' '`);
 $myip=(gethostbyname($me))[4];
 
-die "socket: $!\n" unless
-       socket (SOCK, &AF_INET, &SOCK_DGRAM, $proto);
-
-$flags = fcntl (SOCK, &F_GETFL, 0);
+$flags = fcntl ($sock, &F_GETFL, 0);
 $flags |= &O_NONBLOCK;
 die "fcntl O_NONBLOCK: $!\n" unless
-       fcntl (SOCK, &F_SETFL, $flags);
+       fcntl ($sock, &F_SETFL, $flags);
 
 $flags = 0;
 $flags |= 0x80000000;
@@ -77,6 +70,12 @@ $rn = 0;
 $start = time;
 while (<>) {
        chop;
+
+       if ($opt_l) { # it's a Squid log file
+               @stuff = split(/\s+/, $_);
+               $_ = $stuff[6];
+       }
+
         $len = length($_) + 1;
         $request_template = sprintf 'CCnNNa4a4x4a%d', $len;
         $request = pack($request_template,
@@ -89,14 +88,15 @@ while (<>) {
                 $myip,          # a4 shostid
                 $_);            # a%d payload
        die "send: $!\n" unless
-               send(SOCK, $request, 0, $them);
+               send($sock, $request, 0, $them);
        $nsent++;
         $rin = '';
-        vec($rin,fileno(SOCK),1) = 1;
+        vec($rin,fileno($sock),1) = 1;
         ($nfound,$timeleft) = select($rout=$rin, undef, undef, 2.0);
        next if ($nfound == 0);
        while (1) {
-               last unless ($theiraddr = recv(SOCK, $reply, 1024, 0));
+               last unless ($theiraddr = recv($sock, $reply, 1024, 0));
+               next if $opt_q; # quietly carry on
                $nrecv++;
                if ($opt_r) {
                        # only print send/receive rates
index 103a8faa5af9a1f22f66ac24fd08d95dab59589c..5279a9ca3b50618f248387db69ba0123361a951b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: StatHist.cc,v 1.19 1998/11/12 06:27:52 wessels Exp $
+ * $Id: StatHist.cc,v 1.20 1998/11/21 16:54:25 wessels Exp $
  *
  * DEBUG: section 62    Generic Histogram
  * AUTHOR: Duane Wessels
@@ -161,7 +161,7 @@ statHistBin(const StatHist * H, double v)
 static double
 statHistVal(const StatHist * H, int bin)
 {
-    return H->val_out(bin / H->scale) + H->min;
+    return H->val_out((double) bin / H->scale) + H->min;
 }
 
 double
index 35f3b135d0eacfcfb6355fc6323ee8a155a967e0..0b75eda6698817937373122e81ec2fe988f96e44 100644 (file)
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.125 1998/11/12 06:33:31 wessels Exp $
+# $Id: cf.data.pre,v 1.126 1998/11/21 16:54:26 wessels Exp $
 #
 #
 # SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -1462,7 +1462,7 @@ acl all src 0.0.0.0/0.0.0.0
 acl manager proto cache_object
 acl localhost src 127.0.0.1/255.255.255.255
 acl SSL_ports port 443 563
-acl Safe_ports port 80 21 70 1025-65535
+acl Safe_ports port 80 21 443 563 70 210 1025-65535
 acl CONNECT method CONNECT
 NOCOMMENT_END
 DOC_END
@@ -2708,4 +2708,5 @@ DOC_START
        cache, instead of going direct, then turn this option off.
 prefer_direct on
 DOC_END
+
 EOF
index b8d95069b24e73932500e945b37ee0079469bcb7..1fe425a69836c006cfafcde34e03b3b09f857dfc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: dnsserver.cc,v 1.53 1998/11/12 06:28:03 wessels Exp $
+ * $Id: dnsserver.cc,v 1.54 1998/11/21 16:54:26 wessels Exp $
  *
  * DEBUG: section 0     DNS Resolver
  * AUTHOR: Harvest Derived
@@ -286,16 +286,33 @@ main(int argc, char *argv[])
 #if HAVE_RES_INIT
            if (opt_s == 0) {
                _res.nscount = 0;
+               /*
+                * Setting RES_INIT here causes coredumps when -s is
+                * used with -D option.  It looks to me like setting
+                * RES_INIT is wrong.  The resolver code sets RES_INIT
+                * after calling res_init().  When we change the _res
+                * structure and set RES_INIT, some internal resolver
+                * structures get confused.             -DW 2.1.p1
+                */
+#if SEEMS_WRONG
                _res.options |= RES_INIT;
+#endif
                opt_s = 1;
+           } else if (_res.nscount == MAXNS) {
+               fprintf(stderr, "Too many -s options, only %d are allowed\n",   
+                       MAXNS);
+               break;
            }
 #if HAVE_RES_NSADDR_LIST
+           _res.nsaddr_list[_res.nscount]=_res.nsaddr_list[0];
            safe_inet_addr(optarg, &_res.nsaddr_list[_res.nscount++].sin_addr);
 #elif HAVE_RES_NS_LIST
+           _res.ns_list[_res.nscount]=_res.ns_list[0];
            safe_inet_addr(optarg, &_res.ns_list[_res.nscount++].addr.sin_addr);
-#endif
+#else /* Unknown NS list format */
            fprintf(stderr, "-s is not supported on this resolver\n");
-#else
+#endif
+#else /* !HAVE_RES_INIT */
            fprintf(stderr, "-s is not supported on this resolver\n");
 #endif /* HAVE_RES_INIT */
            break;
index a46acc70bcc4d94a4390ba571688a33de5127bcf..3f072347291dbfbae5abb12e79ed160e379e3478 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: forward.cc,v 1.31 1998/11/12 06:28:05 wessels Exp $
+ * $Id: forward.cc,v 1.32 1998/11/21 16:54:27 wessels Exp $
  *
  * DEBUG: section 17    Request Forwarding
  * AUTHOR: Duane Wessels
@@ -230,6 +230,14 @@ fwdStartComplete(peer * p, void *data)
        s->host = xstrdup(p->host);
        s->port = p->http_port;
        s->peer = p;
+    } else if (fwdState->request->protocol == PROTO_WAIS) {
+       if (!Config.Wais.relayHost) {
+           fwdStartFail(NULL, fwdState);
+           return;
+       } else {
+           s->host = xstrdup(Config.Wais.relayHost);
+           s->port = Config.Wais.relayPort;
+       }
     } else {
        s->host = xstrdup(fwdState->request->host);
        s->port = fwdState->request->port;
index b63daec9f8c1f8d85c22695900fcadbb3c3e0ba0..3613d4cc679afaf16bef52a8f7a8838902159995 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.254 1998/11/12 06:28:07 wessels Exp $
+ * $Id: ftp.cc,v 1.255 1998/11/21 16:54:27 wessels Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -905,7 +905,7 @@ ftpCheckUrlpath(FtpStateData * ftpState)
     if ((t = strRChr(request->urlpath, ';')) != NULL) {
        if (strncasecmp(t + 1, "type=", 5) == 0) {
            ftpState->typecode = (char) toupper((int) *(t + 6));
-           strSet(request->urlpath, t, '\0');
+           strCutPtr(request->urlpath, t);
        }
     }
     l = strLen(request->urlpath);
@@ -1201,7 +1201,7 @@ static void
 ftpHandleControlReply(FtpStateData * ftpState)
 {
     char *oldbuf;
-    wordlist **W;
+    wordlist **W, **T;
     int bytes_used = 0;
     wordlistDestroy(&ftpState->ctrl.message);
     ftpState->ctrl.message = ftpParseControlReply(ftpState->ctrl.buf,
@@ -1228,10 +1228,21 @@ ftpHandleControlReply(FtpStateData * ftpState)
        xmemmove(ftpState->ctrl.buf, ftpState->ctrl.buf + bytes_used,
            ftpState->ctrl.offset);
     }
-    for (W = &ftpState->ctrl.message; *W && (*W)->next; W = &(*W)->next);
+    /* Extract reply message (last line) */
+    for (T = NULL, W = &ftpState->ctrl.message; *W && (*W)->next; W = &(*W)->next) {
+       /* Skip trailing blank lines */
+       if (strlen((*W)->key) == 0) {
+           if (T == NULL)
+               T = W;
+       } else if ((*W)->next) {
+           T = NULL;
+       }
+    }
     safe_free(ftpState->ctrl.last_reply);
     ftpState->ctrl.last_reply = (*W)->key;
     safe_free(*W);
+    if (T)
+       wordlistDestroy(T);
     debug(9, 8) ("ftpReadControlReply: state=%d, code=%d\n", ftpState->state,
        ftpState->ctrl.replycode);
     FTP_SM_FUNCS[ftpState->state] (ftpState);
@@ -1247,9 +1258,14 @@ ftpReadWelcome(FtpStateData * ftpState)
     if (ftpState->flags.pasv_only)
        ftpState->login_att++;
     if (code == 220) {
-       if (ftpState->ctrl.message)
+       if (ftpState->ctrl.message) {
            if (strstr(ftpState->ctrl.message->key, "NetWare"))
                ftpState->flags.skip_whitespace = 1;
+           if (ftpState->cwd_message)
+               wordlistDestroy(&ftpState->cwd_message);
+           ftpState->cwd_message = ftpState->ctrl.message;
+           ftpState->ctrl.message = NULL;
+       }
        ftpSendUser(ftpState);
     } else if (code == 120) {
        if (NULL != ftpState->ctrl.message)
@@ -1301,6 +1317,12 @@ ftpReadPass(FtpStateData * ftpState)
 {
     int code = ftpState->ctrl.replycode;
     debug(9, 3) ("ftpReadPass\n");
+    if (ftpState->ctrl.message) {
+       if (ftpState->cwd_message)
+           wordlistDestroy(&ftpState->cwd_message);
+       ftpState->cwd_message = ftpState->ctrl.message;
+       ftpState->ctrl.message = NULL;
+    }
     if (code == 230) {
        ftpSendType(ftpState);
     } else {
index 30a15c29ec57039d28b97b37e67c73d3e81c803d..5e3aa2d54994532c45bccd2214da0b3e2585f31e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: pinger.cc,v 1.38 1998/11/13 20:50:54 wessels Exp $
+ * $Id: pinger.cc,v 1.39 1998/11/21 16:54:28 wessels Exp $
  *
  * DEBUG: section 42    ICMP Pinger program
  * AUTHOR: Duane Wessels
@@ -76,8 +76,8 @@
 #define MAX_PKT_SZ 8192
 #define MAX_PAYLOAD (MAX_PKT_SZ - sizeof(struct icmphdr) - sizeof (char) - sizeof(struct timeval) - 1)
 #else
-#define MAX_PAYLOAD (sizeof(struct icmphdr) + sizeof (char) + sizeof(struct timeval) + 1)
-#define MAX_PKT_SZ MAX_PAYLOAD
+#define MAX_PAYLOAD SQUIDHOSTNAMELEN
+#define MAX_PKT_SZ (MAX_PAYLOAD + sizeof(struct timeval) + sizeof (char) + sizeof(struct icmphdr) + 1)
 #endif
 
 typedef struct {
@@ -293,7 +293,7 @@ pingerReadRequest(void)
     n = recv(0, (char *) &pecho, sizeof(pecho), 0);
     if (n < 0)
        return n;
-    guess_size = n - (sizeof(pingerEchoData) - MAX_PKT_SZ);
+    guess_size = n - (sizeof(pingerEchoData) - PINGER_PAYLOAD_SZ);
     if (guess_size != pecho.psize)
        fprintf(stderr, "size mismatch, guess=%d psize=%d\n",
            guess_size, pecho.psize);
index d3f053bd091b857f03685fc7316413c3b8f1d8f7..405ac98ec9c289fef750af9d47ef5bf05e4a15e3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.290 1998/11/18 00:16:38 glenn Exp $
+ * $Id: protos.h,v 1.291 1998/11/21 16:54:29 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -1042,7 +1042,8 @@ extern void htcpSocketClose(void);
 #define strCaseCmp(s,str) strcasecmp(strBuf(s), (str))
 #define strNCaseCmp(s,str,n) strncasecmp(strBuf(s), (str), (n))
 #define strSet(s,ptr,ch) (s).buf[ptr-(s).buf] = (ch)
-#define strCut(s,pos) (s).buf[pos] = '\0'
+#define strCut(s,pos) (((s).len = pos) , ((s).buf[pos] = '\0'))
+#define strCutPtr(s,ptr) (((s).len = (ptr)-(s).buf) , ((s).buf[(s).len] = '\0'))
 /* #define strCat(s,str)  stringAppend(&(s), (str), strlen(str)+1) */
 extern void stringInit(String * s, const char *str);
 extern void stringLimitInit(String * s, const char *str, int len);
index 196b8e91e28c99d90abea1249561a719c07437c6..1ce8a3737e7e02ec7a53e2a145a8af99ef4204cc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.249 1998/11/13 21:02:11 rousskov Exp $
+ * $Id: structs.h,v 1.250 1998/11/21 16:54:29 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -933,12 +933,12 @@ struct _cd_guess_stats {
 };
 
 struct _PeerDigest {
-    peer *peer;                 /* pointer back to peer structure, argh */
-    CacheDigest *cd;            /* actual digest structure */
-    String host;                /* copy of peer->host */
+    peer *peer;                        /* pointer back to peer structure, argh */
+    CacheDigest *cd;           /* actual digest structure */
+    String host;               /* copy of peer->host */
     const char *req_result;    /* text status of the last request */
     struct {
-       unsigned int needed:1;  /* there were requests for this digest */
+       unsigned int needed:1;  /* there were requests for this digest */
        unsigned int usable:1;  /* can be used for lookups */
        unsigned int requested:1;       /* in process of receiving [fresh] digest */
     } flags;
@@ -949,7 +949,7 @@ struct _PeerDigest {
        time_t next_check;      /* next scheduled check/refresh event */
        time_t retry_delay;     /* delay before re-checking _invalid_ digest */
        time_t requested;       /* requested a fresh copy of a digest */
-       time_t req_delay;       /* last request response time */
+       time_t req_delay;       /* last request response time */
        time_t received;        /* received the current copy of a digest */
        time_t disabled;        /* disabled for good */
     } times;
index 490c71b30add385c1c76ec9f35f4eef74b5a3c05..e0f8194e1bee32ce630de9853ea53d208631c057 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: wais.cc,v 1.122 1998/10/12 21:39:06 wessels Exp $
+ * $Id: wais.cc,v 1.123 1998/11/21 16:54:30 wessels Exp $
  *
  * DEBUG: section 24    WAIS Relay
  * AUTHOR: Harvest Derived
@@ -39,8 +39,6 @@ typedef struct {
     int fd;
     StoreEntry *entry;
     method_t method;
-    char *relayhost;
-    int relayport;
     const HttpHeader *request_hdr;
     char url[MAX_URL];
     request_t *request;
@@ -172,10 +170,8 @@ waisSendComplete(int fd, char *bufnotused, size_t size, int errflag, void *data)
        return;
     if (errflag) {
        ErrorState *err;
-       err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE);
+       err = errorCon(ERR_WRITE_ERROR, HTTP_SERVICE_UNAVAILABLE);
        err->xerrno = errno;
-       err->host = xstrdup(waisState->relayhost);
-       err->port = waisState->relayport;
        err->request = requestLink(waisState->request);
        errorAppendEntry(entry, err);
        comm_close(fd);
@@ -197,7 +193,8 @@ waisSendRequest(int fd, void *data)
     MemBuf mb;
     const char *Method = RequestMethodStr[waisState->method];
     debug(24, 5) ("waisSendRequest: FD %d\n", fd);
-    memBufPrintf(&mb, "%s %s", Method, waisState->url);
+    memBufDefInit(&mb);
+    memBufPrintf(&mb, "%s %s HTTP/1.0\r\n", Method, waisState->url);
     if (waisState->request_hdr) {
        Packer p;
        packerToMemInit(&p, &mb);
@@ -220,19 +217,9 @@ waisStart(request_t * request, StoreEntry * entry, int fd)
     debug(24, 3) ("waisStart: \"%s %s\"\n", RequestMethodStr[method], url);
     Counter.server.all.requests++;
     Counter.server.other.requests++;
-    if (!Config.Wais.relayHost) {
-       ErrorState *err;
-       debug(24, 0) ("waisStart: Failed because no relay host defined!\n");
-       err = errorCon(ERR_NO_RELAY, HTTP_INTERNAL_SERVER_ERROR);
-       err->request = requestLink(request);
-       errorAppendEntry(entry, err);
-       return;
-    }
     waisState = xcalloc(1, sizeof(WaisStateData));
     cbdataAdd(waisState, MEM_NONE);
     waisState->method = method;
-    waisState->relayhost = Config.Wais.relayHost;
-    waisState->relayport = Config.Wais.relayPort;
     waisState->request_hdr = &request->header;
     waisState->fd = fd;
     waisState->entry = entry;