From: hno <> Date: Wed, 3 May 2000 02:41:22 +0000 (+0000) Subject: hno squid-2.3.DEVEL3.ftp_all_messages.patch X-Git-Tag: SQUID_3_0_PRE1~2005 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=858783c92c7553996a087744badeae563c16eb53;p=thirdparty%2Fsquid.git hno squid-2.3.DEVEL3.ftp_all_messages.patch 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. --- diff --git a/ChangeLog b/ChangeLog index c81db90724..9fd8d81719 100644 --- 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 (): diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 5f7a4b9501..8db7448912 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -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 diff --git a/src/ftp.cc b/src/ftp.cc index 723bcbec92..ec3c1d4eef 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -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 diff --git a/src/net_db.cc b/src/net_db.cc index 51ffb890e2..c8006a98e9 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -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 diff --git a/src/protos.h b/src/protos.h index f5446674fc..6573259746 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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);