]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
10 years agoDo not blindly forward cache peer CONNECT responses.
Alex Rousskov [Sun, 28 Jun 2015 14:08:31 +0000 (07:08 -0700)] 
Do not blindly forward cache peer CONNECT responses.

Squid blindly forwards cache peer CONNECT responses to clients. This
may break things if the peer responds with something like HTTP 403
(Forbidden) and keeps the connection with Squid open:
  -  The client application issues a CONNECT request.
  -  Squid forwards this request to a cache peer.
  -  Cache peer correctly responds back with a "403 Forbidden".
  -  Squid does not parse cache peer response and
     just forwards it as if it was a Squid response to the client.
  -  The TCP connections are not closed.

At this stage, Squid is unaware that the CONNECT request has failed. All
subsequent requests on the user agent TCP connection are treated as
tunnelled traffic. Squid is forwarding these requests to the peer on the
TCP connection previously used for the 403-ed CONNECT request, without
proper processing. The additional headers which should have been applied
by Squid to these requests are not applied, and the requests are being
forwarded to the cache peer even though the Squid configuration may
state that these requests must go directly to the origin server.

This fixes Squid to parse cache peer responses, and if an error response
found, respond with "502 Bad Gateway" to the client and close the
connections.

10 years agoInitialize TunnelStateData::started in ctor (Coverity defect 1222663)
Francesco Chemolli [Sat, 27 Jun 2015 17:13:26 +0000 (19:13 +0200)] 
Initialize TunnelStateData::started in ctor (Coverity defect 1222663)

10 years agoUse relative-URL in errorpage.css for SN.png
Amos Jeffries [Tue, 23 Jun 2015 09:21:06 +0000 (02:21 -0700)] 
Use relative-URL in errorpage.css for SN.png

Modern browsers now seem to be accepting relative-URLs, and Squid
global_internal_static non-https:// URLs are working. So we can do this
now without as many failures.

10 years agoBug 4193: Memory leak on FTP listings
Matthias Pitzl [Mon, 22 Jun 2015 11:52:31 +0000 (04:52 -0700)] 
Bug 4193: Memory leak on FTP listings

10 years agoReplace GNU atomics and related hacks with C++11 std::atomic
Amos Jeffries [Mon, 22 Jun 2015 11:29:39 +0000 (04:29 -0700)] 
Replace GNU atomics and related hacks with C++11 std::atomic

With C++11 atomic support by the stdlib is not optional. This
resolves issues determining whether GNU atomics are available,
operational 32-bit vs 64-bit, or cross-compiling (bug 4224).

10 years agoMerged from trunk
Amos Jeffries [Mon, 22 Jun 2015 04:14:58 +0000 (21:14 -0700)] 
Merged from trunk

10 years agoBug 4274: ssl_crtd.8 not being installed
Amos Jeffries [Sun, 21 Jun 2015 02:48:59 +0000 (19:48 -0700)] 
Bug 4274: ssl_crtd.8 not being installed

10 years agoFix uninitialized variable after rev.14113
Amos Jeffries [Sat, 20 Jun 2015 00:29:06 +0000 (17:29 -0700)] 
Fix uninitialized variable after rev.14113

 Detected by Coverity Scan. Issue 1307733.

10 years agoFix CONNECT failover to IPv4 after trying broken IPv6 servers
Amos Jeffries [Sat, 20 Jun 2015 00:24:24 +0000 (17:24 -0700)] 
Fix CONNECT failover to IPv4 after trying broken IPv6 servers

This makes CONNECT tunnel connection attempts obey forward_timeout
and continue retrying instead of aborting with a client error when one
possible server hits a connect_timeout.

10 years agoFixed segmentation fault when freeing https_port clientca on reconfigure
Alex Rousskov [Fri, 19 Jun 2015 16:57:30 +0000 (10:57 -0600)] 
Fixed segmentation fault when freeing https_port clientca on reconfigure
or exit.

AnyP::PortCfg::clientCA list was double-freed because the SSL context takes
ownership of the STACK_OF(X509_NAME) supplied via SSL_CTX_set_client_CA_list(),
but Squid was not aware of that. Squid now supplies a clone of clientCA.

10 years agoSourceFormat Enforcement
Source Maintenance [Fri, 19 Jun 2015 12:12:10 +0000 (12:12 +0000)] 
SourceFormat Enforcement

10 years agoBug 4269: ignore-must-revalidate broken
Amos Jeffries [Fri, 19 Jun 2015 07:13:57 +0000 (00:13 -0700)] 
Bug 4269: ignore-must-revalidate broken

ignore-must-revalidate appears to prevent revalidation by disabling
storage of objects with must-revalidate/proxy-revalidate header.

However it was also preventing revalidation of objects cached due to
ignore-private, or the presence of no-cache, s-maxage, and use of auth
credentials.

Remove the violation option entirely.

Also cleanup the documentation of ignore-auth which was removed earlier.

10 years agoSupport Ephemeral Elliptic Curve Diffie-Hellman (EECDH) key exchange
Paulo Matias [Fri, 19 Jun 2015 04:57:39 +0000 (21:57 -0700)] 
Support Ephemeral Elliptic Curve Diffie-Hellman (EECDH) key exchange

Which allows for forward secrecy with better performance than traditional
ephemeral DH.

Also replaces http(s)_port dhparams= option with tls-dh= that takes a
curve name as well as filename for curve parameters.

10 years agoHardening against CVE-2009-3555
Paulo Matias [Fri, 19 Jun 2015 03:37:47 +0000 (20:37 -0700)] 
Hardening against CVE-2009-3555

Disable client-initiated renegotiation, mitigating a DoS attack which
might be possible with some builds of the OpenSSL library.

10 years agoparser-ng: Add HTTP/1.x extension tokenizer
Amos Jeffries [Fri, 19 Jun 2015 01:22:22 +0000 (18:22 -0700)] 
parser-ng: Add HTTP/1.x extension tokenizer

Adds a class Http1::Tokenizer, which inherits from ::Parser::Tokenizer
and presents additional HTTP-specific token parsing methods.

At present it extends for the quoted-string, 1#( token/ quoted-string ),
and qdtext constructs from RFC 7230 and RFC 1945.

It can also cope with charset and quoted-pair escaping differences in
qdtext between RFC 1945 and RFC 7230. The un-escaped form of token is
returned.

10 years agoCleanup: use SBuf to store MimeIcon filename
Amos Jeffries [Thu, 18 Jun 2015 15:11:24 +0000 (08:11 -0700)] 
Cleanup: use SBuf to store MimeIcon filename

10 years agoTranslations: add Spanish US dialect alias
Amos Jeffries [Mon, 15 Jun 2015 23:58:25 +0000 (11:58 +1200)] 
Translations: add Spanish US dialect alias

10 years agoCleanup: replace __DATE__ and __TIME__ macros
Amos Jeffries [Sun, 14 Jun 2015 22:11:46 +0000 (15:11 -0700)] 
Cleanup: replace __DATE__ and __TIME__ macros

... with code VERSION and SQUID_BUILD_INFO maros.

This allows separately built binaries to be compared for equivalence. A
small security check, but useful.

10 years agoslash-escape is 0x5C
Amos Jeffries [Tue, 9 Jun 2015 14:46:15 +0000 (07:46 -0700)] 
slash-escape is 0x5C

10 years agoUse Http1::Tokenizer in TeChunkedParser
Amos Jeffries [Tue, 9 Jun 2015 12:21:49 +0000 (05:21 -0700)] 
Use Http1::Tokenizer in TeChunkedParser

... in particular to compliantly parse chunk-ext with token/quoted-string

10 years agoBug 1961 partial: Move HttpRequest host:port to class URL
Amos Jeffries [Tue, 9 Jun 2015 06:14:43 +0000 (23:14 -0700)] 
Bug 1961 partial: Move HttpRequest host:port to class URL

Moves the host:port authority details into class URL for more
modular URI management. Add URL::authority() member to generate
authority-form URIs from the class URL stored details.

Also, shuffle urlDefaultPort() to AnyP::UriScheme::defaultPort()

10 years agoMerge from trunk rev.14108
Amos Jeffries [Tue, 9 Jun 2015 01:59:58 +0000 (18:59 -0700)] 
Merge from trunk rev.14108

10 years agoParser-NG: Transfer-Encoding:chunked Parser
Amos Jeffries [Tue, 9 Jun 2015 01:54:56 +0000 (18:54 -0700)] 
Parser-NG: Transfer-Encoding:chunked Parser

Remove several performance regressions incurred in earlier Parser-NG
updates by refactoring the class ChunkedCodingParser to a class
Http1::TeChunkedParser which parses an SBuf I/O buffer for chunked
encoding data and (for now) copies the chunk payloads into a MemBuf buffer.

The new class is inherited from Http1::Parser and presents the same API.
Chunk Trailers are now available via the Parser API mimeHeader() method
- although none of the rest of Squid makes use of that data yet. It
implements parsing using a ::Parser::Tokenizer for (nearly) compliant
protocol tokenization. With enumerated states instead of a dynamic
function-pointer chain.

Measurements:
 Co-Advisor shows no compliance change.
 Polygraph shows approx 1% speed improvement over trunk.

10 years agoCleanup after rev.14102
Amos Jeffries [Fri, 5 Jun 2015 23:45:06 +0000 (16:45 -0700)] 
Cleanup after rev.14102

10 years agoSourceFormat Enforcement
Source Maintenance [Fri, 5 Jun 2015 06:12:06 +0000 (06:12 +0000)] 
SourceFormat Enforcement

10 years agoSourceLayout: convert helper stats display to Packable API
Amos Jeffries [Fri, 5 Jun 2015 05:56:36 +0000 (22:56 -0700)] 
SourceLayout: convert helper stats display to Packable API

Requires unifying the classes Helper::Request queues which incidentally
also brings stateful helpers closer to concurrency support

10 years agoWrong intialization value for clientReplyContext::headers_sz member
Christos Tsantilas [Wed, 3 Jun 2015 17:24:41 +0000 (20:24 +0300)] 
Wrong intialization value for clientReplyContext::headers_sz member

The clientReplyContext::headers_sz member after the trunk patch r14078
initialized to wrong value. In many cases inside clientReplyContext class
this is considered as initialized to "0" and setting to "-1" can cause
problems.

This is a Measurement Factory project

10 years agoSourceFormat Enforcement
Source Maintenance [Wed, 3 Jun 2015 12:12:07 +0000 (12:12 +0000)] 
SourceFormat Enforcement

10 years agoSquid Assertion String.cc:221: "str"
Christos Tsantilas [Wed, 3 Jun 2015 11:12:40 +0000 (14:12 +0300)] 
Squid Assertion String.cc:221: "str"

This bug can be caused by certificates does not contain a CN field. In this
case the Ssl::ErrorDetail::cn method may return NULL causing this assertion
somewhere inside Ssl::ErrorDetail::buildDetail method, which expects always
a non NULL value from Ssl::ErrorDetail::cn and similar methods.

This patch try to hardening the Ssl::ErrorDetail error formating functions to
avoid always check for NULL values and also avoid sending wrong information
for various certificate fields in the case of an error while extracting the
information from certificate..

This is a Measurement Factory project

10 years agoFix Squid Assertion comm.cc:759: "Comm::IsConnOpen(conn)"
Christos Tsantilas [Wed, 3 Jun 2015 10:42:08 +0000 (13:42 +0300)] 
Fix Squid Assertion comm.cc:759: "Comm::IsConnOpen(conn)"

This is a squid Assertion inside ConnStateData::getSslContextDone while setting timeout. The reason is that the ConnStateData::clientConnection connection may
closed while waiting response from ssl_crtd helper.

This is a Measurement Factory project

10 years agoBug 3875: bad mimeLoadIconFile error handling
Amos Jeffries [Tue, 2 Jun 2015 23:27:26 +0000 (16:27 -0700)] 
Bug 3875: bad mimeLoadIconFile error handling

Improve the MimeIcon reliability when filesystem I/O errors or others
cause the icon data to not be loadable.

The loading process is re-worked to guarantee that once the
MimeIon::created callback occurs it will result in a valid StoreEntry in
the cache representing the wanted icon.

* If the image can be loaded without any issues it will be placed in
the cache as a 200 response.

* If errors prevent the image being loaded or necessary parameters
(size and mtime) being known a 204 object will be placed into the cache.

NP: There is no clear agreement on 204 being 'the best' status for this
case. 500 Internal Error is also appropriate. I have use 204 since:

* the bug is not in the clients request (eliminating 400, 404, etc),
* a 500 would be revealing details about server internals unnecessarily
   often and incur extra complexity creating the error page.
* 204 also avoids needing to send Content-Length, Cache-Control header
  and body object (bandwidth saving over 500 status).

NP: This started with just correcting the errno usage, but other bugs
promptly started appearing once I got to seriously testing this load
process. So far it fixes:
* several assertions resulting from StoreEntry being left invalid in
  cache limbo beween created hash entries and valid mem_obj data.
* repeated attempts on startup to load absent icons files which dont
  exist in the filesystem.
* buffer overfow on misconfigured or corrupt mime.conf file entries
* incorrect debugs messages about file I/O errors
* large error pages delivered when icons not installed (when it does
  not assert from the StoreEntry)

10 years agoRemove unused Atomic::Word and GNU atomics
Amos Jeffries [Tue, 2 Jun 2015 23:04:21 +0000 (16:04 -0700)] 
Remove unused Atomic::Word and GNU atomics

10 years agoConvert MemMap to std::atomic
Amos Jeffries [Tue, 2 Jun 2015 15:41:52 +0000 (08:41 -0700)] 
Convert MemMap to std::atomic

10 years agoConvert Ipc::Queue to std::atomic
Amos Jeffries [Tue, 2 Jun 2015 15:28:56 +0000 (08:28 -0700)] 
Convert Ipc::Queue to std::atomic

10 years agoSourceFormat Enforcement
Source Maintenance [Tue, 2 Jun 2015 12:12:06 +0000 (12:12 +0000)] 
SourceFormat Enforcement

10 years agosupport custom OIDs in *_cert ACLs
Christos Tsantilas [Tue, 2 Jun 2015 12:04:00 +0000 (15:04 +0300)] 
support custom OIDs in *_cert ACLs

This patch allow user_cert and ca_cert ACLs to match arbitrary stand-alone OIDs
(not DN/C/O/CN/L/ST objects or their substrings). For example, should be able to
match certificates that have 1.3.6.1.4.1.1814.3.1.14 OID in the certificate
Subject or Issuer field. Squid configuration would look like this:

 acl User_Cert-TrustedCustomerNum user_cert 1.3.6.1.4.1.1814.3.1.14 1001

This is a Measurement Factory project

10 years agoConvert StoreMap to std::atomic
Amos Jeffries [Tue, 2 Jun 2015 11:05:22 +0000 (04:05 -0700)] 
Convert StoreMap to std::atomic

Implemented copy-constructor and assignment operator for StoreMapSlice
since the default ones used by AtomicWord were not thread safe and
C++11 explicitly deletes them for std::atomic.

10 years agoBug3329: The server side pinned connection is not closed properly
Christos Tsantilas [Tue, 2 Jun 2015 10:15:06 +0000 (13:15 +0300)] 
Bug3329: The server side pinned connection is not closed properly
in ConnStateData::clientPinnedConnectionClosed CommClose handler.

Squid enters a buggy state when an idle connection pinned to a peer closes:

 - The ConnStateData::clientPinnedConnectionRead, the pinned peer
   connection read handler, is called with the io.flag set to
   Comm::ERR_CLOSING. The read handler does not close the peer
   Comm::Connection object. This is correct and expected -- the I/O
   handler must exit on ERR_CLOSING without doing anything.

 - The ConnStateData::clientPinnedConnectionClosed close handler is called,
   but it does not close the peer Comm::Connection object either. Again,
   this is correct and expected -- the close handler is not the place to
   close a being-closed connection.

 - The corresponding fde object is marked as closed (fde::flags.open
   is false), but the peer Comm::Connection object is still open
   (Comm::Connection.fd >= 0)! From this point on, we have an inconsistency
   between the peer Comm::Connection object state and the real world.

 - When the ConnStateData::pinning::serverConnection object is later
   destroyed (by refcounting), it will try to close its fd. If that fd
   is already in use (e.g., by another Comm::Connection), bad things
   happen (crashes, segfaults, etc). Otherwise (i.e., if that fd is
   not open), comm_close may cry about BUG 3556 (or worse).

To fix this problem, we must not allow Comm::Connections to get out
of sync with fd_table, even when a descriptor is closed without going
through Connection::close(). There are two ways to accomplished that:

 * Change Comm to always store Comm::Connections and similar high-level
   objects instead of fdes. This is a huge change that has been long on
   the TODO list (those "other high-level objects" is on of the primary
   obstacles there because not everything with a FD is a Connection).

 * Notify Comm::Connections about closure in their closing handlers
   (this change). This design relies on every Comm::Connection having
   a close handler that notifies it. It may take us some time to reach
   that goal, but this change is the first step providing the necessary
   API, a known bug fix, and a few preventive changes.

This change:

 - Adds a new Comm::Connection::noteClosure() method to inform the
   Comm::Connection object that somebody is closing its FD.

 - Uses the new method inside ConnStateData::clientPinnedConnectionClosed
   handler to inform the ConnStateData::pinning::serverConnection object
   that its FD is being closed.

 - Replaces comm_close calls which may cause bug #3329 in other places with
   Comm::Connection->close() calls.

Initially based on Nathan Hoad research for bug 3329.

This is a Measurement Factory project.

10 years agoConvert ReadWriteLock to std::atomic
Amos Jeffries [Tue, 2 Jun 2015 10:04:27 +0000 (03:04 -0700)] 
Convert ReadWriteLock to std::atomic

10 years agoRefactor Ipc::Mem::PagePool using std::atomic
Amos Jeffries [Tue, 2 Jun 2015 09:14:22 +0000 (02:14 -0700)] 
Refactor Ipc::Mem::PagePool using std::atomic

10 years agoRefactor Ipc::Mem::PageStack using std::atomic
Amos Jeffries [Tue, 2 Jun 2015 08:21:08 +0000 (01:21 -0700)] 
Refactor Ipc::Mem::PageStack using std::atomic

10 years agoRename ChunkedCodingParser to TeChunkedParser
Amos Jeffries [Mon, 1 Jun 2015 21:41:37 +0000 (14:41 -0700)] 
Rename ChunkedCodingParser to TeChunkedParser

10 years agoMerged from trunk rev.14096
Amos Jeffries [Mon, 1 Jun 2015 06:21:54 +0000 (23:21 -0700)] 
Merged from trunk rev.14096

10 years agoFix eCAP issues after rev.14093
Amos Jeffries [Fri, 29 May 2015 10:16:18 +0000 (03:16 -0700)] 
Fix eCAP issues after rev.14093

10 years agoPrep for 3.5.5
Amos Jeffries [Thu, 28 May 2015 10:38:56 +0000 (03:38 -0700)] 
Prep for 3.5.5

10 years agoSourceFormat Enforcement
Source Maintenance [Tue, 26 May 2015 18:12:08 +0000 (18:12 +0000)] 
SourceFormat Enforcement

10 years agoReplace Packer object API with Packable API
Amos Jeffries [Tue, 26 May 2015 17:25:04 +0000 (10:25 -0700)] 
Replace Packer object API with Packable API

Majority of thost patch is symbol renaming to unify the
class method names to the Packable API names.

There is effectively no logical change in this patch
despite appearances because it replaces the Packer object
which provides methods which are just wrappers pointing
to static functions which are in turn wrappers pointing
to storage buffer object methods. With direct calls to
those storage object methods (renamed).

We can now interchangebly use MemBuf or StoreEntry objects
with the packInto(Packable *) functions. Or any other
object which inherits and implements the Packable API.

We also gain 0.1% in performance (+2 RPS) by avoiding the
layers of wrapper funcions and Packer object allocate /
deallocate cycles.

10 years agoCleanu: Remove dead Packer API
Amos Jeffries [Tue, 26 May 2015 09:18:13 +0000 (02:18 -0700)] 
Cleanu: Remove dead Packer API

Also includes some Packable API polishing. No logical changes.

10 years agoUse StoreEntry Packable API directly without class Packer wrapper
Amos Jeffries [Mon, 25 May 2015 14:02:29 +0000 (07:02 -0700)] 
Use StoreEntry Packable API directly without class Packer wrapper

10 years agoC++11: migrate auto_ptr to unique_ptr
Amos Jeffries [Sat, 23 May 2015 20:17:16 +0000 (13:17 -0700)] 
C++11: migrate auto_ptr to unique_ptr

Improving the backward compatibility workaround for older compilers.

This is required for GCC 5.x which does not include any auto_ptr support
or compatibility at all.

10 years agoPortability: Define nullptr if not provided
Amos Jeffries [Sat, 23 May 2015 12:24:21 +0000 (05:24 -0700)] 
Portability: Define nullptr if not provided

For use building with non-C++11 compilers, or broken stdlib definitions.
In the absence of nullptr we define it to be a synonym for NULL.

Also, removethe old hack defining NULL in terms of nullptr. It has never
worked properly and C++11 compilers define NULL explicitly.

10 years agoCleanup: remove unnecessary if-conditions
Amos Jeffries [Sat, 23 May 2015 05:10:00 +0000 (22:10 -0700)] 
Cleanup: remove unnecessary if-conditions

krb5 credentials objects were being checked fro NULL before freeing in
several cases where they should not be. Use assert() instead to enforce
the expected behaviour.

 Detected by Coverity Scan. Issue 1250265

10 years agoCleanup: duplicate includes in icap/Xaction.h
Amos Jeffries [Sat, 23 May 2015 03:16:46 +0000 (20:16 -0700)] 
Cleanup: duplicate includes in icap/Xaction.h

10 years agoFix segmentation fault inside Adaptation::Icap::Xaction::swanSong
Christos Tsantilas [Fri, 22 May 2015 17:21:48 +0000 (20:21 +0300)] 
Fix segmentation fault inside Adaptation::Icap::Xaction::swanSong

The Adaptation::Icap::Xaction::swanSong may try to use an invalid
Icap::Xaction::cs object (Comm::ConnOpener object) if the  Comm::ConnOpener
is already gone (because its job finished) but the  Xaction::noteCommConnected
method is not called yet.

This patch makes the Adaptation::Icap::Xaction::cs object a CbcPointer instead
of a raw pointer and checks if the Xaction::cs object is still valid before
using it.

This is a Measurement Factory project

10 years agoPortability: Define C++11 uniform distributions if missing
Amos Jeffries [Fri, 22 May 2015 15:43:19 +0000 (08:43 -0700)] 
Portability: Define C++11 uniform distributions if missing

Older compilers standard libraries may not contain the uniform
distribution templates now used. But we may be able to use the TR1
distributions instead.

10 years agoC++11: compiler support is now mandatory
Amos Jeffries [Fri, 22 May 2015 13:59:49 +0000 (06:59 -0700)] 
C++11: compiler support is now mandatory

We are now using too many C++11 features to go without proper support in
the compiler. Present ./configure time errors if support for -std=c++11
is missing.

10 years agoCrypto-NG: update random number generators
Amos Jeffries [Fri, 22 May 2015 13:33:01 +0000 (06:33 -0700)] 
Crypto-NG: update random number generators

C++11 brings with it a set of reasonable quality random number
generators and tools to retrieve values for various ranges and types.

Use those C++11 STL <random> features to replace the use of the
varyingly broken, weak or non-standard functions: rand(), random(),
lrand48(), and drand48().

In the process we gain much faster and higher 'quality' randomness in
the auth nonces and event queue scheduling. And more "even" spread for
the ACL random feature.

10 years agoMerged from trunk rev.14084
Amos Jeffries [Fri, 22 May 2015 09:59:09 +0000 (02:59 -0700)] 
Merged from trunk rev.14084

10 years agoReplacement of sslversion=N by tls-min-version=1.N
Amos Jeffries [Fri, 22 May 2015 09:42:55 +0000 (02:42 -0700)] 
Replacement of sslversion=N by tls-min-version=1.N

Overall the default behaviour is changed from enumerating the protocols
wanted. To enumerating and eliminating the unwanted.

* sslversion= / version= parameter is removed from documentation.

* sslversion= code logics is converted from setting the SSL_*_method()
  function to setting the ssloptions= masking parameters.

Yes this will open a hole for future libraries use of TLSv1.3. However
that is kind of desirable and if it becomes a problem the
ssloptions=NO_TLSv1_3 should be made available.

* The SSL_*_method() logic is all converted to using the flexible
  TLS_*_Method() API when available (OpenSSL 1.1.0) otherwise the
  equivalent SSLv23_*_method() API is used.

That API follows the latest specification behaviour: to send a protocol
frame type that any recipient should be able to parse (library decides
which), while only negotiating the protocol type permitted.

* A new option tls-min-version=1.N is added to server connection
  directives. It controls *only* the TLS version range.

 - http(s)_port directives are not (yet) implemented using
   Security::PeerOptions. For now they are left with options= masking to
   select protocol support.

 - bug in http(s)_port directives version= parameter is fixed. The new
   backward compatibility code accepts version=4|5|6 where the existing
   code did not despite documentation saying it did.

 - SSLv3 is left at the library default unless ssloptions=NO_SSLv3 is used.

* ssloptions= is left alone so anyone can still set the library options
  masks to control SSLv3 enable/disable or specific TLS versions higher
  than the configured minimum.

10 years agoSourceFormat Enforcement
Source Maintenance [Wed, 20 May 2015 12:12:11 +0000 (12:12 +0000)] 
SourceFormat Enforcement

10 years agoFix "Not enough space to hold server hello message" error message
Christos Tsantilas [Wed, 20 May 2015 11:00:11 +0000 (14:00 +0300)] 
Fix "Not enough space to hold server hello message" error message

This patch merges the Ssl::ClientBio and Ssl::ServerBio read buffering code
to the Ssl::Bio::readAndBuffer method and uses the MemBuf::potentialSpaceSize
instead of MemBuf::spaceSize to check space size for SSL hello messages buffer,
to take in account available space after a possible buffer grow.

This is a Measurement Factory project

10 years agoBug 4132: regression in short_icon_urls with global_internal_static on
Andre Albsmeier [Tue, 19 May 2015 07:51:31 +0000 (00:51 -0700)] 
Bug 4132: regression in short_icon_urls with global_internal_static on

10 years agoFix build errors in rev.14057 and rev.14058
Amos Jeffries [Mon, 18 May 2015 15:51:14 +0000 (08:51 -0700)] 
Fix build errors in rev.14057 and rev.14058

10 years agoPrevent unused ssl_crtd helpers being run
Amos Jeffries [Mon, 18 May 2015 12:50:03 +0000 (05:50 -0700)] 
Prevent unused ssl_crtd helpers being run

The conditions for when to start ssl_crtd helpers was ignoring the
generate-host-certificates=off option. Meaning most ssl-bump installs
were running them needlessly.

10 years agoDocs: fix debug output on https_port context failure
Amos Jeffries [Mon, 18 May 2015 12:49:05 +0000 (05:49 -0700)] 
Docs: fix debug output on https_port context failure

10 years agoFix various uninitialized class members
Amos Jeffries [Sat, 16 May 2015 08:41:00 +0000 (01:41 -0700)] 
Fix various uninitialized class members

 Detected by Coverity Scan. Issues 129715412971531294554,
  126824112682401268239126823812657221264389,
  1151595, 740579, 740574, 740562, 740561, 740560, 740559,
  740558, 740542, 740541, 740540, 740525

10 years agoCleanup: Refactor IcmpConfig
Amos Jeffries [Fri, 15 May 2015 12:50:09 +0000 (05:50 -0700)] 
Cleanup: Refactor IcmpConfig

Pull the IcmpConfig object out of the global SquidConfig structure and
updates it to processing its own parse logics. Bringing it inline with
the per-component configuration design in SourceLayout and HotConf projects.

This allows us to use SBuf for storing the pinger program details and
avoid valgrind complaints about some malloc.

It will also allow lazy re-starting of the helper to be implemented later.

10 years agoSourceFormat Enforcement
Source Maintenance [Fri, 15 May 2015 06:12:06 +0000 (06:12 +0000)] 
SourceFormat Enforcement

10 years agoHTTP/2: RFC 7540
Amos Jeffries [Fri, 15 May 2015 00:38:20 +0000 (17:38 -0700)] 
HTTP/2: RFC 7540

10 years agoFix typo in rev.14073
Amos Jeffries [Thu, 14 May 2015 23:56:40 +0000 (16:56 -0700)] 
Fix typo in rev.14073

10 years agoFix several uninitizliaed members variables
Amos Jeffries [Thu, 14 May 2015 21:47:16 +0000 (14:47 -0700)] 
Fix several uninitizliaed members variables

 Detected by Coverity Scan. Issues 1297154 and 1297152.

10 years agosystemd: add man(8) reference to .service file
Amos Jeffries [Thu, 14 May 2015 10:34:43 +0000 (03:34 -0700)] 
systemd: add man(8) reference to .service file

10 years agoFix incorrect use of errno in various libcomm.la places
Alex Dowad [Thu, 14 May 2015 10:24:29 +0000 (03:24 -0700)] 
Fix incorrect use of errno in various libcomm.la places

Fix problems with 'errno' in TcpAcceptor::Listen, Comm::HandleRead, and
Comm::HandleWrite. 'errno' is only valid after a standard library function
returns an error. Also, we must avoid calling out to other functions before
recording the value of 'errno', since they might overwrite it.

10 years agoSourceFormat Enforcement
Source Maintenance [Wed, 13 May 2015 12:12:10 +0000 (12:12 +0000)] 
SourceFormat Enforcement

10 years agoBug 4236: SSL negotiation error of 'success'
Nathan Hoad [Wed, 13 May 2015 12:00:37 +0000 (05:00 -0700)] 
Bug 4236: SSL negotiation error of 'success'

10 years agoFix signal.h usage to resolve compiler warning
Alex Dowad [Mon, 11 May 2015 15:31:57 +0000 (08:31 -0700)] 
Fix signal.h usage to resolve compiler warning

When included, musl libc's sys/signal.h issues a compiler warning
stating that signal.h should be used directly instead. If gcc is
treating all warnings as errors, this breaks the build.

glibc's sys/signal.h does not contain any definitions; all it does
is include signal.h (indirectly). So directly including signal.h
doesn't break anything with glibc.

10 years agoBug 3930: assertion 'connIsUsable(http->getConn())'
Amos Jeffries [Mon, 11 May 2015 10:44:23 +0000 (03:44 -0700)] 
Bug 3930: assertion 'connIsUsable(http->getConn())'

10 years agoFix missing external ACL helper notes
Nathan Hoad [Fri, 8 May 2015 19:28:16 +0000 (12:28 -0700)] 
Fix missing external ACL helper notes

external ACL helper notes are only added onto the HTTP request that
kicked off the external ACL lookup, and not cached ACL responses.
This means if you set notes from an external ACL that are used for
some processing in other ACLs, or post-processing on logs, things
may be missed.

10 years agocomm_connect_addr on failures returns Comm:OK
Christos Tsantilas [Fri, 8 May 2015 19:16:22 +0000 (12:16 -0700)] 
comm_connect_addr on failures returns Comm:OK

The comm_connect_addr on connect failures sets the xerrno to 0
and returns Comm::OK. This is causes problems on ConnOpener
class users which believes the connection is established and
it is ready for use.

 This is a Measurement Factory project

10 years agoCleanup: Rename Ssl::method() to Ssl::clientMethod() to say what it produces
Amos Jeffries [Fri, 8 May 2015 11:18:30 +0000 (04:18 -0700)] 
Cleanup: Rename Ssl::method() to Ssl::clientMethod() to say what it produces

10 years agoDocs: shuffle SMP specific options to the top of squid.conf
Amos Jeffries [Fri, 8 May 2015 08:11:53 +0000 (01:11 -0700)] 
Docs: shuffle SMP specific options to the top of squid.conf

The workers directive is required to be used before several other
directives. It makes little sense to documents it after the controls
which depend on it.

Make a new config section to contain the SMP specific options.

10 years agoCacheMgr: display 'client_db off' instead of 0 clients accessing cache
Amos Jeffries [Fri, 8 May 2015 07:13:35 +0000 (00:13 -0700)] 
CacheMgr: display 'client_db off' instead of 0 clients accessing cache

... to clarify why there is no record of even the mgr request happening.
The cleint_db mechanism needs to be enabled and measuring traffci for
any useful client counter value to exist.

10 years agoMerge from trunk rev.14061
Amos Jeffries [Thu, 7 May 2015 16:29:15 +0000 (09:29 -0700)] 
Merge from trunk rev.14061

10 years agoFix "Secure ICAP" patch, revno.14055, to allow compile with openSSL disabled
Christos Tsantilas [Wed, 6 May 2015 14:58:01 +0000 (17:58 +0300)] 
Fix "Secure ICAP" patch, revno.14055, to allow compile with openSSL disabled

10 years agoSourceFormat Enforcement
Source Maintenance [Tue, 5 May 2015 18:12:06 +0000 (18:12 +0000)] 
SourceFormat Enforcement

10 years agoSquid Assertion Read.cc:205: "params.data == data"
Christos Tsantilas [Tue, 5 May 2015 17:40:36 +0000 (20:40 +0300)] 
Squid Assertion Read.cc:205: "params.data == data"

Inside IdleConnList::findUseable the IdleConnList::removeAt call can delete
"this" IdleConnList object. The IdleConnList::clearHandlers called imediatelly
after the removeAt method, will try to use the invalid "this" object in
a comm_read_cancel function call, causing this assertion or other similar.

This patch fixes the IdleConnList::findUseable, IdleConnList::pop and
IdleConnList::findAndClose methods to call IdleConnList::clearHandlers before
the IdleConnList::removeAt is called.

This is a Measurement Factory project

10 years agoSquid Assertion errorpage.cc:600: "entry->isEmpty()"
Christos Tsantilas [Tue, 5 May 2015 15:59:56 +0000 (18:59 +0300)] 
Squid Assertion errorpage.cc:600: "entry->isEmpty()"

While squid shuting down, aborted transactions, for which body data already
downloaded, can cause this bug.

This is a Measurement Factory project

10 years agoSquid Assertion MemBuf.cc:380: "new_cap > (size_t) capacity"
Christos Tsantilas [Tue, 5 May 2015 15:38:39 +0000 (18:38 +0300)] 
Squid Assertion MemBuf.cc:380: "new_cap > (size_t) capacity"

The maximum buffer size for holding Server and Client SSL hello messages is only
16k which is not enough hold a Hello message which includes some extensions and
1-2 or more Certificates.
This patch increases the maximum size to 65535 and also adds some checks to
avoid squid crashes in the case the hello messages buffer overflows.

This is a Measurement Factory project

10 years agoSourceFormat Enforcement
Source Maintenance [Tue, 5 May 2015 12:12:14 +0000 (12:12 +0000)] 
SourceFormat Enforcement

10 years agoSecure ICAP
Christos Tsantilas [Tue, 5 May 2015 09:09:27 +0000 (12:09 +0300)] 
Secure ICAP

This patch adds support for ICAP services that require SSL/TLS transport
connections. The same options used for the cache_peer directive are used for
the icap_service directive, with similar certificate validation logic.

To mark an ICAP service as "secure", use an "icaps://" service URI scheme when
listing your service via an icap_service directive. The industry is using a
"Secure ICAP" term, and Squid follows that convention, but "icaps" seems more
appropriate for a _scheme_ name.

Squid uses port 11344 for Secure ICAP by default, following another popular
proxy convention. The old 1344 default for plain ICAP ports has not changed.

Technical Details
==================

This patch:
  - Splits Ssl::PeerConnector class into Ssl::PeerConnector parent and two kids:
    Ssl::BlindPeerConnector, a basic SSL connector for cache_peers, and
    Ssl::PeekingPeerConnector, a peek-and-splice SSL connector for HTTP servers.

  - Adds a third Ssl::IcapPeerConnector kid to connect to Secure ICAP servers.

  - Fixes ErrorState class to avoid crashes on nil ErrorState::request member.
    (Ssl::IcapPeerConnector may generate an ErrorState with a nil request).

  - Modifies the ACL peername to use the Secure ICAP server name as value while
    connecting to an ICAP server. This is useful to make SSL certificate
    policies based on ICAP server name. However, this change is undocumented
    until we decide whether a dedicated ACL would be better.

This is a Measurement Factory project.

10 years agoMake pod2man an optional dependency
Amos Jeffries [Sun, 3 May 2015 07:46:48 +0000 (00:46 -0700)] 
Make pod2man an optional dependency

Documentation files can be built on a best-effort basis. This allows
Squid more helpers to be built without pod2man and sub-dependencies.

configure.ac already checks for pod2man existence and sets appropriate
automake conditionals.

10 years agoPrep for 3.5.4, 3.4.13, 3.3.14, 3.2.14
Amos Jeffries [Fri, 1 May 2015 07:35:40 +0000 (00:35 -0700)] 
Prep for 3.5.4, 3.4.13, 3.3.14, 3.2.14

10 years agoFix X509 server certificate domain matching
Amos Jeffries [Fri, 1 May 2015 06:31:01 +0000 (23:31 -0700)] 
Fix X509 server certificate domain matching

The X509 certificate domain fields may contain non-ASCII encodings.
Ensure the domain match algorithm is only passed UTF-8 ASCII-compatible
strings.

10 years agoBug 3775: Disable HTTP/1.1 pipeline feature for pinned connections
Christos Tsantilas [Fri, 1 May 2015 06:25:14 +0000 (23:25 -0700)] 
Bug 3775: Disable HTTP/1.1 pipeline feature for pinned connections

10 years agoCleanup: Display correct error code in debugging output for IoCallback::finish
Alex Dowad [Wed, 29 Apr 2015 11:26:53 +0000 (04:26 -0700)] 
Cleanup: Display correct error code in debugging output for IoCallback::finish

It seems clear that the debugging log message in IoCallback::finish
was intended to display the arguments passed to the method.

10 years agoCleanup: Fix spelling error in debug message in parseHttpRequest()
Alex Dowad [Wed, 29 Apr 2015 11:24:02 +0000 (04:24 -0700)] 
Cleanup: Fix spelling error in debug message in parseHttpRequest()

10 years agoCleanup: Add whitespace to make debug message in writeComplete() more readable
Alex Dowad [Wed, 29 Apr 2015 11:22:58 +0000 (04:22 -0700)] 
Cleanup: Add whitespace to make debug message in writeComplete() more readable

10 years agoDocs: READ_HANDLER and WRITE_HANDLER error handling requirements
Alex Dowad [Wed, 29 Apr 2015 11:06:52 +0000 (04:06 -0700)] 
Docs: READ_HANDLER and WRITE_HANDLER error handling requirements

All existing READ_HANDLER functions return < 0 on error, so we can test that.
None of them overwrite errno before returning.

10 years agopconn_lifetime robustness fixes
Christos Tsantilas [Tue, 28 Apr 2015 09:55:08 +0000 (12:55 +0300)] 
pconn_lifetime robustness fixes

This patch changes pconn_lifetime (r13780) to abort only really idle
persistent connections (when they timeout). It removes some "extra" features
(added to pconn_lifetime during the feature review) because they break things
when aggressive timeouts is combined with picky clients. Specifically,

1. Squid closed connections with partially received requests when they
   reached pconn_lifetime limit. We should only close _idle_ connections.

2. When connecting to Squid without sending anything for longer than
   pconn_lifetime, the connection hangs if the request is sent after the
   waiting period.

3. The connection also hangs if the initial request is starting to be
   transmitted but then there is a longer pause before the request is
   completed.

Most of the above problems are easy to trigger only when using very aggressive
pconn_lifetime settings that the feature was not designed for, but they still
can be considered bugs from admins point of view. Fixes:

* Do not stop reading a partially received request when we are timing out,
  to avoid aborting that request.

* Do not set keepalive flag based on the pconn_lifetime timeout. We cannot
  predict whether some new request data is going to be read (and reset the
  idle timeout clock) before our Connection:close response is sent back.

HTTP clients are supposed to recover from such races, but some apparently
do not, especially if it is their first request on the connection.

This is a Measurement Factory project.

10 years agoAdd vsnprintf() protection for vargs
Amos Jeffries [Mon, 27 Apr 2015 14:39:04 +0000 (07:39 -0700)] 
Add vsnprintf() protection for vargs