Bug 3613: relax standard-compliance strctness on clang to enable build
When clang is invoked with the -std=c++0x option, it won't make available some system functions
defined in c99. For some reason configure fails to detect this, and so the built-in implementation is
not invoked. This change prevents enabling the -std=c++0x option for clang.
Prep work for automatic sorting of include directives.
Automatic sorting of include files reveals some indirect inclusions, which would break the build.
scripts/sort-includes.pl is the tool to do the automatic header include order sorting.
The other changes in this set fix the issues which that be introduced by running the sorting.
Amos Jeffries [Tue, 14 Aug 2012 12:04:16 +0000 (06:04 -0600)]
Remove --enable-ntlm-fail-open
This feature has been half missing for quite some time (10 years).
The SMB helper sends the LD code back to Squid when the directive is
compiled in, but there is no Squid code handling such responses, back as far
as squid-2.
clang++ doesn't support c++ variable arrays for non-pod types.
Change variable arrays to dynamically-allocated arrays, Ipc::QueueReaders, Ipc::StoreMap and Ipc::Mem::PageStack
Amos Jeffries [Wed, 1 Aug 2012 07:01:58 +0000 (19:01 +1200)]
Support -DFAILURE_MODE_TIME=n compiler flag
This value determins at compile-time how long Squid spends in HIT-only
mode after the failure ratio goes over 1.0. see checkFailureRatio() in
src/client_side_request.cc for details on the ratio.
This flag is supported to remove the need for patching when alteration
is required.
This re-enables Squid peer selection algorithms for intercepted
traffic which has failed Host header verification.
When host verification fails Squid will use, in order of preference:
* an already PINNED server connection
* the client ORIGINAL_DST details
* cache_peer as chosen by selection algorithms
NOTE: whenever DIRECT is selected by routing algorithms the
ORIGINAL_DST is used instead.
Peer selection results are updated to display PINNED and
ORIGINAL_DST alongside DIRECT and cache_peer.
SECURITY NOTE:
At this point Squid will pass the request to cache_peer using the
non-trusted Host header in their URLs. Meaning that the peers
may still be poisoned by CVE-2009-0801 attacks. Only the initial
intercepting proxy is protected.
Full protection against CVE-2009-0801 can be enjoyed by building
Squid with the -DSTRICT_HOST_VERIFY compile-time flag. This will
make the peers unreachable for intercepted traffic where the
Host verification has failed.
* list Sponsors who paid for significant developments in the squid code,
donated hardware for devleopment etc.
* exclude cash donations to the project (only cash to a developer for
specific work)
* in an ordered list broken down in reverse-chronological order of the
latest release they sponsored anything.
For simplicity of maintenance I'm adding @Squid-X.Y labels at the
boundaries for the bzr copy. They should be stripped out automatically
by the "make dist" process for release packaging.
Alex Rousskov [Wed, 25 Jul 2012 23:57:51 +0000 (17:57 -0600)]
Allow a ufs cache_dir entry to coexist with a shared memory cache entry
instead of being released when it becomes idle.
The original boolean version of the StoreController::dereference() code
(r11730) was written to make sure that idle unlocked local store_table entries
are released if nobody needs them (to avoid creating inconsistencies with
shared caches that could be modified in a different process).
Then, in r11786, we realized that the original code was destroying non-shared
memory cache entries if there were no cache_dirs to vote for keeping them in
store_table. I fixed that by changing the StoreController::dereference() logic
from "remove if nobody needs it" to "remove if somebody objects to keeping
it". That solved the problem at hand, but prohibited an entry to exist in
a non-shared cache_dir and in a shared memory cache at the same time.
We now go back to the original "remove if nobody needs it" design but also
give non-shared memory cache a vote so that it can protect idle non-shared
memory cached entries from being released if there are no cache_dirs to vote
for them.
Alex Rousskov [Sun, 22 Jul 2012 03:15:02 +0000 (21:15 -0600)]
Stop HttpRequest and AccessLogEntry memory leaks.
The leaks were introduced by recent request_header_add improvements (r12213)
which needed server-side access to client-side information like client
certificate so that it can be stuffed into the outgoing request headers.
Stuffing was done via Format API that uses AccessLogEntry as the source of
information.
This change breaks the HttpRequest->AccessLogEntry->HttpRequest refcounting
loop that prevented both request and ale objects from being destroyed. The ale
object is now delivered to the server side using FwdState::Start() API. Only
HTTP code currently takes advantage of ale availability on the server side.
Also had to modify httpHdrAdd() API because ale is no longer available via
the request pointer.
Alex Rousskov [Fri, 20 Jul 2012 23:11:02 +0000 (17:11 -0600)]
Avoid bogus "Disk space over limit" warnings when rebuidling dirty ufs index.
Subtract sizes of added-then-rejected entries while loading ufs cache index.
Before SMP changes, the ufs code was incorrectly ignoring the size of
loaded-but-not-yet-validated entries, leading to cache disk overflows.
After SMP changes, the ufs code was not subtracting sizes of
loaded-but-then-rejected entries, leading to bogus "Disk space over
limit" warnings. Now we correctly account for both kinds of entries.
author: Alex Rousskov <rousskov@measurement-factory.com>, Christos Tsantilas <chtsanti@users.sourceforge.net>
SslBump: Support bump-ssl-server-first and mimic SSL server certificates.
Summary: These changes allow Squid working in SslBump mode to peek at
the origin server certificate and mimic peeked server certificate
properties in the generated fake certificate, all prior to establishing
a secure connection with the client:
http://wiki.squid-cache.org/Features/BumpSslServerFirst
http://wiki.squid-cache.org/Features/MimicSslServerCert
The changes are required to bump intercepted SSL connections without
excessive browser warnings. The changes allow to disable bumping of some
intercepted SSL connections, forcing Squid to go into a TCP tunnel mode
for those connections.
The changes also empower end user to examine and either honor or bypass
most origin SSL server certificate errors. Prior to these changes, the
responsibility for ignoring certificate validation errors belonged
exclusively to Squid, necessarily leaving users in the dark if errors
are ignored/bypassed.
Squid can still be configured to emulate old bump-ssl-client-first
behavior. However, a manual revision of ssl_bump options is required
during upgrade because ssl_bump no longer supports an implicit "negate
the last one" rule (and it is risky to let Squid guess what the admin
true intent was or mix old- and new-style rules).
Finally, fake certificate generation has been significantly improved.
The new code guarantees that all identically configured Squids receiving
identical origin server certificates will generate identical fake
certificates, even if those Squid instances are running on different
hosts, at different times, and do not communicate with each other. Such
stable, reproducible certificates are required for distributed,
scalable, or fail-safe Squid deployment.
Overall, the changes are meant to make SslBump more powerful and safer.
The code has been tested in several independent labs.
Specific major changes are highlighted below:
Make bumping algorithm selectable using ACLs. Even though
bump-server-first is an overall better method, bumping the client first
is useful for backward compatibility and possibly for serving internal
Squid objects (such as icons inside Squid error pages). The following
example bumps special and most other requests only, using the old
bump-client-first approach for the special requests only:
ssl_bump client-first specialOnes
ssl_bump server-first mostOthers
ssl_bump none all
It allow use the old ssl_bump syntax:
ssl_bump allow/deny acl ...
but warns the user to update squid configuration.
Added sslproxy_cert_adapt squid.conf option to overwrite default mimicking
behavior when generating SSL certificates. See squid.conf.documented.
Added sslproxy_cert_sign squid.conf option to control how generated SSL
certificates are signed. See squid.conf.documented.
Added ssl::certHasExpired, ssl::certNotYetValid, ssl::certDomainMismatch,
ssl::certUntrusted, and ssl::certSelfSign predefined ACLs to squid.conf.
Do not require http[s]_port's key option to be set if cert option is given.
The fixed behavior for bumped connections now matches squid.conf docs.
Generate stable fake certificates by using signing and true certificate
hashes as the serial number and by using the configured CA private key
for all fake certificates.
Use minimal, trusted certificate for serving SSL errors to the client
instead of trying to mimic the broken true certificate (which results
in double error for the user: browser error dialog plus Squid error page).
To mimic "untrusted" true certificates, generate an untrusted CA certificate
from the configured trusted CA certificate. This both reduces configuration
effort (compared to a configuration option) and results in identical
untrusted fake certificates given identical Squid configurations.
Intelligent handling of CONNECT denials: Do not connect to origin
servers unless CONNECT is successfully authenticated. Delay errors.Added sslproxy_cert_sign squid.conf option to control how generated SSL
certificates are signed. See squid.conf.documented.
Provide '%I' error page formatting code with enough information to avoid
displaying '[unknown]' on SQUID_X509_V_ERR_DOMAIN_MISMATCH errors.
Set logged status code (%<Hs) to 200 when establishing a bumped tunnel.
Improved error detailing and logging: Forget most retried errors.
During SslBump errors, the error details are now logged with both the
initial CONNECT transaction and the first tunneled HTTP transaction.
Do not report system errors as custom Squid errors. Do not report
system errors that did not necessarily happen during the transaction
being logged.
Check SSL server certificate when reconnecting to the origin server for
bumped requests. Despite pinning, Squid maintains two separate connections
and the server may disconnect while the client is still sending requests. To
minimize deployment problems, we reconnect to the origin server but check
that its certificate (which we mimicked for the client) has not changed
much.
Forward bumped server connection-close signal to the bumped client to
improve the "dumb tunnel" appearance of the bumped SSL tunnel.
Allow bumping of CONNECT requests without allow-direct set on http_port.
Previously, that flag was required to allow bumped requests to go direct
because they were (and, sometimes, still are) considered "accelerated".
Send SNI information to the server when server-first bumping a non-IP
CONNECT request.
Better helper-to-Squid buffer size management to support large certificates.
Bypass rare OpenSSL certificate serialization failures when composing an
ssl_crtd request by generating the certificate in the Squid process.
When generating certificate CN names, strip [] surrounding host names,
assuming they are for IPv6 addresses. Bracketed CNs confuse browsers.
Disable persistent connections after client-side-detected errors. They cause
"abandoning such and such connection" warnings, stuck ConnStateData jobs, and
other problems.
HttpRequest::SetHost() must invalidate HttpRequest::canonical "cache".
Implement ssl::bump_mode logformat code to log SslBump decisions: prints "none",
"client-first", "server-first" or "-" for no ssl-bump enabled ports
Bug 3478: Partial fix: Connection-auth on intercepted connections is broken
Currenty in the case of intercepted connections each request is open a new
connection to the destination server, even if the connection is a valid pinned
connection.
This patch fixes this problem and reuses pinned connections on intercepted
requests.