]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
9 years agoNote ACL substrings matching
Christos Tsantilas [Thu, 24 Dec 2015 06:57:04 +0000 (08:57 +0200)] 
Note ACL substrings matching

There are several use cases where an annotation may contain a list of values
for a single key. Today it is only possible to match the full annotation value.

This patch investigates the -m flag which can be used to enable delimiter
separated substrings matching on annotations:
   acl aclname note [-m[=delimiters]] name value ...
The '-m' flag by default matches comma separated substrings. The optional
"delimiters" parameter is a list of non-alphanumeric characters, which can
be used as alternate delimiters.

E.g. if an external ACL sets an annotation like:
   "applications=http,facebook,facebook-chat"
the following ACLs can be used to block access to certain applications:

acl fb_chat      note -m applications facebook-chat
acl db_upload    note -m  applications dropbox-upload
http_access      deny fb_chat
http_access      deny db_upload

This is a Measurement Factory project

9 years agoLog TLS Cryptography Parameters: more more fixes to allow "make check" work
Christos Tsantilas [Wed, 23 Dec 2015 13:17:35 +0000 (15:17 +0200)] 
Log TLS Cryptography Parameters: more more fixes to allow "make check" work

9 years agoSourceFormat Enforcement
Source Maintenance [Wed, 23 Dec 2015 12:12:10 +0000 (12:12 +0000)] 
SourceFormat Enforcement

9 years agoLog TLS Cryptography Parameters: more fixes to allow "make distcheck" work
Christos Tsantilas [Wed, 23 Dec 2015 12:08:55 +0000 (14:08 +0200)] 
Log TLS Cryptography Parameters: more fixes to allow "make distcheck" work

9 years agoLog TLS Cryptography Parameters: fixes to allow "make check/distcheck" work
Christos Tsantilas [Wed, 23 Dec 2015 10:13:39 +0000 (12:13 +0200)] 
Log TLS Cryptography Parameters: fixes to allow "make check/distcheck" work

9 years agoLog TLS Cryptography Parameters
Christos Tsantilas [Wed, 23 Dec 2015 10:11:26 +0000 (12:11 +0200)] 
Log TLS Cryptography Parameters

This patch adds the following formatting codes:
  %ssl::>negotiated_version  The TLS version of the client-to-Squid connection.
  %ssl::<negotiated_version  The TLS version of the Squid-to-server connection.
  %ssl::>received_hello_version The TLS version of the Hello message received
                                from TLS client
  %ssl::<received_hello_version The TLS version of the Hello message received
                                from TLS server.
  %ssl::>received_supported_version The maximum TLS version supported by the
                                    the TLS client.
  %ssl::<received_supported_version The maximum TLS version supported by the
                                    the TLS server.
  %ssl::>cipher   The negotiated cipher of the client-to-Squid connection.
  %ssl::<cipher   The negotiated cipher of the Squid-to-server connection.

These are useful for statistics collection, security reviews, and reviews
prior to adjusting the list of the allowed TLS protocols and ciphers.

This is a Measurement Factory project

9 years agoSourceFormat Enforcement
Source Maintenance [Tue, 22 Dec 2015 12:12:11 +0000 (12:12 +0000)] 
SourceFormat Enforcement

9 years agoAdd cache_peer auth-no-keytab option to use a credentials cache instead of keytab
Amos Jeffries [Tue, 22 Dec 2015 10:57:16 +0000 (23:57 +1300)] 
Add cache_peer auth-no-keytab option to use a credentials cache instead of keytab

... when using login=NEGOTIATE to authenticate via kerberos to a peer.

When specified, this option prevents Squid from crafting a kerberos
credentials cache from a keytab, but instead lets GSSAPI use an existing
credentials cache.

9 years agoSourceFormat Enforcement
Source Maintenance [Tue, 22 Dec 2015 00:12:11 +0000 (00:12 +0000)] 
SourceFormat Enforcement

9 years agoFix typo in rev.14350
Amos Jeffries [Mon, 21 Dec 2015 21:55:05 +0000 (10:55 +1300)] 
Fix typo in rev.14350

9 years agoSourceFormat Enforcement
Source Maintenance [Mon, 21 Dec 2015 12:12:10 +0000 (12:12 +0000)] 
SourceFormat Enforcement

9 years agoC++-ify basic_fake_auth
Francesco Chemolli [Mon, 21 Dec 2015 10:22:45 +0000 (11:22 +0100)] 
C++-ify basic_fake_auth

9 years agoConvert ClientSocketContext to MEMPROXY class
Amos Jeffries [Fri, 18 Dec 2015 13:10:26 +0000 (02:10 +1300)] 
Convert ClientSocketContext to MEMPROXY class

CBDATA and RefCountable are not very compatible. With the recent I/O
callback shuffling there appears to no longer be any reason for this
class to be CBDATA.

9 years agoBug 4397: DragonFly BSD, POSIX shared memory is implemented as filepath
Amos Jeffries [Fri, 18 Dec 2015 07:07:46 +0000 (20:07 +1300)] 
Bug 4397: DragonFly BSD, POSIX shared memory is implemented as filepath

9 years agoSquid with a misconfigured (too-small) shared memory cache might crash
Alex Rousskov [Fri, 18 Dec 2015 04:30:52 +0000 (21:30 -0700)] 
Squid with a misconfigured (too-small) shared memory cache might crash
upon startup.

Controller condition for allocating MemStore is slightly different from
MemStore condition for allocating MemStore::map, resulting in MemStore
without a map. Until that discrepancy is fixed, be careful when
dereferencing MemStore::map.

9 years agoFix segfault after rev.14439
Amos Jeffries [Fri, 18 Dec 2015 02:18:39 +0000 (15:18 +1300)] 
Fix segfault after rev.14439

9 years agoTypo in rev.14448
Amos Jeffries [Thu, 17 Dec 2015 11:54:50 +0000 (00:54 +1300)] 
Typo in rev.14448

9 years agoPolish: update tls-no-default-ca logic to match tls-no-npn
Amos Jeffries [Wed, 16 Dec 2015 23:17:16 +0000 (12:17 +1300)] 
Polish: update tls-no-default-ca logic to match tls-no-npn

9 years agoShuffle TLS NPN logic to libsecurity
Amos Jeffries [Wed, 16 Dec 2015 23:10:40 +0000 (12:10 +1300)] 
Shuffle TLS NPN logic to libsecurity

Also, adds new config option tls-no-npn to fully disable NPN on selected
cache_peer or http(s)_port directives.

ICAPS services set TLS NPN to off by default to prevent NPN wrongly
advertising them as HTTPS connections. The semantic meaning of NPN is to
name the protocol which is being wrapped by TLS, in the case of ICAPS that
is ICAP/1.0 but Squid NPN callback is currently hard-coded to send 'http/1.1'

9 years agoAdd missing parts to rev.14346 for squid.conf parse and display
Amos Jeffries [Wed, 16 Dec 2015 14:06:32 +0000 (03:06 +1300)] 
Add missing parts to rev.14346 for squid.conf parse and display

9 years agoFwdState should retry connect to the next ip after a Ssl::PeerConnector failure
Christos Tsantilas [Wed, 16 Dec 2015 13:47:22 +0000 (15:47 +0200)] 
FwdState should retry connect to the next ip after a Ssl::PeerConnector failure

When the Ssl::PeerConnector fails to establish an SSL connection FwdState does
not retry to connect to the next destination server ip address, but instead
returns an error.

This is a Measurement Factory project

9 years ago%ssl::<cert_errors logformat code part2: replace std::stoi call with atoi to
Christos Tsantilas [Mon, 14 Dec 2015 10:00:07 +0000 (12:00 +0200)] 
%ssl::<cert_errors logformat code part2: replace std::stoi call with atoi to
make g++-4.9 on FreeBsd-9.3 happy

9 years ago%ssl::<cert_errors logformat code part2: provide depth information
Christos Tsantilas [Sun, 13 Dec 2015 17:53:57 +0000 (19:53 +0200)] 
%ssl::<cert_errors logformat code part2: provide depth information

The first implementation of %ssl::<cert_errors formating code does not provide
information about the certificate the errors belongs.
This patch prints the chain depth information for error, if exist, using the
following format for the printed certificate error:
   ERROR@depth=X

The patch also adds the "error_depth_" parameter to cert validator, used to
pass depth information from cert validator to squid.

This is a Measurement Factory project

9 years agoAvoid memory leaks when a certificate validator is used with SslBump
Christos Tsantilas [Sun, 13 Dec 2015 17:13:44 +0000 (19:13 +0200)] 
Avoid memory leaks when a certificate validator is used with SslBump

When a certificate validator was used, sslCrtvdHandleReplyWrapper delivered
validator response directly to the Ssl::PeerConnector job using job's
Ssl::CertValidationHelper::CVHCB callback. If that synchronous call happened
to be the last job call, then Ssl::PeerConnector::done() would become true
for the job, as it should, but nobody would notice that the PeerConnector
job object should be deleted, and the object would leak.

This fix converts CVHCB into an async job call to avoid direct, unprotected
job calls in this context.

This is a Measurement Factory project.

9 years agoThe user baseDN is ignored for ext_ldap_group_acl helper
Christos Tsantilas [Wed, 9 Dec 2015 16:32:28 +0000 (18:32 +0200)] 
The user baseDN is ignored for ext_ldap_group_acl helper

The user baseDN provided with -B argument is always ignored, which leads to
problems if user baseDN and group baseDN are not the same.

The bug introduced with the r14382 patch.

9 years agoRefactor ClientSocketContext write(2) using Server:: write methods
Amos Jeffries [Tue, 8 Dec 2015 18:47:25 +0000 (10:47 -0800)] 
Refactor ClientSocketContext write(2) using Server:: write methods

Writing to the client connection is scoped as an action for class Server
and its child classes. There is no need for ClientSocketContext to be
providing the callback handlers and performing I/O error handling.

With Server providing the current write handler we can move from
CBDATA callbacks to AsyncCall. Initial testing indicates this has some
minor performance benefit.

9 years agoTLS: refactor cert=/key= storage in libsecurity
Amos Jeffries [Tue, 8 Dec 2015 01:48:40 +0000 (17:48 -0800)] 
TLS: refactor cert=/key= storage in libsecurity

This updates the cert=/key= filename storage from single entries
in PeerOptions to a list of key pairs in preparation for supporting
multiple certificates on client or server TLS contexts.

key= following a cert= parameter is now enforced, rather than just
warned about.

squid.conf can now be configured with multiple [cert= [key=...]]
pairs of filenames, however only the first is used. This differs
from older behaviour where the last value(s) were used. But since
configurations with multiple values was not supported previously
this seems acceptible breakage.

Since the multi-cert support is not fully existing yet this config
ability is left undocumented for now.

9 years agoFix connections over plain squid port to SSL origins
Christos Tsantilas [Mon, 7 Dec 2015 09:53:57 +0000 (11:53 +0200)] 
Fix connections over plain squid port to SSL origins

After the "Restrict SslBump inspections of cache_peer connections"/r14425 patch
https requests over plain proxy port (eg. "GET https://www.example.com/" on
http_port) does not work any more.
This is because the BlindPeerConnector class, which used now for any connection
to the https peers or servers designed initialy to work with cache_peer
connections.

This small patch fix Ssl::BlindPeerConnector to initiate SSL connections
destined to origin SSL servers.

This is a Measurement Factory project.

9 years agoCleanup: pass PeerOptions to sslCreateClientContext()
Amos Jeffries [Mon, 7 Dec 2015 01:45:46 +0000 (17:45 -0800)] 
Cleanup: pass PeerOptions to sslCreateClientContext()

... to reduce context creation code and simplify upcoming libsecurity
migration steps.

9 years agoMake TidyPointer act like other pointers in bool comparison
Amos Jeffries [Sun, 6 Dec 2015 15:42:52 +0000 (07:42 -0800)] 
Make TidyPointer act like other pointers in bool comparison

9 years agoCleanup: Expose SSL initialization function to libsecurity
Amos Jeffries [Sun, 6 Dec 2015 13:59:59 +0000 (05:59 -0800)] 
Cleanup: Expose SSL initialization function to libsecurity

SSL initialize needs to be performed before any security context
objects are generated. Expose the function so that the new blank
context methods can use it.

9 years agoAdd missing stub defines for rev.14433
Amos Jeffries [Sat, 5 Dec 2015 07:15:06 +0000 (23:15 -0800)] 
Add missing stub defines for rev.14433

9 years agoCleanup TLS: shuffle context creation to libsecurity
Amos Jeffries [Sat, 5 Dec 2015 04:45:43 +0000 (20:45 -0800)] 
Cleanup TLS: shuffle context creation to libsecurity

9 years agoBug 4392: assertion CbcPointer.h:159: 'c' via tunnelServerClosed or tunnelClientClosed
Amos Jeffries [Fri, 4 Dec 2015 18:00:46 +0000 (10:00 -0800)] 
Bug 4392: assertion CbcPointer.h:159: 'c' via tunnelServerClosed or tunnelClientClosed

9 years agoCleanup TLS: shuffle AnyP::PortCfg::staticSslContext into libsecurity
Amos Jeffries [Fri, 4 Dec 2015 13:35:13 +0000 (05:35 -0800)] 
Cleanup TLS: shuffle AnyP::PortCfg::staticSslContext into libsecurity

There are no logic changes in this patch. Only symbol moves and debugs
documentation polish.

9 years agoCleanup: add Security::ContextPointer as smart pointer to SSL_CTX*
Amos Jeffries [Fri, 4 Dec 2015 02:28:25 +0000 (18:28 -0800)] 
Cleanup: add Security::ContextPointer as smart pointer to SSL_CTX*

Due to circular dependency issues between ssl/libsquidssl.la and
security/libsecurity.la the code within src/ssl/ is restricted to
only using Security::ContextPtr, it MUST NOT use ContextPointer

Code outside of src/ssl/ should always use Security::ContextPointer
when storing a reference to a context.

Unfortunately some uses of SSL_CTX_Pointer and AnyP::PortCfg remain
in src/ssl/support.cc for now.

9 years agoSourceFormat Enforcement
Source Maintenance [Thu, 3 Dec 2015 00:12:11 +0000 (00:12 +0000)] 
SourceFormat Enforcement

9 years agoComplete certificate chains using external intermediate certificates
Christos Tsantilas [Wed, 2 Dec 2015 19:45:15 +0000 (21:45 +0200)] 
Complete certificate chains using external intermediate certificates
stored in sslproxy_foreign_intermediate_certs file.

Many origin servers do not send complete certificate chains. Many
browsers use certificate extensions in the server certificate to
download the missing intermediate certificates automatically from
the Internet. Squid does not do that (yet?).

This patch adds the sslproxy_foreign_intermediate_certs configuration directive
to allow an admin to supply a file with intermediate certificates that
Squid may use to complete certificate chains. These intermediate
certificates are _not_ treated as trusted root certificates.

This is a Measurement Factory project.

9 years agoSourceFormat Enforcement
Source Maintenance [Mon, 30 Nov 2015 18:12:19 +0000 (18:12 +0000)] 
SourceFormat Enforcement

9 years agoCleanup: Simplify HTTP 1xx control message writing
Amos Jeffries [Mon, 30 Nov 2015 14:23:16 +0000 (06:23 -0800)] 
Cleanup: Simplify HTTP 1xx control message writing

The ::Server class heirarchy has the responsibility of writing to
client connection sockets. The logic that was in ClientSocketContext
can be moved (unchanged) to HttpControlMsgSink and ConnStateData.
There was actually never any need to have it spread outside the
ConnStateData class hierarchy in the first place.

No logic is changed in this patch, just symbol shuffling and one
method inlined into its caller.

9 years agoRestrict SslBump inspections of cache_peer connections.
Christos Tsantilas [Mon, 30 Nov 2015 10:53:23 +0000 (12:53 +0200)] 
Restrict SslBump inspections of cache_peer connections.

This change is specific to FwdState code path. It does not affect tunneled
traffic. Thus, it does not affect CONNECT tunnels unless they are being
inspected with SslBump code.

The old code always used PeekingPeerConnector when connecting to a TLS-related
cache_peer. That approach worked because PeekingPeerConnector does not always
inspect the SSL/TLS connection it establishes. We were kind of lucky that
PeekingPeerConnector exceptions matched FwdState needs.

The primary PeekingPeerConnector goal is to inspect. As its code evolves, it may
enable inspection when FwdState does not want it. Non-peeking cases inside
PeekingPeerConnector should all deal with exceptional situations that
are difficult to predict a priori, before the connector object is created.

This change restricts inspection to cases where an inspected SSL client
connection is being forwarded, reducing the probability that a peer
connection is wrongly inspected. This change does not fix any known bugs.

This is a Measurement Factory project.

9 years agoBug 4387: Kerberos build errors on Solaris
Amos Jeffries [Sun, 29 Nov 2015 14:20:34 +0000 (06:20 -0800)] 
Bug 4387: Kerberos build errors on Solaris

9 years ago4.0.3 SQUID_4_0_3
Amos Jeffries [Sat, 28 Nov 2015 15:29:39 +0000 (07:29 -0800)] 
4.0.3

9 years agoPrep for 4.0.3 and 3.5.12
Amos Jeffries [Sat, 28 Nov 2015 14:18:32 +0000 (06:18 -0800)] 
Prep for 4.0.3 and 3.5.12

9 years agoCleanup: rename Security::ContextPointer to ContextPtr
Amos Jeffries [Sat, 28 Nov 2015 03:00:35 +0000 (19:00 -0800)] 
Cleanup: rename Security::ContextPointer to ContextPtr

... Pointer is used in Squid for smart pointers, which this is not (yet).

Also convert remaining SSL_CTX* instances with ContextPtr.

9 years agoAdd missing include after rev.14418
Amos Jeffries [Thu, 26 Nov 2015 21:14:30 +0000 (13:14 -0800)] 
Add missing include after rev.14418

9 years agoSourceFormat Enforcement
Source Maintenance [Wed, 25 Nov 2015 06:12:10 +0000 (06:12 +0000)] 
SourceFormat Enforcement

9 years agoCleanup: Refactor ConnStateData pipeline handling
Amos Jeffries [Wed, 25 Nov 2015 04:21:40 +0000 (20:21 -0800)] 
Cleanup: Refactor ConnStateData pipeline handling

This refactors the request pipeline management API to use std::list
instead of a custom linked-list with accessors spread over both
ConnStateData and ClientSocketContext.

To do this a new class Pipeline is created with methods wrapping
std::list API and extending it slightly to meet the HTTP/1.1 pipeline
behaviours and perform basic stats gathering. The pipeline management
methods and state variables are moved inside this class.

ClientSocketContext was performing several layering violations in
relation to ConnStateData when one transaction ended and the next needed
starting. Treating the pipeline properly as a std::list forced removal
of that violation.

* actions for starting or resuming a transaction on the connection are
now moved to ConnStateData::kick(). Which gets called after each
transaction completes.
 - with some further cleanup it can be called at any point the
ConnStateData needs to resume processing. However, that is left out of
scope for this patch.

* the ClientSocketContext scope now ends when the finished() method is
used to mark completion of these contexts transactions. Which will mark
itself done and de-register from the Pipeline queue. The ConnStateData
kick() method still needs to be called to resume other transactions
processing.

* the queue is now holding RefCounted Pointers. So that the
ClientSocketContext destructor no longer needs to be careful of
registrations, and the queue entries are guaranteed to still exist while
queued.

* The old freeAllContexts() and notifyAllContexts(int) members of
ConnStateData have been combined into Pipeline::terminateAll(int).

The ClientSocketContext and ConnStateData documentation is updated to
describe what they do in regards to connection and transaction processing.

Initial testing revealed CONNECT tunnels always being logged as ABORTED.
This turns out to be techincally correct, since the only way a tunnel
can finish is for client or server to just close the connection.
However, it is not right to log these as abnormal aborts. Instead, I
have now made the context be finished() just prior to the
TunnelStateData being destroyed. That way normal closure should show up
only as TUNNEL, but timeouts and I/O errors should still be recorded as
abnormal.

Two potential bugs have been highlighted:

* The on_unsupported_protocol handling function appears to be a bit
broken. It pop()'s contexts off the pipeline directly without going
through the proper finished() process to release their state data. I
have highlighted that with an XXX and comment.

* The ssl-bump handling logic switching to TLS begins with a terminateAll(0)
run on all active contexts. It does not check whether there is any existing
pipeline of requests waiting to be processed. And the action prematurely
purges the bumped CONNECT message context, which should be closed properly
and logged as successful.

9 years agoAdd missing stub definition for CPU_ISSET
Amos Jeffries [Tue, 24 Nov 2015 08:01:16 +0000 (00:01 -0800)] 
Add missing stub definition for CPU_ISSET

9 years agoBug 4383: Kerberos library detection failing
Amos Jeffries [Tue, 24 Nov 2015 01:43:30 +0000 (17:43 -0800)] 
Bug 4383: Kerberos library detection failing

9 years agoFix typo in tunnel.cc
Amos Jeffries [Mon, 23 Nov 2015 08:18:35 +0000 (00:18 -0800)] 
Fix typo in tunnel.cc

9 years agoFix build errors in cpuafinity.cc
Amos Jeffries [Mon, 23 Nov 2015 01:46:29 +0000 (17:46 -0800)] 
Fix build errors in cpuafinity.cc

So OS provide stub sched.h which contain various amounts of the CPU_*
macro gadgets but not working sched_setaffinity / sched_getaffinity.

We need to check for each macro separately and limit the
HAVE_CPU_AFFINITY protection to the syscalls which configure actually
checked for.

9 years agoIncluded <vector> that was missing on some platforms after r14411.
Alex Rousskov [Sat, 21 Nov 2015 14:59:09 +0000 (07:59 -0700)] 
Included <vector> that was missing on some platforms after r14411.

9 years agoError on missing MIT libraries only if MIT was required
Amos Jeffries [Thu, 19 Nov 2015 14:07:53 +0000 (06:07 -0800)] 
Error on missing MIT libraries only if MIT was required

9 years agoSourceFormat Enforcement
Source Maintenance [Thu, 19 Nov 2015 06:12:03 +0000 (06:12 +0000)] 
SourceFormat Enforcement

9 years agoStore API and layout polishing. No functionality changes intended.
Alex Rousskov [Thu, 19 Nov 2015 05:51:49 +0000 (22:51 -0700)] 
Store API and layout polishing. No functionality changes intended.

Fixes "any Store is a Root" API that forced us to bloat the base
Store class with methods needed only in Store::Root() Controller.
Unblocks bug #7 (cached headers update) fixes.

Class renaming and source file movement map:

  src/SwapDir.h => src/store/Disk.h (and Controller.h)
  src/SwapDir.cc => src/store/Disk.cc
  src/StoreHashIndex.h => src/store/Disks.h (and LocalSearch.h)
  src/store_dir.cc => src/store/Controller.cc (and Disks.cc, LocalSearch.cc)
  src/disk.* => src/fs_io.*

The Store namespace hierarchy now looks like this:

* Storage: Any storage. Similar to the old Store class, but leaner.
* Controller: Combined memory/disks caches and transients. Root API.
* Controlled: Memory cache, disk(s) cache, or transient Storage.
* Disks: All disk caches combined.
* Disk: A single cache_dir Storage.
* Memory: A memory cache.
* Transients: Entries capable of being collapsed for CF.

Please see merged branch commits for details.

9 years agoAdd missing bit of rev.14405
Amos Jeffries [Thu, 19 Nov 2015 02:30:20 +0000 (18:30 -0800)] 
Add missing bit of rev.14405

9 years agoFix build after rev.14402 https_port currently still requires OpenSSL
Amos Jeffries [Thu, 19 Nov 2015 00:24:50 +0000 (16:24 -0800)] 
Fix build after rev.14402 https_port currently still requires OpenSSL

9 years agoFix various DiskIO bugs after rev.14178
Amos Jeffries [Thu, 19 Nov 2015 00:10:31 +0000 (16:10 -0800)] 
Fix various DiskIO bugs after rev.14178

9 years agoBug 4368: A simpler and more robust HTTP request line parser.
Alex Rousskov [Wed, 18 Nov 2015 23:56:16 +0000 (15:56 -0800)] 
Bug 4368: A simpler and more robust HTTP request line parser.

The primary changes are: Removed incremental parsing and revised parsing
sequence to accept virtually any URI (by default and also configurable
as before).

Also doubled hard-coded 16-character method length limit.

No changes to parsing HTTP header fields (a.k.a. the MIME block) were
intended.

Known side effects:

* Drastically simpler code.
* Some unit test case adjustments.
* The new parser no longer treats some request lines ending with
  "HTTP/1.1" as HTTP/0.9 requests for URIs that end with "HTTP/1.1".
* The new parser no longer re-allocates character sets while parsing
  each request.

Intentional Changes:

* Removal of incremental request line parsing.

Squid parsed the request line incrementally. That optimization was
unnecessary:
  - most request lines are short enough to fit into one network I/O,
  - the long lines contain only a single long field (the URI), and
  - the user code must not use incomplete parsing results anyway.

Incremental parsing made code much more complex and possibly slower than
necessary.

The only place where incremental parsing of request lines potentially
makes sense is the URI field itself, and only if we want to accept URIs
exceeding request buffer capacity. Neither the old code, nor the
simplified one do that right now.

* Accept virtually any request-target (when allowed).

1. relaxed_header_parser allows whitespace in request-target.
2. relaxed_header_parser combined with USE_HTTP_VIOLATIONS now allows
   any characters except non-whitespace CTL characters (see RFC 5234
   appendix B.1) in the message request-target (aka URI).

#2 being the default build and configuration situation allows virtually
any URI that Squid can isolate by stripping method (prefix) and
HTTP/version (suffix) off the request line. This approach allows Squid to
forward slightly malformed (in numerous ways) URIs instead of misplacing
on the Squid admin the burden of explaining why something does not work
going through Squid but works fine when going directly or through another
popular proxy (or through an older version of Squid!).

URIs in what Squid considers an HTTP/0.9 request obey the same rules.
Whether the rules should differ for HTTP/0 is debatable, but the current
implementation is the simplest possible one, and the code makes it easy
to add complex rules.

* Code simplification.

RequestParser::parseRequestFirstLine() is now a simple sequence of
sequential if statements. There is no longer a path dedicated for the
strict parser. The decisions about parsing individual fields and
delimiters are mostly isolated to the corresponding methods.

* Unit test cases adjustments.

Removal of incremental request line parsing means that we should not
check parsed fields when parsing fails or has not completed yet.

Some test cases made arguably weird decisions apparently to accommodate
the old parser. The expectations of those test cases are more natural now.

Also, added optional (and disabled by default) debugging, to help pin-point
failures to test sub-cases that CPPUNIT cannot see.

Changing request methods to "none" in test sub-cases with invalid input
was not technically necessary because the new code ignores the method
when parsing fails, but it may help whoever would decide to reduce test
code duplication (by replacing hand-written expected outcomes for failed
test cases with a constant assignment or function call).

9 years agoRemoved src/tests/stub_store_search.cc as unneeded.
Alex Rousskov [Wed, 18 Nov 2015 21:48:34 +0000 (14:48 -0700)] 
Removed src/tests/stub_store_search.cc as unneeded.

9 years agoUse "override" more consistently.
Alex Rousskov [Wed, 18 Nov 2015 21:48:22 +0000 (14:48 -0700)] 
Use "override" more consistently.

Some broken compilers may not like it when only some overridden
methods in a class declaration have the "override" specifier.

9 years agoConvert old comments to Doxygen syntax per review request.
Alex Rousskov [Wed, 18 Nov 2015 20:47:28 +0000 (13:47 -0700)] 
Convert old comments to Doxygen syntax per review request.

9 years agoUse "override" more consistently.
Alex Rousskov [Wed, 18 Nov 2015 20:04:35 +0000 (13:04 -0700)] 
Use "override" more consistently.

Some broken compilers may not like it when only some overridden
methods in a class declaration have the "override" specifier.

9 years agoDo not _require_ anchor/updateCollapsed() re-implementation.
Alex Rousskov [Wed, 18 Nov 2015 20:03:55 +0000 (13:03 -0700)] 
Do not _require_ anchor/updateCollapsed() re-implementation.

Also do not override Controlled methods that Disk is not going to
provide because doing so will complicate changing or deleting those
methods later as we revise the APIs.

9 years agoAdding missing #include, fixing layer-02-maximus build test.
Alex Rousskov [Wed, 18 Nov 2015 18:54:53 +0000 (11:54 -0700)] 
Adding missing #include, fixing layer-02-maximus build test.

9 years agoSourceFormat Enforcement
Source Maintenance [Wed, 18 Nov 2015 18:12:15 +0000 (18:12 +0000)] 
SourceFormat Enforcement

9 years agoC++ convert the global C functions that operate on class CacheDigest
Amos Jeffries [Wed, 18 Nov 2015 13:28:57 +0000 (05:28 -0800)] 
C++ convert the global C functions that operate on class CacheDigest

This is largely a symbol renaming change. But there are two relatively
small logic changes:

1) convert the class to MEMPROXY_CLASS.

Which alters the pool creation timing from general memory pool
initialization time, to whenever the CacheDigest object is first used.

A nice side effect is removal the macro conditional within the old pool
type enumeration. Macros like that in enumeration lists such as this one
have been causing some builds to have run-time errors accessing memory
arrays out-of-bounds or incorrect postions when the build-time
dependency detection issues caused build objects to link with different
./configure'd versions.

2) Constructor logic sequence alteration.

The old *Create function used to set some members then call the *Init
function which would re-set some of them, and initialize most of the
rest (but not all).
The old *UpdateCap function would call a helper that emulated
safe_free(mask) then *Init to alter the objects mask related members
whether they needed it or not.

The class constructor now initializes all members via initialization
list then calls updateCapacity(), which calls a simplified init(). This
altered sequence contains the same operational acts while the new order
avoids repeated or unnecesarily setting members on create and update.

9 years agoMerged from trunk rev.14404
Amos Jeffries [Wed, 18 Nov 2015 13:26:10 +0000 (05:26 -0800)] 
Merged from trunk rev.14404

9 years agoRename CacheDigest::test() to CacheDigest::contains()
Amos Jeffries [Wed, 18 Nov 2015 13:25:29 +0000 (05:25 -0800)] 
Rename CacheDigest::test() to CacheDigest::contains()

9 years agoext_unix_group_acl: Add support via -r flag to strip @REALM from usernames
Chris Addie [Wed, 18 Nov 2015 10:09:05 +0000 (02:09 -0800)] 
ext_unix_group_acl: Add support via -r flag to strip @REALM from usernames

9 years agoSourceFormat
Alex Rousskov [Wed, 18 Nov 2015 06:07:42 +0000 (23:07 -0700)] 
SourceFormat

9 years agoStore API and layout polishing. No functionality changes intended.
Alex Rousskov [Wed, 18 Nov 2015 05:46:36 +0000 (22:46 -0700)] 
Store API and layout polishing. No functionality changes intended.

This first step towards bug #7 fix focuses on fixing "any Store is a
Root" API that forced us to bloat the base Store class with methods
needed only in Store::Root() Controller.

We resolved about 15 XXXs and 10 TODOs (although these counts are
inflated by many duplicated/repeated problems). We added a few new
XXXs and TODOs as well, but they are just marking already problematic
code, not adding more problems or genuinely new work.

Class renaming and source file movement map:

  src/SwapDir.h => src/store/Disk.h (and Controller.h)
  src/SwapDir.cc => src/store/Disk.cc
  src/StoreHashIndex.h => src/store/Disks.h (and LocalSearch.h)
  src/store_dir.cc => src/store/Controller.cc (and Disks.cc, LocalSearch.cc)
  src/disk.* => src/fs_io.*

The code movement to files in parenthesis is not tracked by bzr
because bzr cannot track file splits, and most of the moved code had
to be split across multiple files to untangle various messes. When
deciding what to tell "bzr mv", we picked file pairs that would allow
us to track the most complex, most voluminous code but there is
probably no single correct way to do that.

src/disk.* files were renamed to src/fs_io.* to avoid "src/foo
conflicts with src/store/Foo" problems expected on some case-
insensitive platforms.

The Store namespace hierarchy now looks like this:

* Storage: Any storage. Similar to the old Store class, but leaner.
* Controller: Combined memory/disks caches and transients. Root API.
* Controlled: Memory cache, disk(s) cache, or transient Storage.
* Disks: All disk caches combined.
* Disk: A single cache_dir Storage.
* Memory: A memory cache.
* Transients: Entries capable of being collapsed for CF.

The last two are not moved/finalized yet, but it should not be too
difficult to do that later because there are few direct references to
them from the high-level code.

Related polishing touches:

Moved a lot of misplaced code into the right class and/or source file.

Simplified Store::search() interface to match the actual code that
does not support any search parameters. Removed the search API from
all other stores because the code did not really support store-
specific searches. Resisted the temptation to rename parameterless
search() to iterate() or similar because the actual future of this API
is murky. We may add search parameters or even remove the method
completely. This could quickly snowball into a separate project.

Removed Store::get(x,y,z) API as unused and unsupported.

Removed FreeObject() template as unused (and possibly technically
flawed).

Simplified default Store initialization/cleanup sequence. Removed
empty disk_init(). The non-default Store::Init() parameter is used by
the unit testing code only.

Simplified Store::dereference() API by moving the second parameter to
dedicated Controller::dereferenceIdle() method that is the only ones
using that parameter.

9 years agoUse "standard" STUB macros/API. Also marked the file as unused.
Alex Rousskov [Wed, 18 Nov 2015 05:38:42 +0000 (22:38 -0700)] 
Use "standard" STUB macros/API. Also marked the file as unused.

9 years agoFixed STUB_RETREF() implementation to return the right type.
Alex Rousskov [Wed, 18 Nov 2015 05:34:33 +0000 (22:34 -0700)] 
Fixed STUB_RETREF() implementation to return the right type.
Removed bogus STUB_RETREF() comment about memory leaks in _unreachable_ code.
Deprecated STUB_RETSTATREF() as essentially duplicating STUB_RETREF().

9 years agoMake RefCount pointers behave more like regular pointers.
Alex Rousskov [Wed, 18 Nov 2015 05:32:24 +0000 (22:32 -0700)] 
Make RefCount pointers behave more like regular pointers.

Allow default (but safe, thanks to C++11) conversion of RefCount
pointers to bool. This helps keep the code succinct, minimizes changes
during conversion of reference counting pointers to/from other pointer
types, and avoids nullptr/NULL differences.

9 years agoext_ldap_group_acl: fix std::cerr build error
Aymeric Vincent [Wed, 18 Nov 2015 03:30:57 +0000 (19:30 -0800)] 
ext_ldap_group_acl: fix std::cerr build error

9 years agoCombine the https_port list internal state with http_port state.
Amos Jeffries [Wed, 18 Nov 2015 03:23:59 +0000 (19:23 -0800)] 
Combine the https_port list internal state with http_port state.

These two lists have been near identical for some time now and we can
easily reduce code by simply merging the two and using either the
secure.encryptTransport flag or the transport.protocol type to select
the remaining non-identical code paths.

9 years agoPrevent all TUNNELs being marked as ABORTED
Amos Jeffries [Tue, 17 Nov 2015 10:14:15 +0000 (02:14 -0800)] 
Prevent all TUNNELs being marked as ABORTED

TUNNEL transactions are naturally ended by one of the client or server
closing the connection. This is not an abort. So finish the CONNECT
message context cleanly when the tunnel is closed.

9 years agoupdate docs for finished()
Amos Jeffries [Tue, 17 Nov 2015 08:18:25 +0000 (00:18 -0800)] 
update docs for finished()

9 years agoSplit kick() out of finished(), making terminateAll() cleaner
Amos Jeffries [Tue, 17 Nov 2015 08:14:47 +0000 (00:14 -0800)] 
Split kick() out of finished(), making terminateAll() cleaner

9 years agoDocument bug in clientTunnelOnError
Amos Jeffries [Tue, 17 Nov 2015 07:06:50 +0000 (23:06 -0800)] 
Document bug in clientTunnelOnError

9 years agoRemove unnecessary and dangerous terminateAll()
Amos Jeffries [Tue, 17 Nov 2015 06:58:37 +0000 (22:58 -0800)] 
Remove unnecessary and dangerous terminateAll()

9 years agoUpdate docs and make pop() check the context being removed
Amos Jeffries [Tue, 17 Nov 2015 06:50:47 +0000 (22:50 -0800)] 
Update docs and make pop() check the context being removed

9 years agoDocs: update ConnStateData::kick() comment
Amos Jeffries [Tue, 17 Nov 2015 06:39:08 +0000 (22:39 -0800)] 
Docs: update ConnStateData::kick() comment

9 years agoDocs: Update ConnStateData and ClientServerContext descriptions
Amos Jeffries [Tue, 17 Nov 2015 05:58:08 +0000 (21:58 -0800)] 
Docs: Update ConnStateData and ClientServerContext descriptions

9 years agoMerged from trunk rev.14401
Amos Jeffries [Tue, 17 Nov 2015 04:24:26 +0000 (20:24 -0800)] 
Merged from trunk rev.14401

9 years agoRename ClientSocketContext::connIsFinished() to finished()
Amos Jeffries [Tue, 17 Nov 2015 03:50:31 +0000 (19:50 -0800)] 
Rename ClientSocketContext::connIsFinished() to finished()

Removes some needless mentions of "conn" and clarifies that the method
handles the context object and transaction finishing, not the connection
it belongs to.

9 years agoUse connIsFinished() when a transaction is completed successfully
Amos Jeffries [Tue, 17 Nov 2015 03:26:01 +0000 (19:26 -0800)] 
Use connIsFinished() when a transaction is completed successfully

initiateClose() may sound okay, but it actually is the error handling logic.
It will terminate the ConnStateData with an erro rmessage, leaving the completed
request in the pipeline which in turn will result in *_ABORTED being logged for
all requests with Connection:close headers even if they are cleanly finished.

connIsFinished() is (now) the clean way to finish ClientSocketContext objects
lifetime regardless of whether keep-alive is needed. The ConnStateData::kick()
will now handle that so we do not even need to call keepaliveNextRequest().

Remove the now unused ClientSocketContext::keepaliveNextRequest().

9 years agoFix delay_parameters documentation
Amos Jeffries [Tue, 17 Nov 2015 00:21:01 +0000 (16:21 -0800)] 
Fix delay_parameters documentation

9 years agoError on missing Heimdal libraries only if Heimdal was required
Amos Jeffries [Mon, 16 Nov 2015 22:51:28 +0000 (14:51 -0800)] 
Error on missing Heimdal libraries only if Heimdal was required

9 years agoStop using dangling pointers for eCAP-set custom HTTP reason phrases.
Alex Rousskov [Sun, 15 Nov 2015 17:54:58 +0000 (10:54 -0700)] 
Stop using dangling pointers for eCAP-set custom HTTP reason phrases.

Squid still does not support [external] custom reason phrases and,
hence, cannot reliably support eCAP API that sets the reason phrase to
the one supplied by the adapter.  This and r14398 changes fix [known]
regression bugs introduced by r12728 ("SourceLayout").

9 years agoFixed status code-based HTTP reason phrase for eCAP-generated messages.
Alex Rousskov [Sun, 15 Nov 2015 16:59:12 +0000 (09:59 -0700)] 
Fixed status code-based HTTP reason phrase for eCAP-generated messages.

Calling .reason() on a not-yet-set theMessage.sline object resulted in
"Init" status reason phrase for all from-scratch (i.e., not cloned)
eCAP-made HTTP responses. This fix lets Squid compute the reason phrase
based on the status code, just like Squid does for forwarded responses
(IIRC).

9 years agoCleanup pipeline handling on 1xx message sending
Amos Jeffries [Sun, 15 Nov 2015 13:42:41 +0000 (05:42 -0800)] 
Cleanup pipeline handling on 1xx message sending

9 years agoRemove unused ClientSocketContext::next member
Amos Jeffries [Sun, 15 Nov 2015 13:40:50 +0000 (05:40 -0800)] 
Remove unused ClientSocketContext::next member

9 years agoRemove last traces of ConnStateData::currentobject
Amos Jeffries [Sun, 15 Nov 2015 13:36:19 +0000 (05:36 -0800)] 
Remove last traces of ConnStateData::currentobject

9 years agoReplace ClientSocketContext::removeFromConnectionList() with Pipeline::pop()
Amos Jeffries [Sun, 15 Nov 2015 13:33:44 +0000 (05:33 -0800)] 
Replace ClientSocketContext::removeFromConnectionList() with Pipeline::pop()

9 years agoReplace ConnStateData::getCurrentContext() with Pipeline::front()
Amos Jeffries [Sun, 15 Nov 2015 13:24:11 +0000 (05:24 -0800)] 
Replace ConnStateData::getCurrentContext() with Pipeline::front()

9 years agoRemove ClientSocketContext::deRegisterWithConn()
Amos Jeffries [Sun, 15 Nov 2015 12:47:04 +0000 (04:47 -0800)] 
Remove ClientSocketContext::deRegisterWithConn()

Merge with ClientSocketContext::connIsFinished(). Completing transactions
is the proper way to get requests de-queued.

9 years agoSplit ConnStateData manipulation out of ClientSocketContext::keepaliveNextRequest()
Amos Jeffries [Sun, 15 Nov 2015 12:39:27 +0000 (04:39 -0800)] 
Split ConnStateData manipulation out of ClientSocketContext::keepaliveNextRequest()

 ... move it to a ConnStateData::kick() method instead. Which is called
whenever a transaction is completed and the front queued context changes.