Changeset 5503 for squid-ssl/trunk/fuentes
- Timestamp:
- Jul 13, 2017, 11:11:39 AM (4 years ago)
- Location:
- squid-ssl/trunk/fuentes
- Files:
-
- 1 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
squid-ssl/trunk/fuentes/debian/patches/01-cf.data.debian.patch
r5498 r5503 3 3 --- a/src/cf.data.pre 4 4 +++ b/src/cf.data.pre 5 @@ -1 155,11 +1155,11 @@ NOCOMMENT_START5 @@ -1206,11 +1206,11 @@ 6 6 # Example rule allowing access from your local networks. 7 7 # Adapt to list your (internal) IP networks from where browsing … … 20 20 acl SSL_ports port 443 21 21 acl Safe_ports port 80 # http 22 @@ -14 08,7 +1408,7 @@ http_access deny manager22 @@ -1459,7 +1459,7 @@ 23 23 # Example rule allowing access from your local networks. 24 24 # Adapt localnet in the ACL section to list your (internal) IP networks … … 29 29 30 30 # And finally deny all other access to this proxy 31 @@ -4 431,7 +4431,7 @@ DOC_END31 @@ -4533,7 +4533,7 @@ 32 32 33 33 NAME: logfile_rotate … … 38 38 DOC_START 39 39 Specifies the number of logfile rotations to make when you 40 @@ -4 450,6 +4450,9 @@ DOC_START40 @@ -4552,6 +4552,9 @@ 41 41 42 42 Note, from Squid-3.1 this option is only a default for cache.log, … … 48 48 49 49 NAME: mime_table 50 @@ -8 794,8 +8797,8 @@ DOC_START50 @@ -8896,8 +8899,8 @@ 51 51 52 52 WARNING: -
squid-ssl/trunk/fuentes/debian/patches/CVE-2016-10003.patch
r5501 r5503 5 5 --- a/src/client_side_reply.cc 6 6 +++ b/src/client_side_reply.cc 7 @@ -545,7 +545,6 @@ 8 debugs(88, 5, "negative-HIT"); 9 http->logType = LOG_TCP_NEGATIVE_HIT; 10 sendMoreData(result); 11 - return; 12 } else if (blockedHit()) { 13 debugs(88, 5, "send_hit forces a MISS"); 14 http->logType = LOG_TCP_MISS; 15 @@ -597,29 +596,27 @@ 16 http->logType = LOG_TCP_MISS; 17 processMiss(); 18 } 19 - return; 20 } else if (r->conditional()) { 21 debugs(88, 5, "conditional HIT"); 22 - if (processConditional(result)) 23 - return; 24 - } 25 - 26 - /* 27 - * plain ol' cache hit 28 - */ 29 - debugs(88, 5, "plain old HIT"); 30 + processConditional(result); 31 + } else { 32 + /* 33 + * plain ol' cache hit 34 + */ 35 + debugs(88, 5, "plain old HIT"); 36 37 #if USE_DELAY_POOLS 38 - if (e->store_status != STORE_OK) 39 - http->logType = LOG_TCP_MISS; 40 - else 41 + if (e->store_status != STORE_OK) 42 + http->logType = LOG_TCP_MISS; 43 + else 44 #endif 45 - if (e->mem_status == IN_MEMORY) 46 - http->logType = LOG_TCP_MEM_HIT; 47 - else if (Config.onoff.offline) 48 - http->logType = LOG_TCP_OFFLINE_HIT; 49 + if (e->mem_status == IN_MEMORY) 50 + http->logType = LOG_TCP_MEM_HIT; 51 + else if (Config.onoff.offline) 52 + http->logType = LOG_TCP_OFFLINE_HIT; 53 54 - sendMoreData(result); 55 + sendMoreData(result); 56 + } 57 } 58 59 /** 60 @@ -713,16 +710,17 @@ 61 } 62 63 /// process conditional request from client 64 -bool 65 +void 66 clientReplyContext::processConditional(StoreIOBuffer &result) 67 { 68 StoreEntry *const e = http->storeEntry(); 69 70 if (e->getReply()->sline.status() != Http::scOkay) { 71 - debugs(88, 4, "Reply code " << e->getReply()->sline.status() << " != 200"); 72 + debugs(88, 4, "clientReplyContext::processConditional: Reply code " << 73 + e->getReply()->sline.status() << " != 200"); 74 http->logType = LOG_TCP_MISS; 75 processMiss(); 76 - return true; 77 + return; 7 @@ -474,6 +474,16 @@ 8 return; 78 9 } 79 10 80 HttpRequest &r = *http->request; 81 @@ -730,39 +728,51 @@ 82 if (r.header.has(HDR_IF_MATCH) && !e->hasIfMatchEtag(r)) { 83 // RFC 2616: reply with 412 Precondition Failed if If-Match did not match 84 sendPreconditionFailedError(); 85 - return true; 11 + // The previously identified hit suddenly became unsharable! 12 + // This is common for collapsed forwarding slaves but might also 13 + // happen to regular hits because we are called asynchronously. 14 + if (EBIT_TEST(e->flags, KEY_PRIVATE)) { 15 + debugs(88, 3, "unsharable " << *e << ". MISS"); 16 + http->logType = LOG_TCP_MISS; 17 + processMiss(); 86 18 + return; 87 }88 89 + bool matchedIfNoneMatch = false;90 if (r.header.has(HDR_IF_NONE_MATCH)) {91 - // RFC 7232: If-None-Match recipient MUST ignore IMS92 - r.flags.ims = false;93 - r.ims = -1;94 - r.imslen = 0;95 - r.header.delById(HDR_IF_MODIFIED_SINCE);96 + if (!e->hasIfNoneMatchEtag(r)) {97 + // RFC 2616: ignore IMS if If-None-Match did not match98 + r.flags.ims = false;99 + r.ims = -1;100 + r.imslen = 0;101 + r.header.delById(HDR_IF_MODIFIED_SINCE);102 + http->logType = LOG_TCP_MISS;103 + sendMoreData(result);104 + return;105 + }106 107 - if (e->hasIfNoneMatchEtag(r)) {108 + if (!r.flags.ims) {109 + // RFC 2616: if If-None-Match matched and there is no IMS,110 + // reply with 304 Not Modified or 412 Precondition Failed111 sendNotModifiedOrPreconditionFailedError();112 - return true;113 + return;114 }115 116 - // None-Match is true (no ETag matched); treat as an unconditional hit117 - return false;118 + // otherwise check IMS below to decide if we reply with 304 or 412119 + matchedIfNoneMatch = true;120 }121 122 if (r.flags.ims) {123 // handle If-Modified-Since requests from the client124 if (e->modifiedSince(&r)) {125 - // Modified-Since is true; treat as an unconditional hit126 - return false;127 + http->logType = LOG_TCP_IMS_HIT;128 + sendMoreData(result);129 + return;130 + }131 132 - } else {133 - // otherwise reply with 304 Not Modified134 - sendNotModified();135 + if (matchedIfNoneMatch) {136 + // If-None-Match matched, reply with 304 Not Modified or137 + // 412 Precondition Failed138 + sendNotModifiedOrPreconditionFailedError();139 + return;140 }141 - return true;142 - }143 144 - return false;145 + // otherwise reply with 304 Not Modified146 + sendNotModified();147 19 + } 148 } 149 150 /// whether squid.conf send_hit prevents us from serving this hit 151 @@ -1909,12 +1919,7 @@ 152 StoreEntry *e = http->storeEntry(); 153 const time_t timestamp = e->timestamp; 154 HttpReply *const temprep = e->getReply()->make304(); 155 - // log as TCP_INM_HIT if code 304 generated for 156 - // If-None-Match request 157 - if (!http->request->flags.ims) 158 - http->logType = LOG_TCP_INM_HIT; 159 - else 160 - http->logType = LOG_TCP_IMS_HIT; 161 + http->logType = LOG_TCP_IMS_HIT; 162 removeClientStoreReference(&sc, http); 163 createStoreEntry(http->request->method, RequestFlags()); 164 e = http->storeEntry(); 20 + 21 if (result.length == 0) { 22 debugs(88, 5, "store IO buffer has no content. MISS"); 23 /* the store couldn't get enough data from the file for us to id the -
squid-ssl/trunk/fuentes/src/LogTags.h
r5502 r5503 28 28 LOG_TCP_CLIENT_REFRESH_MISS, 29 29 LOG_TCP_IMS_HIT, 30 LOG_TCP_INM_HIT,31 30 LOG_TCP_SWAPFAIL_MISS, 32 31 LOG_TCP_NEGATIVE_HIT, … … 55 54 (code == LOG_TCP_HIT) || 56 55 (code == LOG_TCP_IMS_HIT) || 57 (code == LOG_TCP_INM_HIT) ||58 56 (code == LOG_TCP_REFRESH_FAIL_OLD) || 59 57 (code == LOG_TCP_REFRESH_UNMODIFIED) || -
squid-ssl/trunk/fuentes/src/Makefile.am
r5502 r5503 910 910 DEFAULT_CONFIG_DIR = $(sysconfdir) 911 911 DEFAULT_CONFIG_FILE = $(DEFAULT_CONFIG_DIR)/squid.conf 912 DEFAULT_MIME_TABLE = $( datadir)/mime.conf912 DEFAULT_MIME_TABLE = $(DEFAULT_CONFIG_DIR)/mime.conf 913 913 DEFAULT_SSL_CRTD = $(libexecdir)/`echo ssl_crtd | sed '$(transform);s/$$/$(EXEEXT)/'` 914 914 DEFAULT_LOG_PREFIX = $(DEFAULT_LOG_DIR) -
squid-ssl/trunk/fuentes/src/Makefile.in
r5502 r5503 3258 3258 DEFAULT_CONFIG_DIR = $(sysconfdir) 3259 3259 DEFAULT_CONFIG_FILE = $(DEFAULT_CONFIG_DIR)/squid.conf 3260 DEFAULT_MIME_TABLE = $( datadir)/mime.conf3260 DEFAULT_MIME_TABLE = $(DEFAULT_CONFIG_DIR)/mime.conf 3261 3261 DEFAULT_SSL_CRTD = $(libexecdir)/`echo ssl_crtd | sed '$(transform);s/$$/$(EXEEXT)/'` 3262 3262 DEFAULT_LOG_PREFIX = $(DEFAULT_LOG_DIR) -
squid-ssl/trunk/fuentes/src/cf.data.pre
r5502 r5503 1207 1207 # Adapt to list your (internal) IP networks from where browsing 1208 1208 # should be allowed 1209 #acl localnet src 10.0.0.0/8 # RFC1918 possible internal network1210 #acl localnet src 172.16.0.0/12 # RFC1918 possible internal network1211 #acl localnet src 192.168.0.0/16 # RFC1918 possible internal network1212 #acl localnet src fc00::/7 # RFC 4193 local private network range1213 #acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines1209 acl localnet src 10.0.0.0/8 # RFC1918 possible internal network 1210 acl localnet src 172.16.0.0/12 # RFC1918 possible internal network 1211 acl localnet src 192.168.0.0/16 # RFC1918 possible internal network 1212 acl localnet src fc00::/7 # RFC 4193 local private network range 1213 acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines 1214 1214 1215 1215 acl SSL_ports port 443 … … 1460 1460 # Adapt localnet in the ACL section to list your (internal) IP networks 1461 1461 # from where browsing should be allowed 1462 #http_access allow localnet1462 http_access allow localnet 1463 1463 http_access allow localhost 1464 1464 … … 3211 3211 reference a combined file containing both the 3212 3212 certificate and the key. 3213 3214 Notes:3215 3216 On Debian/Ubuntu systems a default snakeoil certificate is3217 available in /etc/ssl and users can set:3218 3219 cert=/etc/ssl/certs/ssl-cert-snakeoil.pem3220 3221 and3222 3223 key=/etc/ssl/private/ssl-cert-snakeoil.key3224 3225 for testing.3226 3213 3227 3214 sslversion=1|2|3|4|5|6 … … 4547 4534 NAME: logfile_rotate 4548 4535 TYPE: int 4549 DEFAULT: 04536 DEFAULT: 10 4550 4537 LOC: Config.Log.rotateNumber 4551 4538 DOC_START … … 4566 4553 Note, from Squid-3.1 this option is only a default for cache.log, 4567 4554 that log can be rotated separately by using debug_options. 4568 4569 Note2, for Debian/Linux the default of logfile_rotate is4570 zero, since it includes external logfile-rotation methods.4571 4555 DOC_END 4572 4556 … … 5447 5431 refresh_pattern ^gopher: 1440 0% 1440 5448 5432 refresh_pattern -i (/cgi-bin/|\?) 0 0% 0 5449 refresh_pattern (Release|Packages(.gz)*)$ 0 20% 28805450 # example lin deb packages5451 #refresh_pattern (\.deb|\.udeb)$ 129600 100% 1296005452 5433 refresh_pattern . 0 20% 4320 5453 5434 NOCOMMENT_END … … 8916 8897 WARNING: 8917 8898 This option will restrict the situations under which IPv6 8918 connectivity is used (and tested) , potentially hiding network8919 problemswhich would otherwise be detected and warned about.8899 connectivity is used (and tested). Hiding network problems 8900 which would otherwise be detected and warned about. 8920 8901 DOC_END 8921 8902 -
squid-ssl/trunk/fuentes/src/client_side.cc
r5502 r5503 416 416 break; 417 417 418 case LOG_TCP_INM_HIT:419 418 case LOG_TCP_IMS_HIT: 420 419 statCounter.client_http.nearMissSvcTime.count(svc_time); … … 2662 2661 return; 2663 2662 } 2664 2665 // when absolute-URI is provided Host header should be ignored. However2666 // some code still uses Host directly so normalize it.2667 // For now preserve the case where Host is completely absent. That matters.2668 if (request->header.has(HDR_HOST)) {2669 const char *host = request->header.getStr(HDR_HOST);2670 SBuf authority(request->GetHost());2671 if (request->port != urlDefaultPort(request->url.getScheme()))2672 authority.appendf(":%d", request->port);2673 debugs(33, 5, "URL domain " << authority << " overrides header Host: " << host);2674 // URL authority overrides Host header2675 request->header.delById(HDR_HOST);2676 request->header.putStr(HDR_HOST, authority.c_str());2677 }2678 2663 } 2679 2664 -
squid-ssl/trunk/fuentes/src/client_side_reply.h
r5502 r5503 115 115 int checkTransferDone(); 116 116 void processOnlyIfCachedMiss(); 117 boolprocessConditional(StoreIOBuffer &result);117 void processConditional(StoreIOBuffer &result); 118 118 void cacheHit(StoreIOBuffer result); 119 119 void handleIMSReply(StoreIOBuffer result); -
squid-ssl/trunk/fuentes/src/client_side_request.cc
r5502 r5503 142 142 al = new AccessLogEntry; 143 143 al->cache.start_time = current_time; 144 if (aConn) { 145 al->tcpClient = clientConnection = aConn->clientConnection; 146 al->cache.port = aConn->port; 147 al->cache.caddr = aConn->log_addr; 144 al->tcpClient = clientConnection = aConn->clientConnection; 145 al->cache.port = aConn->port; 146 al->cache.caddr = aConn->log_addr; 148 147 149 148 #if USE_OPENSSL 150 if (aConn->clientConnection != NULL && aConn->clientConnection->isOpen()) { 151 if (SSL *ssl = fd_table[aConn->clientConnection->fd].ssl) 152 al->cache.sslClientCert.reset(SSL_get_peer_certificate(ssl)); 153 } 154 #endif 155 } 149 if (aConn->clientConnection != NULL && aConn->clientConnection->isOpen()) { 150 if (SSL *ssl = fd_table[aConn->clientConnection->fd].ssl) 151 al->cache.sslClientCert.reset(SSL_get_peer_certificate(ssl)); 152 } 153 #endif 156 154 dlinkAdd(this, &active, &ClientActiveRequests); 157 155 #if USE_ADAPTATION -
squid-ssl/trunk/fuentes/src/esi/Context.h
r5502 r5503 14 14 #include "esi/Element.h" 15 15 #include "esi/Parser.h" 16 #include "HttpReply.h"17 16 #include "http/StatusCode.h" 18 17 … … 93 92 Http::StatusCode errorstatus; /* if we error, what code to return */ 94 93 char *errormessage; /* error to pass to error page */ 95 HttpReply ::Pointerrep; /* buffered until we pass data downstream */94 HttpReply *rep; /* buffered until we pass data downstream */ 96 95 ESISegment::Pointer buffered; /* unprocessed data - for whatever reason */ 97 96 ESISegment::Pointer incoming; -
squid-ssl/trunk/fuentes/src/esi/Esi.cc
r5502 r5503 574 574 #endif 575 575 576 if (!(rep != NULL|| (outbound.getRaw() &&576 if (!(rep || (outbound.getRaw() && 577 577 outbound->len && (outbound_offset <= outbound->len)))) { 578 578 debugs(86, 5, "ESIContext::send: Nothing to send."); … … 619 619 debugs(86, 5, "ESIContext::send: this=" << this << " Client no longer wants data "); 620 620 /* Deal with re-entrancy */ 621 HttpReply ::Pointertemprep = rep;621 HttpReply *temprep = rep; 622 622 rep = NULL; /* freed downstream */ 623 623 624 if (temprep != NULL&& varState)625 varState->buildVary (temprep.getRaw());624 if (temprep && varState) 625 varState->buildVary (temprep); 626 626 627 627 { … … 630 630 tempBuffer.offset = pos - len; 631 631 tempBuffer.data = next->readBuffer.data; 632 clientStreamCallback (thisNode, http, temprep .getRaw(), tempBuffer);632 clientStreamCallback (thisNode, http, temprep, tempBuffer); 633 633 } 634 634 … … 967 967 int specifiedattcount = attrCount * 2; 968 968 char *position; 969 Must(ellen < sizeof(localbuf)); /* prevent unexpected overruns. */969 assert (ellen < sizeof (localbuf)); /* prevent unexpected overruns. */ 970 970 971 971 debugs(86, 5, "ESIContext::Start: element '" << el << "' with " << specifiedattcount << " tags"); … … 981 981 localbuf[0] = '<'; 982 982 localbuf[1] = '\0'; 983 xstrncpy(&localbuf[1], el, sizeof(localbuf) - 2);983 assert (xstrncpy (&localbuf[1], el, sizeof(localbuf) - 2)); 984 984 position = localbuf + strlen (localbuf); 985 985 986 986 for (i = 0; i < specifiedattcount && attr[i]; i += 2) { 987 Must(static_cast<size_t>(position - localbuf) < sizeof(localbuf) - 1);988 987 *position = ' '; 989 988 ++position; 990 989 /* TODO: handle thisNode gracefully */ 991 xstrncpy(position, attr[i], sizeof(localbuf) - (position - localbuf));990 assert (xstrncpy (position, attr[i], sizeof(localbuf) + (position - localbuf))); 992 991 position += strlen (position); 993 Must(static_cast<size_t>(position - localbuf) < sizeof(localbuf) - 2);994 992 *position = '='; 995 993 ++position; … … 1000 998 while ((ch = *chPtr++) != '\0') { 1001 999 if (ch == '\"') { 1002 Must(static_cast<size_t>(position - localbuf) < sizeof(localbuf) - 6); 1003 xstrncpy(position, """, sizeof(localbuf) - (position-localbuf)); 1000 assert( xstrncpy(position, """, sizeof(localbuf) + (position-localbuf)) ); 1004 1001 position += 6; 1005 1002 } else { 1006 Must(static_cast<size_t>(position - localbuf) < sizeof(localbuf) - 1);1007 1003 *position = ch; 1008 1004 ++position; 1009 1005 } 1010 1006 } 1011 Must(static_cast<size_t>(position - localbuf) < sizeof(localbuf) - 1);1007 position += strlen (position); 1012 1008 *position = '\"'; 1013 1009 ++position; 1014 1010 } 1015 1011 1016 Must(static_cast<size_t>(position - localbuf) < sizeof(localbuf) - 2);1017 1012 *position = '>'; 1018 1013 ++position; … … 1100 1095 1101 1096 case ESIElement::ESI_ELEMENT_NONE: 1102 Must(ellen < sizeof(localbuf) - 3); /* prevent unexpected overruns. */1097 assert (ellen < sizeof (localbuf)); /* prevent unexpected overruns. */ 1103 1098 /* Add elements we aren't interested in */ 1104 1099 localbuf[0] = '<'; 1105 1100 localbuf[1] = '/'; 1106 xstrncpy(&localbuf[2], el, sizeof(localbuf) - 3);1101 assert (xstrncpy (&localbuf[2], el, sizeof(localbuf) - 3)); 1107 1102 position = localbuf + strlen (localbuf); 1108 1103 *position = '>'; … … 1260 1255 } 1261 1256 1262 if (rep != NULL&& !parserState.inited())1257 if (rep && !parserState.inited()) 1263 1258 parserState.init(this); 1264 1259 … … 1399 1394 debugs(86, 5, HERE << "Freeing for this=" << this); 1400 1395 1401 rep = NULL; // refcounted1396 HTTPMSGUNLOCK(rep); 1402 1397 1403 1398 finishChildren (); -
squid-ssl/trunk/fuentes/src/icmp/Icmp6.cc
r5502 r5503 257 257 258 258 ip = (struct ip6_hdr *) pkt; 259 NP: echo size needs to +sizeof(ip6_hdr);259 pkt += sizeof(ip6_hdr); 260 260 261 261 debugs(42, DBG_CRITICAL, HERE << "ip6_nxt=" << ip->ip6_nxt << … … 268 268 269 269 icmp6header = (struct icmp6_hdr *) pkt; 270 pkt += sizeof(icmp6_hdr); 270 271 271 272 if (icmp6header->icmp6_type != ICMP6_ECHO_REPLY) { … … 292 293 } 293 294 294 echo = (icmpEchoData *) (pkt + sizeof(icmp6_hdr));295 echo = (icmpEchoData *) pkt; 295 296 296 297 preply.opcode = echo->opcode; -
squid-ssl/trunk/fuentes/src/mime_header.cc
r5502 r5503 37 37 debugs(25, 5, "mime_get_header: looking for '" << name << "'"); 38 38 39 for (p = mime; *p; p += strcspn(p, "\n ")) {40 if (strcmp(p, "\ n\r\n") == 0 || strcmp(p, "\n\n") == 0)39 for (p = mime; *p; p += strcspn(p, "\n\r")) { 40 if (strcmp(p, "\r\n\r\n") == 0 || strcmp(p, "\n\n") == 0) 41 41 return NULL; 42 42 43 if (*p == '\n')43 while (xisspace(*p)) 44 44 ++p; 45 45 -
squid-ssl/trunk/fuentes/src/tests/stub_cbdata.cc
r5502 r5503 14 14 15 15 void cbdataRegisterWithCacheManager(void) STUB 16 void *cbdataInternalAlloc(cbdata_type type, const char *, int sz) { 17 return xcalloc(1, sz); 18 } 19 void *cbdataInternalFree(void *p, const char *, int) { 20 xfree(p); 21 return NULL; 22 } 16 23 17 #if USE_CBDATA_DEBUG 24 18 void *cbdataInternalAllocDbg(cbdata_type type, const char *, int) STUB_RETVAL(NULL) -
squid-ssl/trunk/fuentes/src/tests/stub_mem.cc
r5502 r5503 15 15 #define STUB_API "stub_mem.cc" 16 16 #include "Mem.h" 17 #include " tests/STUB.h"17 #include "STUB.h" 18 18 19 19 void -
squid-ssl/trunk/fuentes/tools/Makefile.am
r5502 r5503 35 35 cp $(top_srcdir)/src/tests/stub_debug.cc . 36 36 37 MemBuf.cc: $(top_srcdir)/src/MemBuf.cc38 cp $(top_srcdir)/src/MemBuf.cc $@39 40 37 time.cc: $(top_srcdir)/src/time.cc 41 38 cp $(top_srcdir)/src/time.cc . 42 43 stub_cbdata.cc: $(top_srcdir)/src/tests/stub_cbdata.cc44 cp $(top_srcdir)/src/tests/stub_cbdata.cc $@45 46 stub_mem.cc: $(top_srcdir)/src/tests/stub_mem.cc47 cp $(top_srcdir)/src/tests/stub_mem.cc $@48 39 49 40 # stock tools for unit tests - library independent versions of dlink_list … … 52 43 # Neither of these should be disted from here. 53 44 TESTSOURCES= test_tools.cc 54 CLEANFILES += test_tools.cc MemBuf.cc stub_debug.cc time.cc stub_cbdata.cc stub_mem.cc45 CLEANFILES += test_tools.cc stub_debug.cc time.cc 55 46 56 47 ## ##### helper-mux ##### … … 70 61 71 62 cachemgr__CGIEXT__SOURCES = cachemgr.cc \ 72 MemBuf.cc \73 stub_cbdata.cc \74 63 stub_debug.cc \ 75 stub_mem.cc \76 64 test_tools.cc \ 77 65 time.cc -
squid-ssl/trunk/fuentes/tools/cachemgr.cc
r5502 r5503 12 12 #include "html_quote.h" 13 13 #include "ip/Address.h" 14 #include "MemBuf.h"15 14 #include "rfc1123.h" 16 15 #include "rfc1738.h" … … 425 424 } 426 425 427 static void428 munge_menu_line( MemBuf &out,const char *buf, cachemgr_request * req)426 static const char * 427 munge_menu_line(const char *buf, cachemgr_request * req) 429 428 { 430 429 char *x; … … 434 433 char *a_url; 435 434 char *buf_copy; 436 437 const char bufLen = strlen(buf); 438 if (bufLen < 1 || *buf != ' ') { 439 out.append(buf, bufLen); 440 return; 441 } 442 443 buf_copy = x = xstrndup(buf, bufLen); 435 static char html[2 * 1024]; 436 437 if (strlen(buf) < 1) 438 return buf; 439 440 if (*buf != ' ') 441 return buf; 442 443 buf_copy = x = xstrdup(buf); 444 444 445 445 a = xstrtok(&x, '\t'); … … 453 453 /* no reason to give a url for a disabled action */ 454 454 if (!strcmp(p, "disabled")) 455 out.Printf("<LI type=\"circle\">%s (disabled)<A HREF=\"%s\">.</A>\n", d, a_url);455 snprintf(html, sizeof(html), "<LI type=\"circle\">%s (disabled)<A HREF=\"%s\">.</A>\n", d, a_url); 456 456 else 457 457 /* disable a hidden action (requires a password, but password is not in squid.conf) */ 458 458 if (!strcmp(p, "hidden")) 459 out.Printf("<LI type=\"circle\">%s (hidden)<A HREF=\"%s\">.</A>\n", d, a_url);459 snprintf(html, sizeof(html), "<LI type=\"circle\">%s (hidden)<A HREF=\"%s\">.</A>\n", d, a_url); 460 460 else 461 461 /* disable link if authentication is required and we have no password */ 462 462 if (!strcmp(p, "protected") && !req->passwd) 463 out.Printf("<LI type=\"circle\">%s (requires <a href=\"%s\">authentication</a>)<A HREF=\"%s\">.</A>\n",464 463 snprintf(html, sizeof(html), "<LI type=\"circle\">%s (requires <a href=\"%s\">authentication</a>)<A HREF=\"%s\">.</A>\n", 464 d, menu_url(req, "authenticate"), a_url); 465 465 else 466 466 /* highlight protected but probably available entries */ 467 467 if (!strcmp(p, "protected")) 468 out.Printf("<LI type=\"square\"><A HREF=\"%s\"><font color=\"#FF0000\">%s</font></A>\n",469 468 snprintf(html, sizeof(html), "<LI type=\"square\"><A HREF=\"%s\"><font color=\"#FF0000\">%s</font></A>\n", 469 a_url, d); 470 470 471 471 /* public entry or unknown type of protection */ 472 472 else 473 out.Printf("<LI type=\"disk\"><A HREF=\"%s\">%s</A>\n", a_url, d);473 snprintf(html, sizeof(html), "<LI type=\"disk\"><A HREF=\"%s\">%s</A>\n", a_url, d); 474 474 475 475 xfree(a_url); 476 476 477 477 xfree(buf_copy); 478 } 479 480 static void 481 munge_other_line(MemBuf &out, const char *buf, cachemgr_request *) 478 479 return html; 480 } 481 482 static const char * 483 munge_other_line(const char *buf, cachemgr_request * req) 482 484 { 483 485 static const char *ttags[] = {"td", "th"}; 484 486 487 static char html[4096]; 485 488 static int table_line_num = 0; 486 489 static int next_is_header = 0; … … 489 492 char *buf_copy; 490 493 char *x, *p; 494 int l = 0; 491 495 /* does it look like a table? */ 492 496 493 497 if (!strchr(buf, '\t') || *buf == '\t') { 494 498 /* nope, just text */ 495 if (table_line_num) 496 out.append("</table>\n<pre>", 14); 497 out.Printf("%s", html_quote(buf)); 499 snprintf(html, sizeof(html), "%s%s", 500 table_line_num ? "</table>\n<pre>" : "", html_quote(buf)); 498 501 table_line_num = 0; 499 return ;502 return html; 500 503 } 501 504 502 505 /* start html table */ 503 506 if (!table_line_num) { 504 out.append("</pre><table cellpadding=\"2\" cellspacing=\"1\">\n", 46);507 l += snprintf(html + l, sizeof(html) - l, "</pre><table cellpadding=\"2\" cellspacing=\"1\">\n"); 505 508 next_is_header = 0; 506 509 } … … 512 515 513 516 /* record starts */ 514 out.append("<tr>", 4);517 l += snprintf(html + l, sizeof(html) - l, "<tr>"); 515 518 516 519 /* substitute '\t' */ … … 529 532 } 530 533 531 out.Printf("<%s colspan=\"%d\" align=\"%s\">%s</%s>",532 ttag, column_span,533 is_header ? "center" : is_number(cell) ? "right" : "left",534 html_quote(cell), ttag);534 l += snprintf(html + l, sizeof(html) - l, "<%s colspan=\"%d\" align=\"%s\">%s</%s>", 535 ttag, column_span, 536 is_header ? "center" : is_number(cell) ? "right" : "left", 537 html_quote(cell), ttag); 535 538 } 536 539 537 540 xfree(buf_copy); 538 541 /* record ends */ 539 out.append("</tr>\n", 6);542 snprintf(html + l, sizeof(html) - l, "</tr>\n"); 540 543 next_is_header = is_header && strstr(buf, "\t\t"); 541 544 ++table_line_num; 545 return html; 542 546 } 543 547 … … 696 700 697 701 case isBody: 698 {699 702 /* interpret [and reformat] cache response */ 700 MemBuf out; 701 out.init(); 703 702 704 if (parse_menu) 703 munge_menu_line(out, buf, req);705 fputs(munge_menu_line(buf, req), stdout); 704 706 else 705 munge_other_line(out, buf, req); 706 707 fputs(out.buf, stdout); 708 } 709 break; 707 fputs(munge_other_line(buf, req), stdout); 708 709 break; 710 710 711 711 case isForward:
Note: See TracChangeset
for help on using the changeset viewer.