]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
hno squid-2.3.DEVEL3.ftp_all_messages.patch
authorhno <>
Wed, 3 May 2000 02:41:22 +0000 (02:41 +0000)
committerhno <>
Wed, 3 May 2000 02:41:22 +0000 (02:41 +0000)
Squid-2.3.DEVEL3: Show FTP server messages

Show all FTP server messages in generated error pages or top level
directory listing. Main purpose is to make sure all information is
available when a login is denied due to to many users or a closed
mirror.

ChangeLog
src/cache_cf.cc
src/ftp.cc
src/net_db.cc
src/protos.h

index c81db9072486f7040634a131da1cd1612292bea2..9fd8d8171900cf2e76a2987164cfa10d3ba6280a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -49,6 +49,7 @@ Changes to Squid-2.4.DEVEL3 ():
        - "round-robin" cache_peer counters are reset every 5 minutes to
          compensate previously dead peers
        - DNS retransmit parameters
+       - Show all FTP server messages
 
 Changes to Squid-2.4.DEVEL2 ():
 
index 5f7a4b9501cdd4f6c254780452b27d93cd256d82..8db7448912999361b978d5e0e8746acb6751be5f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.340 2000/05/02 20:31:44 hno Exp $
+ * $Id: cache_cf.cc,v 1.341 2000/05/02 20:41:22 hno Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -100,7 +100,7 @@ wordlistDestroy(wordlist ** list)
     *list = NULL;
 }
 
-wordlist *
+const char *
 wordlistAdd(wordlist ** list, const char *key)
 {
     while (*list)
@@ -108,7 +108,28 @@ wordlistAdd(wordlist ** list, const char *key)
     *list = memAllocate(MEM_WORDLIST);
     (*list)->key = xstrdup(key);
     (*list)->next = NULL;
-    return *list;
+    return (*list)->key;
+}
+
+void
+wordlistJoin(wordlist ** list, wordlist **wl)
+{
+    while (*list)
+       list = &(*list)->next;
+    *list = *wl;
+    *wl = NULL;
+}
+
+void
+wordlistAddWl(wordlist ** list, wordlist *wl)
+{
+    while (*list)
+       list = &(*list)->next;
+    for(;wl;wl=wl->next, list = &(*list)->next) {
+       *list = memAllocate(MEM_WORDLIST);
+       (*list)->key = xstrdup(wl->key);
+    (*list)->next = NULL;
+    }
 }
 
 void
index 723bcbec92ce6b7eeeac3262019540a58ddc245a..ec3c1d4eef457ef63c92538c9ccf379f496a5e48 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.291 2000/05/02 20:25:33 hno Exp $
+ * $Id: ftp.cc,v 1.292 2000/05/02 20:41:22 hno Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -1303,11 +1303,15 @@ ftpHandleControlReply(FtpStateData * ftpState)
        xmemmove(ftpState->ctrl.buf, ftpState->ctrl.buf + bytes_used,
            ftpState->ctrl.offset);
     }
-    /* Find the last line of the reply message */
+    /* Move the last line of the reply message to ctrl.last_reply */
     for (W = &ftpState->ctrl.message; (*W)->next; W = &(*W)->next);
     safe_free(ftpState->ctrl.last_reply);
-    ftpState->ctrl.last_reply = (*W)->key;
-    safe_free(*W);
+    ftpState->ctrl.last_reply = xstrdup((*W)->key);
+    wordlistDestroy(W);
+    /* Copy the rest of the message to cwd_message to be printed in
+     * error messages
+     */
+    wordlistAddWl(&ftpState->cwd_message, ftpState->ctrl.message);
     debug(9, 8) ("ftpHandleControlReply: state=%d, code=%d\n", ftpState->state,
        ftpState->ctrl.replycode);
     FTP_SM_FUNCS[ftpState->state] (ftpState);
@@ -1328,10 +1332,6 @@ ftpReadWelcome(FtpStateData * ftpState)
        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) {
@@ -1385,12 +1385,6 @@ ftpReadPass(FtpStateData * ftpState)
     int code = ftpState->ctrl.replycode;
     debug(9, 3) ("ftpReadPass\n");
     if (code == 230) {
-       if (ftpState->ctrl.message) {
-           if (ftpState->cwd_message)
-               wordlistDestroy(&ftpState->cwd_message);
-           ftpState->cwd_message = ftpState->ctrl.message;
-           ftpState->ctrl.message = NULL;
-       }
        ftpSendType(ftpState);
     } else {
        ftpFail(ftpState);
@@ -1516,6 +1510,7 @@ ftpReadCwd(FtpStateData * ftpState)
     if (code >= 200 && code < 300) {
        /* CWD OK */
        ftpUnhack(ftpState);
+       /* Reset cwd_message to only include the last message */
        if (ftpState->cwd_message)
            wordlistDestroy(&ftpState->cwd_message);
        ftpState->cwd_message = ftpState->ctrl.message;
@@ -2346,8 +2341,8 @@ ftpFailedErrorMessage(FtpStateData * ftpState, err_type error)
        err = errorCon(ERR_FTP_FAILURE, HTTP_BAD_GATEWAY);
     err->xerrno = errno;
     err->request = requestLink(ftpState->request);
-    err->ftp.server_msg = ftpState->ctrl.message;
-    ftpState->ctrl.message = NULL;
+    err->ftp.server_msg = ftpState->cwd_message;
+    ftpState->cwd_message = NULL;
     if (ftpState->old_request)
        command = ftpState->old_request;
     else
index 51ffb890e264b863ae9e1ea17cd456d7a5cc62fa..c8006a98e9252b4b84d2f7f7cd978503b38d8cbe 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: net_db.cc,v 1.142 2000/03/06 16:23:33 wessels Exp $
+ * $Id: net_db.cc,v 1.143 2000/05/02 20:41:23 hno Exp $
  *
  * DEBUG: section 38    Network Measurement Database
  * AUTHOR: Duane Wessels
@@ -60,7 +60,7 @@ static void netdbPurgeLRU(void);
 static netdbEntry *netdbLookupHost(const char *key);
 static net_db_peer *netdbPeerByName(const netdbEntry * n, const char *);
 static net_db_peer *netdbPeerAdd(netdbEntry * n, peer * e);
-static char *netdbPeerName(const char *name);
+static const char *netdbPeerName(const char *name);
 static IPH netdbSendPing;
 static QS sortPeerByRtt;
 static QS sortByRtt;
@@ -467,16 +467,15 @@ netdbReloadState(void)
        count, tvSubMsec(start, current_time));
 }
 
-static char *
+static const char *
 netdbPeerName(const char *name)
 {
-    wordlist *w;
+    const wordlist *w;
     for (w = peer_names; w; w = w->next) {
        if (!strcmp(w->key, name))
            return w->key;
     }
-    w = wordlistAdd(&peer_names, name);
-    return w->key;
+    return wordlistAdd(&peer_names, name);
 }
 
 static void
index f5446674fca856bd57cc029456fdc9cc62936ee2..65732597469ab73e29054f5a1d73e7ea8ee02352 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.361 2000/05/02 20:31:45 hno Exp $
+ * $Id: protos.h,v 1.362 2000/05/02 20:41:23 hno Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -102,7 +102,9 @@ extern int aioQueueSize(void);
 extern int parseConfigFile(const char *file_name);
 extern void intlistDestroy(intlist **);
 extern int intlistFind(intlist * list, int i);
-extern wordlist *wordlistAdd(wordlist **, const char *);
+extern const char *wordlistAdd(wordlist **, const char *);
+extern void wordlistAddWl(wordlist **, wordlist *);
+extern void wordlistJoin(wordlist **, wordlist **);
 extern wordlist *wordlistDup(const wordlist *);
 extern void wordlistDestroy(wordlist **);
 extern void configFreeMemory(void);