]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
10 years agoMerge from trunk
Amos Jeffries [Sun, 12 Jul 2015 10:07:01 +0000 (03:07 -0700)] 
Merge from trunk

10 years agoShuffle _TIMEOUT and _ABORTED flags into class LogTags
Amos Jeffries [Sun, 12 Jul 2015 10:04:45 +0000 (03:04 -0700)] 
Shuffle _TIMEOUT and _ABORTED flags into class LogTags

10 years agoCleanup: Remove SSL parse_flags() function unused since rev.14148
Amos Jeffries [Sun, 12 Jul 2015 08:28:03 +0000 (01:28 -0700)] 
Cleanup: Remove SSL parse_flags() function unused since rev.14148

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

10 years agoCrypto-NG: Use Security::PeerOptions for listening port TLS settings
Amos Jeffries [Fri, 10 Jul 2015 13:03:18 +0000 (06:03 -0700)] 
Crypto-NG: Use Security::PeerOptions for listening port TLS settings

The bulk of this patch is symbol shuffling to de-duplicate the TLS
settings storage and parsing code.

* Shuffle relevant AnyP::PortCfg settings into a Security::PeerOptions
  member object.
 - removes a lot of duplicate config parsing code.

* Remove the now obsolete and unused Ssl::OpenSSLtoSquidSSLVersion()

The actual logic changes are relatively small:

* Shuffle flags= and options= parsing code from Ssl:: to
  Security::PeerOptions and update to use Tokenizer,
 - fixes performance regression using c_str() on the stored SBuf,
 - fixes performance issue with xstrdup() for option tokens,
 - removes several calls to c-string manipulation.

* Add cachemgr 'config' report dumper of Security::PeerOptions for use
  by all directives using it to dump tls-* parameter names. The old
  parameter names are still accepted, and deprecation will follow in a
  separate patch.
 - fixes bug where cache_peer was not dumping out its SSL/TLS config
  settings at all.

* Change the tls_outgoing_options default value from "disable" to setting
  TLS/1.0 minimum version.
  - fixes squid.conf parsing error on default value "disable".

* Fix tls-min-version=1.N handling not to alter stored options= config
  string. Now updates the binary representation in parsedOptions directly.

* Expose the TLS context creation and configuration to non-OpenSSL builds.
 - fixes bug where context creation by OpenSSL failed silently.

10 years agoRevert tls_outgoing_options default 'options=NO_SSLv3'
Amos Jeffries [Fri, 10 Jul 2015 12:59:48 +0000 (05:59 -0700)] 
Revert tls_outgoing_options default 'options=NO_SSLv3'

10 years agoSourceFormat Enforcement
Source Maintenance [Thu, 9 Jul 2015 18:12:08 +0000 (18:12 +0000)] 
SourceFormat Enforcement

10 years agoAvoid SSL certificate db corruption with empty index.txt as a symptom.
Christos Tsantilas [Thu, 9 Jul 2015 14:02:07 +0000 (17:02 +0300)] 
Avoid SSL certificate db corruption with empty index.txt as a symptom.

* Detect cases where the size file is corrupted or has a clearly wrong
  value. Automatically rebuild the database in such cases.

* Teach ssl_crtd to keep running if it is unable to store the generated
  certificate in the database. Return the generated certificate to Squid
  and log an error message in such cases.

Background:

There are cases where ssl_crtd may corrupt its certificate database.
The known cases manifest themselves with an empty db index file.  When
that happens, ssl_crtd helpers quit, SSL bumping does not work any more,
and the certificate DB has to be deleted and re-initialized.

We do not know exactly what causes corruption in deployments, but one
known trigger that is easy to reproduce in a lab is the block size
change in the ssl_crtd configuration. That change has the following
side-effects:

1. When ssl_crtd removes certificates, it computes their size using a
   different block size than the one used to store the certificates.
   This is may result in negative database sizes.

2. Signed/unsigned conversion results in a huge number near LONG_MAX,
   which is then written to the "size" file.

3. The ssl_crtd helper remoces all certificates from database trying to make
   space for new certificates.

4. The ssl_crtd helper refuses to store new certificates because the
   database size (as described by the "size" file) still exceeds the
   configured limit.

5. The ssl_crtd helper exits because it cannot store a new certificates
   to the database. No helper response is sent to Squid in this case.

Most likely, there are other corruption triggers -- the database
management code is of an overall poor quality. This change resolves some
of the underlying problems in hope to address at least some of the
unknown triggers as well as the known one.

This is a Measurement Factory project.

10 years agoErrors served using invalid certificates when dealing with SSL server errors.
Christos Tsantilas [Thu, 9 Jul 2015 13:12:10 +0000 (16:12 +0300)] 
Errors served using invalid certificates when dealing with SSL server errors.

When bumping Squid needs to send an Squid-generated error "page" over a
secure connection, Squid needs to generate a certificate for that connection.
Prior to these changes, several scenarios could lead to Squid generating
a certificate that clients could not validate. In those cases, the user would
get a cryptic and misleading browser error instead of a Squid-generated
error page with useful details about the problem.

For example, is a server certificate that is rejected by the certificate
validation helper. Squid no longer uses CN from that certificate to generate
a fake certificate.

Another example is a user accessing an origin server using one of its
"alternative names" and getting a Squid-generated certificate containing just
the server common name (CN).

These changes make sure that certificate for error pages is generated using
SNI (when peeking or staring, if available) or CONNECT host name (including
server-first bumping mode). We now update the ConnStateData::sslCommonName
field (used as CN field for generated certificates) only _after_ the server
certificate is successfully validated.

This is a Measurement Factory project.

10 years agoIPv6: improve BCP 177 compliance
Amos Jeffries [Thu, 9 Jul 2015 02:50:17 +0000 (19:50 -0700)] 
IPv6: improve BCP 177 compliance

Always perform the IP transport probes to detect IPv6 availability.

* Accept lack of IPv6 assignment as per normal by auto-disabling IPv6.

* Whine loudly if (and only if) it would have worked but has been
  forced OFF by --disable-ipv6.

10 years agoFix off-by-one errors in rev.14139
Amos Jeffries [Thu, 9 Jul 2015 02:21:52 +0000 (19:21 -0700)] 
Fix off-by-one errors in rev.14139

10 years agoFix compile issue after rev.14139
Amos Jeffries [Tue, 7 Jul 2015 16:35:58 +0000 (09:35 -0700)] 
Fix compile issue after rev.14139

10 years agoCleanup: remove squid_DEPENDENCIES from Makefile
Amos Jeffries [Tue, 7 Jul 2015 13:26:41 +0000 (06:26 -0700)] 
Cleanup: remove squid_DEPENDENCIES from Makefile

The bug *_DEPENDENCIES existed to solve no longer exists. Current auto*
toolchains can correctly generate the dependencies data based on *_LDADD
and *_SOURCES Makefile variables.

The incorrect definition of squid_DEPENDENCIES was also causing various
build issues and could result in crashes when conditionaly built features
were changed by users ./configure without a full re-bootstrap.

TODO: remove *_DEPENDEICIES for other binaries.

10 years agoSourceFormat Enforcement
Source Maintenance [Tue, 7 Jul 2015 12:12:09 +0000 (12:12 +0000)] 
SourceFormat Enforcement

10 years agoCleanup: refactor HttpRequest::urlpath member into class URL
Amos Jeffries [Tue, 7 Jul 2015 11:53:08 +0000 (04:53 -0700)] 
Cleanup: refactor HttpRequest::urlpath member into class URL

10 years agoRevert r14137 due to compile errors
Amos Jeffries [Sat, 4 Jul 2015 18:32:54 +0000 (11:32 -0700)] 
Revert r14137 due to compile errors

10 years agoFix uninitialized atomics
Amos Jeffries [Sat, 4 Jul 2015 16:16:34 +0000 (09:16 -0700)] 
Fix uninitialized atomics

 Detected by Coverity Scan. Issue 11539611308370

10 years agoFix several uninitialized members
Amos Jeffries [Sat, 4 Jul 2015 15:33:31 +0000 (08:33 -0700)] 
Fix several uninitialized members

 Detected by Coverity Scan. Issue 740560

10 years agoPolish debugs on NAT failure
Amos Jeffries [Sat, 4 Jul 2015 15:23:25 +0000 (08:23 -0700)] 
Polish debugs on NAT failure

10 years agoFix crash in TcpAccepter with profiler enabled
Amos Jeffries [Sat, 4 Jul 2015 11:36:00 +0000 (04:36 -0700)] 
Fix crash in TcpAccepter with profiler enabled

10 years agoSourceFormat Enforcement
Source Maintenance [Fri, 3 Jul 2015 18:12:11 +0000 (18:12 +0000)] 
SourceFormat Enforcement

10 years agoSplice to origin cache_peer.
Christos Tsantilas [Fri, 3 Jul 2015 14:07:05 +0000 (17:07 +0300)] 
Splice to origin cache_peer.

Currently, Squid cannot redirect intercepted connections that are subject to
SslBump rules to _originserver_ cache_peer. For example, consider Squid that
enforces "safe search" by redirecting clients to forcesafesearch.example.com.
Consider a TLS client that tries to connect to www.example.com. Squid needs to
send that client to forcesafesearch.example.com (without changing the host
header and SNI information; those would still point to www.example.com for
safe search to work as intended!).

The admin may configure Squid to send intercepted clients to an originserver
cache_peer with the forcesafesearch.example.com address. Such a configuration
does not currently work together with ssl_bump peek/splice rules.

This patch:

* Fixes src/neighbors.cc bug which prevented CONNECT requests from going
  to originserver cache peers. This bug affects both true CONNECT requests
  and intercepted SSL/TLS connections (with fake CONNECT requests). Squid
  use the CachePeer::in_addr.port which is not meant to be used for the HTTP
  port, apparently. HTTP checks should use CachePeer::http_port instead.

* Changes Squid to not initiate SSL/TLS connection to cache_peer for
  true CONNECT requests.

* Allows forwarding being-peeked (or stared) at connections to originserver
  cache_peers.

The bug fix described in the first bullet makes the last two changes
necessary.

This is a Measurement Factory project.

10 years agoPrep for 3.5.6
Amos Jeffries [Fri, 3 Jul 2015 09:05:23 +0000 (02:05 -0700)] 
Prep for 3.5.6

10 years agoBug 3483: assertion failed store.cc:1866: 'isEmpty()'
Chudy Fernandez [Wed, 1 Jul 2015 04:38:20 +0000 (21:38 -0700)] 
Bug 3483: assertion failed store.cc:1866: 'isEmpty()'

10 years agoAdd const on all local ssl_error variables
Amos Jeffries [Wed, 1 Jul 2015 03:58:50 +0000 (20:58 -0700)] 
Add const on all local ssl_error variables

10 years agoAdd ERROR messages when TLS context initialize fails
Amos Jeffries [Tue, 30 Jun 2015 15:19:58 +0000 (08:19 -0700)] 
Add ERROR messages when TLS context initialize fails

10 years agoMove tls-flags= parser into Security::PeerOptions
Amos Jeffries [Tue, 30 Jun 2015 14:12:43 +0000 (07:12 -0700)] 
Move tls-flags= parser into Security::PeerOptions

It no longer needs to be called by the SSL code, so can be a private
member.

10 years agoRemove unused OpenSSLtoSquidSSLVersion
Amos Jeffries [Tue, 30 Jun 2015 10:45:22 +0000 (03:45 -0700)] 
Remove unused OpenSSLtoSquidSSLVersion

10 years agoMove tls-options= parser into Security::PeerOptions
Amos Jeffries [Tue, 30 Jun 2015 10:39:39 +0000 (03:39 -0700)] 
Move tls-options= parser into Security::PeerOptions

It no longer needs to be called by the SSL code, so can be a private
member without OpenSSL library dependency.

Also, remove c_str() performance regression by upgrading to use
::Parser::Tokenizer.

10 years agoFix cachemgr 'config' report output for TLS options
Amos Jeffries [Tue, 30 Jun 2015 07:21:06 +0000 (00:21 -0700)] 
Fix cachemgr 'config' report output for TLS options

Adds Security::PeerOptions::dumpCfg() method to output config
details for the peer TLS settings stored. Takes an optional
prefix string for the option parameters.
- uses prefix "" for tls_outgoing_options
- uses prefix "tls-" for https_port, http_port, and cache_peer
- displays "tls-disable" for directives without TLS settings.

Fixes missing cache_peer config output for TLS settings.

Fixes display of http(s)_port TLS settings 'ssl' prefix.

Fixes tls-min-version= internal operation to avoid polluting
tls-options= config settings.

Also, updates documentation mentions of "SSL" in debugs().

10 years agoMerged from trunk rev.14127
Amos Jeffries [Mon, 29 Jun 2015 14:36:31 +0000 (07:36 -0700)] 
Merged from trunk rev.14127

10 years agoCleanup HTCP packet construction
Amos Jeffries [Mon, 29 Jun 2015 14:32:49 +0000 (07:32 -0700)] 
Cleanup HTCP packet construction

Fixes non-zero bits in packet reserved fields.
 Detected by Coverity Scan. Issue 1256168

Also fixes some bad formatting.

10 years agoext_edirectory_userip_acl: fix uninitialized variable
Amos Jeffries [Mon, 29 Jun 2015 14:09:53 +0000 (07:09 -0700)] 
ext_edirectory_userip_acl: fix uninitialized variable

 Detected by Coverity Scan. Issue 1258704

10 years agoUpdate release notes
Amos Jeffries [Mon, 29 Jun 2015 12:57:04 +0000 (05:57 -0700)] 
Update release notes

10 years agoCleanup: remove unnecessary AnyP::PortCfg::contextMethod
Amos Jeffries [Mon, 29 Jun 2015 12:46:17 +0000 (05:46 -0700)] 
Cleanup: remove unnecessary AnyP::PortCfg::contextMethod

Now that SSL/TLS server method is a fixed API function we do not have to
store it locally. Move the lookup to the SSL support code where it is
actually used.

10 years agoSet HTTPS proxy default to TLS/1.0+ with no SSLv3 support
Amos Jeffries [Mon, 29 Jun 2015 12:42:34 +0000 (05:42 -0700)] 
Set HTTPS proxy default to TLS/1.0+ with no SSLv3 support

10 years agoAdd 'tls_outgoing_options disabed' to disable HTTPS proxying
Amos Jeffries [Mon, 29 Jun 2015 12:41:49 +0000 (05:41 -0700)] 
Add 'tls_outgoing_options disabed' to disable HTTPS proxying

10 years agoFix uninitializd PeerOptions::parsedFlags
Amos Jeffries [Mon, 29 Jun 2015 12:40:35 +0000 (05:40 -0700)] 
Fix uninitializd PeerOptions::parsedFlags

10 years agoMerged from trunk rev.14126
Amos Jeffries [Sun, 28 Jun 2015 15:02:53 +0000 (08:02 -0700)] 
Merged from trunk rev.14126

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 agoPass LogTags by-reference now its a class
Amos Jeffries [Thu, 11 Jun 2015 05:02:13 +0000 (22:02 -0700)] 
Pass LogTags by-reference now its a class

10 years agoConvert enum LogTags into class LogTags
Amos Jeffries [Thu, 11 Jun 2015 04:51:10 +0000 (21:51 -0700)] 
Convert enum LogTags into class LogTags

- enum sequence re-typed to LogTags_ot
- logTagsIsATcpHit() function converted to method LogTags::isTcpHit()
- strings array lookup converted to method LogTags::c_str()
- constructors and assignment assure valid values, no more need for
  external asserts before logging.

10 years agoConvert LogTags.cc to non-generated source
Amos Jeffries [Tue, 9 Jun 2015 18:11:52 +0000 (11:11 -0700)] 
Convert LogTags.cc to non-generated source

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