]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
5 years agonetdb not saving to disk (#311) M-staged-PR311
chi-mf [Tue, 23 Oct 2018 22:38:30 +0000 (22:38 +0000)] 
netdb not saving to disk (#311)

5 years agoFix several windows build issues (#309)
Francesco Chemolli [Tue, 23 Oct 2018 19:16:37 +0000 (19:16 +0000)] 
Fix several windows build issues (#309)

The mingw build has rotten somewhat, there are some type errors
and data access errors.
The fix is not yet complete, but it's a step forward

5 years agoCertificate fields injection via %D in ERR_SECURE_CONNECT_FAIL (#306) M-staged-PR306
Christos Tsantilas [Wed, 17 Oct 2018 15:14:07 +0000 (15:14 +0000)] 
Certificate fields injection via %D in ERR_SECURE_CONNECT_FAIL (#306)

%ssl_subject, %ssl_ca_name, and %ssl_cn values were not properly escaped
when %D code was expanded in HTML context of the ERR_SECURE_CONNECT_FAIL
template. This bug affects all ERR_SECURE_CONNECT_FAIL page templates
containing %D, including the default template.

Other error pages are not vulnerable because Squid does not populate %D
with certificate details in other contexts (yet).

Thanks to Nikolas Lohmann [eBlocker] for identifying the problem.

TODO: If those certificate details become needed for ACL checks or other
non-HTML purposes, make their HTML-escaping conditional.

This is a Measurement Factory project.

5 years agoDocs: Update stale version number in release notes (#303)
Amos Jeffries [Wed, 10 Oct 2018 18:49:10 +0000 (18:49 +0000)] 
Docs: Update stale version number in release notes (#303)

5 years agoAllow compilation with minimal OpenSSL (#281)
Eneas Queiroz [Wed, 10 Oct 2018 16:45:29 +0000 (16:45 +0000)] 
Allow compilation with minimal OpenSSL (#281)

Updated use of OpenSSL deprecated API, so that Squid can be compiled
with OpenSSL built with the OPENSSL_NO_DEPRECATED option. Such OpenSSL
builds are useful for saving storage space on embedded systems.

Also added compat/openssl.h -- a centralized OpenSSL portability shim.
Including it is now required before #including openssl/*.h headers.

5 years agoFixed %USER_CA_CERT_xx and %USER_CERT_xx crashes (#301)
chi-mf [Wed, 10 Oct 2018 07:50:52 +0000 (07:50 +0000)] 
Fixed %USER_CA_CERT_xx and %USER_CERT_xx crashes (#301)

The bug was introduced in 4e56d7f6 when the formatting code was moved
into Format::Format::assemble() where the old "format" loop variable is
a Format data member with the right type but (usually) the wrong value.

5 years agoImprove const correctness for hash_link (#300)
Amos Jeffries [Tue, 9 Oct 2018 11:36:14 +0000 (11:36 +0000)] 
Improve const correctness for hash_link (#300)

hash_link does not need to be modified to fetch its key
value. This allows display and fetch of hash keys for
objects which are const.

5 years agontlm_fake_auth: add ability to test delayed responses (#294) M-staged-PR294
Amos Jeffries [Mon, 8 Oct 2018 00:11:14 +0000 (00:11 +0000)] 
ntlm_fake_auth: add ability to test delayed responses (#294)

Add a -t parameter which sets a timeout to artificially delay
authentication responses by a fixed amount longer than their
normal delay.

This enables the fake authenticator to be used to test NTLM
client and Squid behaviour under various network latency and
stress conditions which delay ActiveDirectory responses.

5 years agoFix %>ru for CONNECT requests (#299) M-staged-PR299
Christos Tsantilas [Thu, 4 Oct 2018 10:15:15 +0000 (10:15 +0000)] 
Fix %>ru for CONNECT requests (#299)

Commit bec110e (a.k.a. v4 commit fbbd5cd5) broke CONNECT URI logging
because it incorrectly assumed that URI::absolute() supports all URIs.
As the result, Squid logged CONNECT URLs as "://host:port".

Also fixed a similar wrong assumption in ACLFilledChecklist::verifyAle()
which may affect URL-related ACL checks for CONNECT requests, albeit
only in already buggy cases where Squid warns about "ALE missing URL".

This is a Measurement Factory project

5 years agoSource Format Enforcement (#295) M-staged-PR295
squidadm [Sun, 30 Sep 2018 20:14:00 +0000 (20:14 +0000)] 
Source Format Enforcement (#295)

5 years agoFixed negotiate_kerberos_auth memory leaks (#285)
huaraz [Sun, 30 Sep 2018 09:51:55 +0000 (09:51 +0000)] 
Fixed negotiate_kerberos_auth memory leaks (#285)

The fixed leaks do not affect runtime (i.e. request processing) code.
The helper was not deallocating some memory when exiting.

5 years agoPrep for 4.3
Amos Jeffries [Sat, 29 Sep 2018 14:34:00 +0000 (03:34 +1300)] 
Prep for 4.3

5 years agoDocs: make doxygen happier and fix some comments (#293) M-staged-PR293
Amos Jeffries [Fri, 28 Sep 2018 15:33:12 +0000 (15:33 +0000)] 
Docs: make doxygen happier and fix some comments (#293)

* Update some code syntax for doxygen's naive parser.

* Fix duplicate section IDs in doxygen comments.

* Fix some doxygen markup typos.

* Remove an unnecessary todo.

No logical changes.

5 years agoBug 4885: Excessive memory usage when running out of descriptors (#291)
Craig Gowing [Thu, 27 Sep 2018 08:21:27 +0000 (08:21 +0000)] 
Bug 4885: Excessive memory usage when running out of descriptors (#291)

TcpAcceptor now stops listening when it cannot accept due to FD limits.
We also no longer defer/queue the same limited TcpAcceptor multiple
times. These changes prevent unbounded memory growth and improve
performance of Squids running out of file descriptors. They should have
no impact on other Squids.

5 years agocloneReply() "reply == NULL" assertion when denying replies (#292)
Eduard Bagdasaryan [Tue, 25 Sep 2018 14:42:01 +0000 (14:42 +0000)] 
cloneReply() "reply == NULL" assertion when denying replies (#292)

Commit e2cc8c0 lost argument nullification when converting old
HTTPMSGUNLOCK() macro into a function. This change restores that
important part of the HTTPMSGUNLOCK() API without sacrificing argument
type checks added during that conversion.

5 years agoBug 4875 pt1: GCC-8 compile errors with -O3 optimization (#287)
Amos Jeffries [Tue, 18 Sep 2018 17:43:59 +0000 (17:43 +0000)] 
Bug 4875 pt1: GCC-8 compile errors with -O3 optimization (#287)

 Use xstrncpy instead of strncat for String appending

Our xstrncpy() is safer, not assuming the existing char*
is nul-terminated and accounting explicitly for the
nul-terminator byte.

GCC-8 -O3 optimizations were exposing a strncat() output
truncation of the terminator when insufficient space was
available in the String buffer.

We suspect the GCC error to be a false-positive for -O3
builds and, even it it is accurate, these changes should
not affect builds with lower optimization levels.

5 years agolangpack: Add missing dialect aliases (#286)
Amos Jeffries [Mon, 17 Sep 2018 07:00:42 +0000 (07:00 +0000)] 
langpack: Add missing dialect aliases (#286)

ca-es - Spanish in Catalan
en-cn - English in mainland China
pt-xl - Portuguese in wider South America
en-xl - Spanish in wider South America

5 years agoFix range_offset_limit debugging (#164) M-staged-PR164
sujiacong [Mon, 17 Sep 2018 02:41:19 +0000 (02:41 +0000)] 
Fix range_offset_limit debugging (#164)

5 years agoFix basic_pop3_auth startup errors (#284)
Andreas Hasenack [Mon, 10 Sep 2018 19:40:55 +0000 (19:40 +0000)] 
Fix basic_pop3_auth startup errors (#284)

90cf12e added "use strict" which requires declaring all variables.

Originally reported (against Squid v3) at
https://bugs.launchpad.net/ubuntu/+source/squid3/+bug/1755189

5 years agoBug 4691: balance_on_multiple_ip config option docs (#273) 280/head
Amos Jeffries [Fri, 7 Sep 2018 16:11:33 +0000 (16:11 +0000)] 
Bug 4691: balance_on_multiple_ip config option docs (#273)

Add missing balance_on_multiple_ip removal documentation
after the active code was removed by 3.2 TCP connection
server selection changes.

5 years agoRemove non-standard, redundant new/delete operator replacements (#283)
Francesco Chemolli [Thu, 6 Sep 2018 15:24:37 +0000 (15:24 +0000)] 
Remove non-standard, redundant new/delete operator replacements (#283)

This change also fixes icc builds: Commit 39cca4e missed noexcept
specification for nothrow variants of new and delete operators,
and the icc compiler did not like that.

Furthermore, we can simplify the replacements because, according
to cppreference, with C++11, "replacing the throwing single object
allocation functions is sufficient to handle all [allocations and
deallocations]".

5 years agoBug 4877: Add missing text about external_acl_type %DATA changes (#276) M-staged-PR276
Amos Jeffries [Wed, 5 Sep 2018 18:17:48 +0000 (18:17 +0000)] 
Bug 4877: Add missing text about external_acl_type %DATA changes (#276)

Conversion of external_acl_type to using logformat macros was
not quite seamless. The %DATA macro now expands to a dash '-' to
fix helpers using it explicitly from receiving incorrect number
of fields (and misaligned input) on their input lines.

Unfortunately that also results in the implicit use of that
macro expanding to non-whitespace ('-'). That small fact was not
documented in the initial v4 release notes and config texts.

5 years agoBug 4716: Blank lines in cachemgr.conf are not skipped (#274) M-staged-PR274
Amos Jeffries [Wed, 5 Sep 2018 15:23:45 +0000 (15:23 +0000)] 
Bug 4716: Blank lines in cachemgr.conf are not skipped (#274)

The default cachemgr.conf contains three lines other than
comments. Two of them are blank, the third is "localhost".
These blank lines show up in the "Cache Server" list in the
CGI output.

5 years agoRemove reference on bzr from test-suite (#282)
Francesco Chemolli [Tue, 4 Sep 2018 21:44:44 +0000 (22:44 +0100)] 
Remove reference on bzr from test-suite (#282)

5 years agoUpdate systemd dependencies in squid.service (#264) M-staged-PR264 SQUID_3_5_27
Amos Jeffries [Tue, 7 Aug 2018 13:00:02 +0000 (13:00 +0000)] 
Update systemd dependencies in squid.service (#264)

The network.target is not sufficient to guarantee network
interfaces and IPs are assigned and available. Particularly when
systemd is not in charge of the IP assignment itself.

Use network-online.target as well, which should ensure network
is properly configured and online before starting Squid.

5 years agoPrep for 4.2 (#268) M-staged-PR268
Amos Jeffries [Sat, 4 Aug 2018 19:40:10 +0000 (19:40 +0000)] 
Prep for 4.2 (#268)

Assuming that PR 247 is merged within the next day
and backported with this.

5 years agoDo not update stored headers on HTTP 304 responses (#267) M-staged-PR267
Alex Rousskov [Thu, 2 Aug 2018 17:23:15 +0000 (17:23 +0000)] 
Do not update stored headers on HTTP 304 responses (#267)

... until we learn how to synchronize stored and in-transit metadata.

This temporary disables a feature first introduced in commit abf396e.

5 years agoFixed build on FreeBSD v11.2 (#266) M-staged-PR266
Ture Pålsson [Wed, 1 Aug 2018 15:34:09 +0000 (15:34 +0000)] 
Fixed build on FreeBSD v11.2 (#266)

... and other platforms where htonl() is a macro that uses its argument
multiple times (GCC -Werror=sequence-point).

5 years agoDo not send Content-Length in 1xx or 204 responses (#249)
Eduard Bagdasaryan [Tue, 31 Jul 2018 22:08:31 +0000 (22:08 +0000)] 
Do not send Content-Length in 1xx or 204 responses (#249)

This is RFC 7230 section 3.3.2 requirement.

5 years agoUse AnyP::Uri to generate ASN request URI (#258) M-staged-PR258
Amos Jeffries [Fri, 27 Jul 2018 00:12:11 +0000 (00:12 +0000)] 
Use AnyP::Uri to generate ASN request URI (#258)

Removes the fixed size asres c-string buffer the URL was
using by replacing with an SBuf and dynamic xstrdup().

Also, make AS_REQBUF_SZ configurable at build time with
-DAS_REQBUF_SZ=nn.

TODO: convert the store API to accept AnyP::Uri instead of
c-string will remove 1-2 memory reallocations.

5 years agoOptimization: Faster response headers packing (#230) M-staged-PR230
Eduard Bagdasaryan [Thu, 26 Jul 2018 17:44:14 +0000 (17:44 +0000)] 
Optimization: Faster response headers packing (#230)

Packing reply headers into StoreEntry/ShmWriter directly means numerous
tiny append() calls which involve expensive mem_node/slice searches. For
example, every two-byte ": " and CRLF delimiter is packed separately.

5 years agoBug 4870: milliseconds logformats prepend 0s instead of spaces (#255) M-staged-PR255
Amos Jeffries [Wed, 25 Jul 2018 13:47:20 +0000 (13:47 +0000)] 
Bug 4870: milliseconds logformats prepend 0s instead of spaces (#255)

5 years agoRestored support for the https_port clientca option (#252) M-staged-PR252
Alex Rousskov [Wed, 18 Jul 2018 04:10:00 +0000 (04:10 +0000)] 
Restored support for the https_port clientca option (#252)

Probably missing since commit 621f429.

5 years agoTrivialDB support (#223)
Amos Jeffries [Tue, 17 Jul 2018 23:36:31 +0000 (23:36 +0000)] 
TrivialDB support (#223)

Allow use of Samba TrivialDB instead of outdated BerkleyDB in
the session helper.

Require TrivialDB support for use of the time_quota helper.
libdb v1.85 is no longer supported by distributors and
upgrading to v5 only to deprecate use does not seem to be
worthwhile.

5 years agoFix %>ru logging of huge URLs (#229) M-staged-PR229
Eduard Bagdasaryan [Tue, 17 Jul 2018 15:31:23 +0000 (15:31 +0000)] 
Fix %>ru logging of huge URLs (#229)

When dealing with an HTTP request header that Squid can parse but that
contains request URI length exceeding the 8K limit, Squid should log the
URL (prefix) instead of a dash. Logging the URL helps with triaging
these unusual requests. The older %ru (LFT_REQUEST_URI) was already
logging these huge URLs, but %>ru (LFT_CLIENT_REQ_URI) was logging a
dash. Now both log the URL (or its prefix).

As a side effect, %>ru now also logs error:request-too-large,
error:transaction-end-before-headers and other Squid-specific
pseudo-URLs, as appropriate.

Also refactored request- and URI-recording code to reduce chances of
similar inconsistencies reappearing in the future.

Also, honor strip_query_terms in %ru for large URLs. Not stripping query
string in %ru was a security problem.

Also fixed a bug with "redirected" flag calculation in
ClientHttpRequest::handleAdaptedHeader(). In general, http->url and
request->url should not be compared directly, because the latter always
passes through uri_whitespace cleanup, while the former does not.

Also fixed a bug with possibly wrong %ru after redirection:
ClientHttpRequest::log_uri was not updated in this case.

Also initialize AccessLogEntry::request and AccessLogEntry::notes ASAP.
Before this change, these fields were initialized in
ClientHttpRequest::doCallouts(). It is better to initialize them just
after the request object is created so that ACLs, running before
doCallouts(), could have them at hand. There are at least three such
ACLs: force_request_body_continuation, spoof_client_ip and
spoof_client_ip.

Also synced %ru and %>ru documentation with the current code.

5 years agoRemove NullStoreEntry (#241) M-staged-PR241
Eduard Bagdasaryan [Mon, 16 Jul 2018 12:47:52 +0000 (12:47 +0000)] 
Remove NullStoreEntry (#241)

A nil pointer is the proper way to indicate a missing heap-allocated
object in C++. Removing NullStoreEntry simplifies and optimizes code.
This removal also brings us one step closer to removing all virtual
methods from StoreEntry, further optimizing code and even saving 8 bytes
per non-shared memory cache entry on most platforms.

Also un-virtualized a few StoreEntry-only methods to optimize their
callers.

5 years agoOptimization: Fewer memory (re)allocations for HTTP headers (#239) M-staged-PR239
Eduard Bagdasaryan [Fri, 13 Jul 2018 21:27:19 +0000 (21:27 +0000)] 
Optimization: Fewer memory (re)allocations for HTTP headers (#239)

Tests revealed multiple fresh memory allocations/deallocations while
storing small (few fields) HTTP headers. Many popular sites use larger
headers (15-30 fields). To avoid expensive memory operations:

1. Pool all std::vector<HttpHeaderEntries*> memory allocations.
2. Prevent reallocations (for HTTP headers with fewer than 32 fields).

This optimization deals with storing the header index. It does not
affect how individual header fields are stored.

5 years agoPrep for 3.5.28 (#251)
Amos Jeffries [Tue, 10 Jul 2018 20:20:48 +0000 (20:20 +0000)] 
Prep for 3.5.28  (#251)

Documentation updates for next 3.5 release.

5 years agoThe %>handshake logformat code (#243)
Christos Tsantilas [Tue, 10 Jul 2018 09:07:16 +0000 (09:07 +0000)] 
The %>handshake logformat code (#243)

Logging client "handshake" bytes is useful in at least two contexts:

* Runtime traffic bypass and bumping/splicing decisions. Identifying
  popular clients like Skype for Business (that uses a TLS handshake but
  then may not speak TLS) is critical for handling their traffic
  correctly. Squid does not have enough ACLs to interrogate most TLS
  handshake aspects. Adding more ACLs may still be a good idea, but
  initial sketches for SfB handshakes showed rather complex
  ACLs/configurations, _and_ no reasonable ACLs would be able to handle
  non-TLS handshakes. An external ACL receiving the handshake is in a
  much better position to analyze/fingerprint it according to custom
  admin needs.

* A logged handshake can be used to analyze new/unusual traffic or even
  trigger security-related alarms.

The current support is limited to cases where Squid was saving handshake
for other reasons. With enough demand, this initial support can be
extended to all protocols and port configurations.

This is a Measurement Factory project.

5 years agoSource Format Enforcement (#244)
squidadm [Mon, 9 Jul 2018 09:15:57 +0000 (09:15 +0000)] 
Source Format Enforcement (#244)

5 years agoBug 4865: Unexpected exception on startup in TypedMsgHdr::sync() (#242) M-staged-PR242
Alex Rousskov [Fri, 6 Jul 2018 23:58:22 +0000 (23:58 +0000)] 
Bug 4865: Unexpected exception on startup in TypedMsgHdr::sync() (#242)

Commit b56b37c broke Ipc::TypedMsgHdr copying by incorrectly assuming
that sync() sets name and ios members. The sync() method sets _other_
(low level) members based on name and ios.

5 years agoDo not assign nil values in ACLFilledChecklist::syncAle() (#240)
Eduard Bagdasaryan [Fri, 6 Jul 2018 12:34:30 +0000 (12:34 +0000)] 
Do not assign nil values in ACLFilledChecklist::syncAle() (#240)

Being explicit about nil parameters protects (future) code from
dereferencing them.

5 years agoOptimization: Fewer epoll(2) system calls when closing a socket (#235) M-staged-PR235
Eduard Bagdasaryan [Fri, 6 Jul 2018 04:08:37 +0000 (04:08 +0000)] 
Optimization: Fewer epoll(2) system calls when closing a socket (#235)

Squid was calling epoll(2) twice to clear a socket interest. One call is
more than enough: Technically, close(2) is supposed to clear epoll(2)
registration for us, but I did not risk relying on that.

In other environments, socket interest changes are pooled together
before being submitted to the OS, so Squid was doing a bit of extra
work, but not making (many) extra system calls AFAICT.

Also fixed (previously unused) Comm::ResetSelect() on these platforms:
* epoll(2): The old resetting code did not clear our interest AFAICT.
* kqueue(2): The old resetting code made no sense to me at all.
* poll(2): There was no code at all.
* select(Win32): There was no code at all.

Even though Comm::ResetSelect() implementation is now the same for all
platforms, I did not make that code platform-agnostic because it is
possible to optimize it further in platform-specific ways.

5 years agoDocumented when helper requests get queued (#238) M-staged-PR238
Alex Rousskov [Wed, 4 Jul 2018 15:59:26 +0000 (15:59 +0000)] 
Documented when helper requests get queued (#238)

I had to change introductory paragraphs in several directives so that
the new documentation can refer to "numberofchildren". I fixed a few
spelling/grammar problems in changed paragraphs and edited them a bit
for consistency, but they need more work.

Motivation:
http://lists.squid-cache.org/pipermail/squid-users/2018-July/018577.html

5 years agoFix segmentation fault on -k parse (#218) M-staged-PR218
Amos Jeffries [Wed, 4 Jul 2018 10:30:12 +0000 (10:30 +0000)] 
Fix segmentation fault on -k parse (#218)

When an HTTPS or SSL-Bump port is configured without a cert=
parameter it results in a segmentation fault. Detect that
occurance and add the required FATAL error message instead for
these configurations where cert= is a parameter rather than an
option.

Our project terminology for config settings is;

 "parameter"
 -  a required setting. Print a FATAL error message if missing.

 "option"
 -  an optional setting. Ignored or default value if missing.

5 years agoBug 4843 pt3: GCC-8 fixes and refactoring (#172)
Amos Jeffries [Wed, 4 Jul 2018 06:54:17 +0000 (06:54 +0000)] 
Bug 4843 pt3: GCC-8 fixes and refactoring (#172)

GCC-8 enables a lot more warnings related to unsafe coding
practices. The old Squid code contains a lot of risky buffer
size assumptions and implicit assumptions about C-string strcat,
strncat and snprintf  changes when operating on those buffers -
many can result in output truncation. Squid's use of -Werror
makes these many issues all go from warnings to outright
compile failures.

Rather than just extending the char* buffer sizes not to
truncate this work seeks to actually remove the issues
permanently by converting to SBuf and updated Squid coding
styles.

The C++1z compilers (GCC-8 and Clang 4.0) are beginning to warn
about C functions memset/memcpy/memmove being used on class
objects which lack "trivial copy" constructor or assignment
operator - their use is potentially unsafe where anything more
complex than trivial copy/blit is required. A number of classes
in Squid are safely copied or initialized with those functions
for now but again the -Werror makes these hard errors.
Completing affected objects conversion from C to C++ code avoids
any deeply hidden issues or adding compiler exceptions to
silence the warnings.

see individual commit messages for details on the particular
changes each does.

5 years agoMaintenance: Fix mkrelease.sh script (#237) M-staged-PR237
Amos Jeffries [Tue, 3 Jul 2018 03:28:52 +0000 (03:28 +0000)] 
Maintenance: Fix mkrelease.sh script (#237)

Release of 4.1 revealed that this regex is not fully working.
The final .NN version field is now optional.

5 years agoOptimization: Do not create/configure ACLFilledChecklist in vain (#232)
Eduard Bagdasaryan [Mon, 2 Jul 2018 12:41:26 +0000 (12:41 +0000)] 
Optimization: Do not create/configure ACLFilledChecklist in vain (#232)

While client_db is required for client-side pools to work, it may be
enabled for other reasons, without any client-side pools configured. We
should not create and configure useless ACLFilledChecklist objects
because those operations are already not trivial today and have a
a tendency of becoming more expensive with time.

5 years agoOptimization: Reuse CharacterSets when parsing HTTP responses (#231)
Eduard Bagdasaryan [Mon, 2 Jul 2018 03:14:14 +0000 (03:14 +0000)] 
Optimization: Reuse CharacterSets when parsing HTTP responses (#231)

Expensive CharacterSet objects creation and manipulation was happening
for virtually every HTTP miss since 6fe0370.

Also removed code duplication.

5 years agov4.1 release notes (#234)
Amos Jeffries [Mon, 2 Jul 2018 03:14:06 +0000 (15:14 +1200)] 
v4.1 release notes (#234)

* Release Notes update for 4.1

* Update CONTRIBUTORS from changeset records

* Add ChangeLog entries for scheduled backports

5 years agoResume using "Short Strings" memory pool ignored since 91bb468 (#227) M-staged-PR227
Eduard Bagdasaryan [Thu, 28 Jun 2018 17:14:32 +0000 (17:14 +0000)] 
Resume using "Short Strings" memory pool ignored since 91bb468 (#227)

memFindStringSizeType() misused mem_type as a string pool index,
resulting in index 0 (of the first pool) mapped to MEM_NONE and ignored.

5 years agoSupply ALE for force_request_body_continuation ACL (#226)
Eduard Bagdasaryan [Thu, 28 Jun 2018 11:20:04 +0000 (11:20 +0000)] 
Supply ALE for force_request_body_continuation ACL (#226)

cb36505 already covered many (but not all) similar cases.

5 years agoBug 4579: cannot hit an entry being written by another worker (#183)
Eduard Bagdasaryan [Thu, 28 Jun 2018 08:34:01 +0000 (08:34 +0000)] 
Bug 4579: cannot hit an entry being written by another worker (#183)

... and addressed XXX in 4310f8b commit.

This change disassociates Transients from collapsed forwarding, enabling
it for SMP caching configurations. Before this change, SMP Squid worker
could not read an entry being written by another worker. Besides
unexpected misses, there could be another (worse) negative effect: The
reader worker could get stuck because it did not get updates via
the Transients mechanism.

Also deprecate the collapsed_forwarding_shared_entries_limit directive
name in favor of shared_transient_entries_limit.

Also removed top-level Storage::smpAware() because memory cache SMP
awareness is determined by configuration and is now computed before we
create the memory cache Storage object. This ability to assess SMP
awareness earlier helps decide whether to create Transients segments.

Also eliminated code duplication in a couple of MemStoreRr methods.

5 years agoAdded a sample Kerberos group authentication external_acl helper (#202) M-staged-PR202
huaraz [Sun, 24 Jun 2018 16:01:28 +0000 (16:01 +0000)] 
Added a sample Kerberos group authentication external_acl helper (#202)

5 years agoFix --with-netfilter-conntrack error message (#225) M-staged-PR225
Marcos Mello [Fri, 22 Jun 2018 10:49:40 +0000 (10:49 +0000)] 
Fix --with-netfilter-conntrack error message (#225)

Typo: The nonexistent directory error should say --with, not --without.

5 years agoIdentify collapsed transactions (#213)
Eduard Bagdasaryan [Mon, 18 Jun 2018 16:51:34 +0000 (16:51 +0000)] 
Identify collapsed transactions (#213)

Added a new CF tag to the Squid request status %Ss access log field.
This tag marks transactions that have waited for a CF initiator
transaction. This wait may happen in two cases (or their combination):

1. Classic collapsing: A client request gets collapsed on arrival
   (e.g., TCP_CF_HIT or TCP_CF_MISS).
2. Collapsed revalidation: An internal revalidation request is collapsed
   (e.g., TCP_CF_REFRESH_MODIFIED).

A CF tag approach is simple but the resulting access.log records cannot
distinguish some cases. For example, a pure collapsed revalidation
transaction (case 2) cannot be distinguished from these transactions:
* a collapsed client that got collapsed on revalidation (case 1+2);
* a collapsed client that initiated revalidation.

We may want to log more collapsing details in the future.

These changes do not affect CF initiating code.

In order to track collapsed transactions, a new CollapsingHistory class
was introduced. Since more and more non-logging code relies on ALE, this
history is kept in ALE. ClientHttpRequest uses its logType field instead
of the LogTags in ALE, so we also use logType for storing
ClientHttpRequest's CollapsedHistory. Eventually, ClientHttpRequest
should eliminate logType in favor of direct ALE use.

Also: ICP code fixing/refactoring:
* htcpSyncAle() and icpSyncAle() should not require the caller to supply
  correct LogTags because callers like fillChecklist() do not have
  access to that information (it is not stored in the transaction object
  unlike the other pieces of info that these functions copy to ALE).
* Added icpUdpData::ale to preserve master transaction info when
  messages are queued. Several icpUdpData improvements were triggered by
  this change because ale is a (second!) non-POD member and icpUdpData
  was mistreated as a POD. They include:
  - Removed icpUdpData::start as unused.
  - Removed icpUdpData::len as set but otherwise unused.
  - Removed icpUdpData::logcode as essentially duplicating msg->opcode.
* Update ICP ALE, if any, as soon as the transaction tags become known
  (instead of sometimes waiting for the ICP message to be logged). The
  ICP message may be dropped and/or never be logged, but we should keep
  ALE up to date because it is used in an increasingly many contexts.

Also found and marked an ICP memory leak. It is best to fix that in a
dedicated commit.

Also supplied URN code with ALE. Full-featured Client-based classes
already use ALE. We have not tested with URNs, but these changes may
improve logging of transactions that involve URN resolution.

Also fixed problematic StoreEntry::collapsingInitiator(). It could
return true if the entry had transients but had nothing to do with
collapsing. It also incorrectly assumed that a collapsed entry is always
marked with ENTRY_FWD_HDR_WAIT. That assumption is wrong because
Controller::allowCollapsing() does not set this flag for the entry.

We did not find a better way to track StoreEntry objects associated with
CF initiators than to add a new StoreEntry flag. Hitting an entry
flagged with ENTRY_REQUIRES_COLLAPSING requires collapsing the request.

5 years agoBug 4791: Build failure on MacOS (#220) M-staged-PR220
Amos Jeffries [Tue, 12 Jun 2018 15:38:17 +0000 (15:38 +0000)] 
Bug 4791: Build failure on MacOS (#220)

The src/URL.h and src/acl/Url.h files clash on MacOS case-
insensitive filesystem.

Resolve this and incorrect naming issue by moving class URL into
the AnyP namespace as AnyP::Uri.

5 years agoFeature detect cpu_set_t (#221) M-staged-PR221
Amos Jeffries [Mon, 11 Jun 2018 22:01:17 +0000 (22:01 +0000)] 
Feature detect cpu_set_t (#221)

Some OS define this type but do not define __cpu_set_t_defined.
Use proper feature detection instead of relying on the macro.

5 years agoBug 4223: fixed retries of failed re-forwardable transactions (#211)
Eduard Bagdasaryan [Mon, 11 Jun 2018 10:44:37 +0000 (10:44 +0000)] 
Bug 4223: fixed retries of failed re-forwardable transactions (#211)

This change fixes Store to delay writing (and, therefore, sharing) of
re-triable errors (e.g., 504 Gateway Timeout responses) to clients:
once we start sharing the response with a client, we cannot re-try the
transaction. Since ENTRY_FWD_HDR_WAIT flag purpose is to delay response
sharing with Store clients, this patch fixes and clarifies its usage:

1. Removes unconditional clearing from startWriting().
2. Adds a conditional clearing to StoreEntry::write().
3. Sets it only for may-be-rejected responses.

(2) adds ENTRY_FWD_HDR_WAIT clearing to detect responses that filled the
entire read buffer and must be shared now with the clients because
they can no longer be retried with the current re-forwarding mechanisms
(which rely on completing the bad response transaction first) and will
get stuck. Such large re-triable error responses (>16KB with default
read_ahead_gap) should be uncommon. They were getting stuck prior to
master r12501.1.48. That revision started clearing ENTRY_FWD_HDR_WAIT in
StoreEntry startWriting() unconditionally, allowing all errors to be
sent to Store clients without a delay, and effectively disabling
retries.

Mgr::Forwarder was always setting ENTRY_FWD_HDR_WAIT, probably mimicking
similarly aggressive FwdState behavior that we are now removing. Since
the forwarder never rewrites the entry content, it should not need to
set that flag. The forwarder and associated Server classes must not
communicate with the mgr client during the client-Squid connection
descriptor handoff to Coordinator, but ENTRY_FWD_HDR_WAIT is not the
right mechanism to block such Squid-client communication. The flag
does not work well for this purpose because those Server classes may
(and do?) substitute the "blocked" StoreEntry with another one to
write an error message to the client.

Also moved ENTRY_FWD_HDR_WAIT clearance from many StoreEntry::complete()
callers to that method itself. StoreEntry::complete() is meant to be the
last call when forming the entry. Any post-complete entry modifications
such as retries are prohibited.

5 years agoPrep for 4.0.25 (#219)
Amos Jeffries [Mon, 11 Jun 2018 10:44:30 +0000 (22:44 +1200)] 
Prep for 4.0.25 (#219)

5 years agoBug 4831: filter chain certificates for validity when loading (#187)
Amos Jeffries [Tue, 5 Jun 2018 06:11:29 +0000 (06:11 +0000)] 
Bug 4831: filter chain certificates for validity when loading (#187)

51e09c08a5e6c582e7d93af99a8f2cfcb14ea9e6 adding
GnuTLS support required splitting the way
certificate chains were loaded. This resulted in the
leaf certificate being added twice at the prefix of a
chain in the serverHello.

It turns out that some recipients validate strictly that the
chain delivered by a serverHello does not contain extra
certificates and reject the handshake if they do.

This patch implements the XXX about filtering certificates
for chain sequence order and self-sign properties, added
in the initial PR. Resolving the bug 4831 regression and also
reporting failures at startup/reconfigure for admins.

Also, add debug display of certificate names for simpler
detection and administrative fix when loaded files fail
these tests.

5 years agoBug 4855: re-enable querying private entries for HTCP/ICP (#214)
Eduard Bagdasaryan [Wed, 30 May 2018 11:58:49 +0000 (11:58 +0000)] 
Bug 4855: re-enable querying private entries for HTCP/ICP (#214)

This was broken since 4310f8b: HTCP/ICP misused Store as a storage of
private entries during queries (e.g., see
neighborsUdpPing()/neighborsUdpAck()). A smarter HTCP/ICP
implementation would maintain its own StoreEntry cache for this purpose
(just like the existing queried_keys array for cache keys). However,
fixing this is beyond this issue scope.

5 years agoBug 4707: purge tool does not obey --sysconfdir= build option (#210) M-staged-PR210
Amos Jeffries [Tue, 22 May 2018 12:55:35 +0000 (12:55 +0000)] 
Bug 4707: purge tool does not obey --sysconfdir= build option (#210)

The purge tool was still using DEFAULT_SQUID_CONF macro from
before it was bundled with Squid, which had no connection to our
./configure script.

Update it to the DEFAULT_CONFIG_FILE macro used by other Squid
binaries and fix some existing issues with that macro's use by
binaries outside 'squid'.

5 years agoUpdate sslcrtd_program configuration directive documentation (#209) M-staged-PR209
Marcos Mello [Mon, 21 May 2018 20:57:12 +0000 (20:57 +0000)] 
Update sslcrtd_program configuration directive documentation (#209)

Catch it up with 505f9427c55a365b464f1b204880df1d3ccccb7f.

5 years agoBug 4843 pt2: squidclient refactoring for GCC-8 (#208) M-staged-PR208
Amos Jeffries [Sun, 20 May 2018 15:46:50 +0000 (15:46 +0000)] 
Bug 4843 pt2: squidclient refactoring for GCC-8 (#208)

Replace fixed size buffers for mime header block and additional
custom headers. This fixes long standing issues with buffer
overflow from large custom header values which have become a
hard error in GCC-8.

Also improve snprintf() URL buffer limit handling and const
correctness for Transport::Write().

5 years agoNew function to find Local listening IP and add new %A macro (#198) M-staged-PR198
Amish [Wed, 16 May 2018 19:09:52 +0000 (19:09 +0000)] 
New function to find Local listening IP and add new %A macro (#198)

Implemented a new function to find local listening IP:Port in a
consistent way and added support for %A macro in error pages and
deny_info URL using the same function.

5 years agoDocs: fix many spelling mistakes (#206) M-staged-PR206
Amos Jeffries [Tue, 15 May 2018 09:08:56 +0000 (09:08 +0000)] 
Docs: fix many spelling mistakes (#206)

... identified by Debian lintian tool.

No logic changes in this patch. Just code comment,
documentation and display strings texts.

5 years agoBug 4843 pt1: ext_edirectory_userip_acl refactoring for GCC-8 (#204)
Amos Jeffries [Sun, 13 May 2018 06:57:41 +0000 (06:57 +0000)] 
Bug 4843 pt1: ext_edirectory_userip_acl refactoring for GCC-8 (#204)

Proposed changes to this helper to fix strcat / strncat buffer
overread / overflow issues.

The approach takes three parts:

* adds a makeHexString function to replace many for-loops
  catenating bits of strings together with hex conversion into a
  second buffer. Replacing with a snprintf() and buffer overflow
  handling.

* a copy of Ip::Address::lookupHostIp to convert the input
  string into IP address binary format, then generate the hex
  string using the above new hex function instead of looped
  sub-string concatenations across several buffers.
  This removes all the "00" and "0000" strncat() calls and
  allows far simpler code even with added buffer overflow
  handling.

* replace multiple string part concatenations with a few simpler
  calls to snprintf() for all the search_ip buffer constructions.
  Adding buffer overflow handling as needed for the new calls.

5 years agoSupply AccessLogEntry (ALE) for more fast ACL checks. (#182) M-staged-PR182
Eduard Bagdasaryan [Fri, 11 May 2018 08:32:06 +0000 (08:32 +0000)] 
Supply AccessLogEntry (ALE) for more fast ACL checks. (#182)

Supplying ALE for fast ACL checks allows those checks to use ACLs that
assemble values from logformat %codes. Today, such ACLs are limited to
misplaced external ACLs (that should not be used with "fast"
directives!), but it is likely that fast ACLs like annotate_client will
eventually require ALE.

The "has" ACL documentation promises ALE for every transaction, but our
code does not deliver on that promise. This change fixes a dozen of
easy cases where ALE was available nearby. Also a non-trivial
cache_peer_access case was fixed, which proved to be more complex
because of the significant call depth of the peerAllowedToUse() check,
which is a known design problem of its own.

More cases need fixing, and the whole concept of ALE probably needs to
be revised because logformat %code expansion is needed in the
increasing number of contexts that have nothing to do with access
logging.

Also fixed triggering of (probably pointless) level-1 warnings:

* ALE missing adapted HttpRequest object
* ALE missing URL

With fix applied, any ACLChecklist with ALE synchronizes it at
'pre-check' stage without logging level-1 warnings. Warnings are
triggered only if for some reason this 'pre-check' synchronization was
bypassed.

5 years agoBug 4042: ext_kerberos_ldap_group: add -P principal option (#195) M-staged-PR195
huaraz [Sun, 6 May 2018 16:06:42 +0000 (16:06 +0000)] 
Bug 4042: ext_kerberos_ldap_group: add -P principal option (#195)

Added a -P principal option to ext_kerberos_ldap_group to
select a principal from the keytab overwriting the automated
method which may make it more responsive.

6 years agoBug 4845: NegotiateSsl crash on aborting transaction (#201)
Christos Tsantilas [Sun, 6 May 2018 11:00:38 +0000 (11:00 +0000)] 
Bug 4845: NegotiateSsl crash on aborting transaction (#201)

Security::PeerConnector::NegotiateSsl() might be called after the
Security::PeerConnector object is gone. This race condition is present
on both regular SSL and SslBump code paths, but sightings are rare.

This bug shares the underlying cause (and the solution) with bug 3505.
TODO: Adjust Comm::SetSelect() API to prevent future bugs like this.

This is a Measurement Factory project.

6 years agoBug 4847 pt1: regression in proxy_auth ACL flags (#191)
Amos Jeffries [Sat, 5 May 2018 14:42:12 +0000 (14:42 +0000)] 
Bug 4847 pt1: regression in proxy_auth ACL flags (#191)

r15058 "Support for --long-acl-options" in Squid-4.0.21
unintentionally removed the proxy_auth ACL support for -i/+i
flags. See bug report for details.

Fix proxy_auth ACL -i and +i flags no longer working by copying
RegexData flags registration, since ACLs for UserData all use
the same names and meanings.

Add documentation to indicate that ident and ext_user ACLs do
support -i/+i just like proxy_auth ACLs.

TODO: fix server_cert_fingerprint ACL which is still broken.

6 years agoRevert incorrect changes in PR189 (#199) M-staged-PR199
squidadm [Sat, 5 May 2018 11:58:34 +0000 (11:58 +0000)] 
Revert incorrect changes in PR189 (#199)

Commit a85f0df5d9226a613c14219a26c53f9a9e6c3a5f was supposed
to be documentation only, but somehow included changes from
another PR branch. Remove so the other PR can be applied with
correct commit details.

6 years agoSourceFormat Enforcement (#200) M-staged-PR200
squidadm [Fri, 4 May 2018 17:39:32 +0000 (17:39 +0000)] 
SourceFormat Enforcement (#200)

6 years agoBug 4816: update negotiate_kerberos_auth helper protocol to v3.4 (#196) M-staged-PR196
huaraz [Thu, 3 May 2018 18:45:19 +0000 (18:45 +0000)] 
Bug 4816: update negotiate_kerberos_auth helper protocol to v3.4 (#196)

Updated negotiate_kerberos_auth to use latest helper protocol
with key=value pairs.

6 years agoBug 4852: regression in deny_info %R macro (#193) M-staged-PR193
Amos Jeffries [Thu, 3 May 2018 15:52:04 +0000 (15:52 +0000)] 
Bug 4852: regression in deny_info %R macro (#193)

SBuf::c_str() produces a temporary c-string which is not
guaranteed to survive, and does not survive as long as required
to print the deny_info URL. The HttpRequest::url path SBuf has
a much longer lifetime, so use a const reference to it instead.

This was added in 51b5dcf59c93ef76fefacfeae837b076a624596e
along with many other identical uses which have since been
removed by other refactorings.

6 years agoBug 4171: checking for log_file_daemon despite disabling logging (#181) M-staged-PR181
Amos Jeffries [Tue, 1 May 2018 01:21:15 +0000 (01:21 +0000)] 
Bug 4171: checking for log_file_daemon despite disabling logging (#181)

6 years agoDocumentation for several ACL types (#189) M-staged-PR189
Amos Jeffries [Mon, 30 Apr 2018 22:14:17 +0000 (22:14 +0000)] 
Documentation for several ACL types (#189)

These ACL types have been available for some time but have not
yet had a mention in the squid.conf docs.

6 years agoDo not abuse argv[0] to supply roles and IDs to SMP kids (#176) M-staged-PR176
Eduard Bagdasaryan [Mon, 30 Apr 2018 16:57:53 +0000 (16:57 +0000)] 
Do not abuse argv[0] to supply roles and IDs to SMP kids (#176)

Use a newly added "--kid role-ID" command line option instead. Just like
argv[0], the new option is not meant for direct/human use.

This change allows exec(3)-wrapping tools like Valgrind to work with SMP
Squid: When launching kid processes, Valgrind does not pass Squid-formed
argv[0] to kid processes, breaking old kid role and ID detection code.

This change does not alter argv[0] of Squid processes. There is nothing
wrong with Squid-formed argv[0] values for Squid kids.

Also added a CommandLine class to support command line parsing without
code duplication. Squid needs to handle the new --kid option way before
the old mainParseOptions() handles the other options. The new class also
encapsulates argv manipulations, reducing main.cc pollution.

6 years agoAvoid ssl/helper.cc "ssl_crtd" assertions on reconfiguration (#186) M-staged-PR186
Christos Tsantilas [Mon, 16 Apr 2018 14:46:08 +0000 (14:46 +0000)] 
Avoid ssl/helper.cc "ssl_crtd" assertions on reconfiguration (#186)

Reconfiguration process consists of mainReconfigureStart() and
mainReconfigureFinish() steps separated by at least one main loop
iteration. Clearing a Squid global variable in mainReconfigureStart()
creates two problems for transactions that were started before
reconfiguration:

1. Transactions accessing that global _during_ reconfiguration loop
   iteration(s) may be confused by the variable sudden disappearance.

2. Transactions accessing that global _after_ mainReconfigureFinish()
   may be confused by the variable disappearance if reconfiguration
   resulted in the global variable becoming nil.

To remove the first problem for ssl_crtd, external_acl, and redirecting
helpers, all of them are now reconfigured "instantly", during
mainReconfigureFinish().

To prevent crashes due to the second problem, Squid now generates helper
errors if the disappeared ssl_crtd or external_acl helpers are accessed
after reconfiguration. The admin is warned about such problems via
level-1 cache.log ERROR messages.

The second problem cannot be fully solved without storing (refcounted)
configuration globals inside each transaction that uses them. Such
serious changes are outside this small assertion-fixing project scope.

This is a Measurement Factory project.

6 years agoAdd timestamps to (most) FATAL messages (#179) M-staged-PR179
Christos Tsantilas [Sat, 14 Apr 2018 02:14:46 +0000 (02:14 +0000)] 
Add timestamps to (most) FATAL messages (#179)

Reliable timestamp information is often critical for triage. We can use
the existing debugs() interface to add timestamps to FATAL messages. The
affected code already calls such risky functions as
storeDirWriteCleanLogs() so calling debugs() instead of printing
directly to files/syslog should not make things worse.

FATAL messages that were also logged to syslog (at LOG_ALERT level) are
still logged to syslog (at that same level, but now with the usual
Squid-generated prefix). Such syslog alerts can now be easily triggered
via a new ForceAlert() API.

Also treat segmentation faults, bus errors, and other signal-based
sudden deaths the same as most other FATAL errors -- log them to syslog.

This is a Measurement Factory project.

6 years agoReworked packet/connection marking (#170) M-staged-PR170
Alexander Gozman [Fri, 13 Apr 2018 02:28:57 +0000 (02:28 +0000)] 
Reworked packet/connection marking (#170)

The handling of packet and connection marks was odd: The clientside_mark
ACL worked with connection marks, but the directive of the same name
supported only packet marks. Also, clients packet MARK (if set)
overwrote CONNMARK and, as a result, broke ACL checking.

To minimize confusion, connection and packet marks are now separated:

    * renamed the clientside_mark ACL to client_connection_mark
    * renamed the clientside_mark directive to mark_client_packet
    * added a mark_client_connection directive

While the first two points just clarify things, the last one introduces
a new functionality: It allows to set or change clients CONNMARK.

Both clientside_mark ACL and directive are now deprecated.

6 years agoFixed Transient reader locking broken by 4310f8b (#161) M-staged-PR161
Alex Rousskov [Thu, 12 Apr 2018 22:12:39 +0000 (22:12 +0000)] 
Fixed Transient reader locking broken by 4310f8b (#161)

The closeForWriting() call comment is correct -- we must keep the lock,
but the optional argument was accidentally lost (when undoing the failed
attempt to remove all long-term transient locks in the feature branch).

Also polished stale comments (which led to the above bug discovery!).

Also polished addEntry() aspects that I have missed in 4310f8b.

6 years agoSupport selective CF: collapsed_forwarding_access (#151)
Eduard Bagdasaryan [Tue, 20 Mar 2018 22:53:12 +0000 (22:53 +0000)] 
Support selective CF: collapsed_forwarding_access (#151)

The new directive controls whether individual requests (including
ICP/HTCP and revalidation requests) should participate in collapsed
forwarding. Admins want to limit collapsed forwarding because it carries
significant transaction-specific risks (and benefits!).

Squid default behavior is unchanged.

Only fast ACLs are supported.

6 years agoBug 4829: IPC shared memory leaks when disker queue overflows (#175)
Craig Gowing [Tue, 20 Mar 2018 10:54:56 +0000 (10:54 +0000)] 
Bug 4829: IPC shared memory leaks when disker queue overflows (#175)

The fixed leak was accompanied by these cache.log errors:

ERROR: worker I/O push queue for ... overflow: ...

I/O queue overflows during disk read requests log the same error but do
not leak memory. Repeated overflows during disk write requests could
eventually exhaust IPC shared memory:

ERROR: ... exception: run out of shared memory pages for IPC I/O

With IPC memory exhausted due to leaks, rock disk I/O stops forever.

6 years agoBug 4828: Use feature detection for IPFilter API/ABI checks (#177) 180/head
Amos Jeffries [Sun, 18 Mar 2018 10:36:01 +0000 (23:36 +1300)] 
Bug 4828: Use feature detection for IPFilter API/ABI checks (#177)

Solaris 10+ backported IPFiter v5 features to their v4.1.9 which breaks
the IPFilterv4 logic when IPv6 is received. Resulting in crashes.
see bug 4828

6 years agoPrep for 4.0.24 (#168)
Amos Jeffries [Wed, 7 Mar 2018 04:21:08 +0000 (17:21 +1300)] 
Prep for 4.0.24 (#168)

Also update mkrelease.sh script for git

6 years agoUse va_copy() on all platforms; fixed a dangerous low-level bug (#160)
Amos Jeffries [Thu, 1 Mar 2018 23:48:28 +0000 (12:48 +1300)] 
Use va_copy() on all platforms; fixed a dangerous low-level bug (#160)

To improve cross-compilation support and to simplify code, rely on C++11
cstdarg header instead of ./configure-time va_copy() detection.

Using ./configure-time detection for va_copy() is dangerous because when
it does not work (e.g., during a poorly configured cross-compilation
attempt), Squid may crash if va_copy() was needed but was not detected.

See also: Bug 4821 and bug 753.

Also found and fixed a low-level bug: StoreEntry::vappendf() was not
using va_copy() because store.cc lacked VA_COPY #defines. The affected
code (900+ callers!) is used for cache manager responses and Gopher
gateway response compilation. If any of those calls required a buffer
larger than 4KB, the lack of those va_copy() calls could lead to crashes
and/or data corruption issues on platforms where va_copy() is required.

6 years agoFixed built-in profiling bug created by 2745fea (#162)
Alex Rousskov [Wed, 28 Feb 2018 12:18:47 +0000 (05:18 -0700)] 
Fixed built-in profiling bug created by 2745fea (#162)

6 years agoFixed a dangerous lie in the dereferenceIdle() description (#163)
Alex Rousskov [Tue, 27 Feb 2018 00:25:16 +0000 (17:25 -0700)] 
Fixed a dangerous lie in the dereferenceIdle() description (#163)

Also moved private Controller method descriptions to .cc per convention.

6 years agoBump minimum GnuTLS version required by Squid. (#156)
Amos Jeffries [Mon, 26 Feb 2018 04:00:22 +0000 (17:00 +1300)] 
Bump minimum GnuTLS version required by Squid. (#156)

PR#81 added functions only provided by GnuTLS 3.4.0 and later, but did not bump the
configure.ac check for GnuTLS to enforce that version as minimum.

6 years agoBug 4822: Build failure (-Wformat) where time_t is not long int (#158)
Alex Rousskov [Sat, 24 Feb 2018 00:33:37 +0000 (17:33 -0700)] 
Bug 4822: Build failure (-Wformat) where time_t is not long int (#158)

There is no good way to printf() time_t. AFAICT, Squid usually just
casts to (long) int. TODO: Use C++ streams (with manipulators) instead.

6 years agoFixed writing clean swap file broken by 4310f8b (#155)
Eduard Bagdasaryan [Thu, 22 Feb 2018 15:37:18 +0000 (18:37 +0300)] 
Fixed writing clean swap file broken by 4310f8b (#155)

6 years agoFix clientside_mark and client port logging in TPROXY mode (#150)
Alexander Gozman [Fri, 16 Feb 2018 10:52:58 +0000 (13:52 +0300)] 
Fix clientside_mark and client port logging in TPROXY mode (#150)

The clientside_mark ACL was not working with TPROXY because a
conntrack query could not find connmark without a true client port.

Ip::Intercept::Lookup() must return true client address, but its
TproxyTransparent() component was reseting the client port. We should
use zero port when we compute the source address for the Squid-to-peer
connection instead.

6 years agoSourceformat Enforcement (#148)
squidadm [Wed, 14 Feb 2018 11:27:56 +0000 (00:27 +1300)] 
Sourceformat Enforcement (#148)

6 years agoFix loading certificates after tls-cert= changes (#144)
Amos Jeffries [Mon, 12 Feb 2018 15:05:25 +0000 (04:05 +1300)] 
Fix loading certificates after tls-cert= changes (#144)

* Remove self-signed CA check

This check is not needed when loading the initial cert portion of a PEM file
as it will be performed later when loading the chain and was causing
self-signed CA to be rejected incorrectly.

* Fix a typo in debugs output

* Always generate static context from tls-cert= parameter

... if a cert= is provided. SSL-Bump still (for now) requires a static context as fallback when generate fails.

* Revert tlsAttemptHandshake to Squid_SSL_Accept API

* Update const correctness

* Document when initialization is skipped

6 years agoFixed localnet ACL definition in recommended/default squid.conf (#146)
Ivan Larionov [Fri, 9 Feb 2018 18:10:54 +0000 (10:10 -0800)] 
Fixed localnet ACL definition in recommended/default squid.conf (#146)

... it was lacking 169.254.0.0/16 subnet due to a typo in fe204e1.

6 years agoRemoved duplicate KEY_PRIVATE debugging added in 39fe14b (#145)
Alex Rousskov [Tue, 6 Feb 2018 15:27:24 +0000 (08:27 -0700)] 
Removed duplicate KEY_PRIVATE debugging added in 39fe14b (#145)

6 years agoBug 4505: SMP caches sometimes do not purge entries (#46)
Eduard Bagdasaryan [Fri, 2 Feb 2018 20:41:40 +0000 (23:41 +0300)] 
Bug 4505: SMP caches sometimes do not purge entries (#46)

When Squid finds a requested entry in the memory cache, it does not
check whether the same entry is also stored in a cache_dir. The
StoreEntry object may become associated with its store entry in the
memory cache but not with its store entry on disk. This inconsistency
causes two known problems:

1. Squid may needlessly swap out the memory hit to disk, either
   overwriting an existing (and identical) disk entry or, worse,
   creating a duplicate entry on another disk. In the second case, the
   two disk entries are not synchronized and may eventually start to
   differ if one of them is removed or updated.

2. Squid may not delete a stale disk entry when needed, violating
   various HTTP MUSTs, and eventually serving stale [disk] cache entries
   to clients.

Another purging problem is not caused by the above inconsistency:

3. A DELETE request or equivalent may come for the entry which is still
   locked for writing. Squid fails to get a lock for such an entry (in
   order to purge it) and the entry remains in disk and/or memory cache.

To solve the first two problems:

* StoreEntry::mayStartSwapout() now avoids needless swapouts by checking
  whether StoreEntry was fully loaded, is being loaded, or could have
  been loaded from disk. To be able to reject swapouts in the last case,
  we now require that the newer (disk) entries explicitly delete their
  older variants instead of relying on the Store to overwrite the older
  (unlocked) variant. That explicit delete should already be happening
  in higher-level code (that knows which entry is newer and must mark
  any stale entries for deletion anyway).

To fix problem #3:

* A new Store::Controller::evictIfFound(key) method purges (or marks for
  deletion if purging is impossible) all the matching store entries,
  without loading the StoreEntry information from stores. Avoiding
  StoreEntry creation reduces waste of resources (the StoreEntry object
  would have to be deleted anyway) _and_ allows us to mark being-created
  entries (that are locked for writing and, hence, cannot be loaded into
  a StoreEntry object).

XXX: SMP cache purges may continue to malfunction when the Transients
table is missing. Currently, Transients are created only when the
collapsed_forwarding is on. After Squid bug 4579 is fixed, every public
StoreEntry will have the corresponding Transients entry and vice versa,
extending these fixes to all SMP environments.

Note that even if Squid properly avoids storing duplicate disk entries,
some cache_dir manipulations by humans and Squid crashes may lead to
such duplicates being present.  This patch leaves dealing with potential
duplicates out of scope except it guarantees that if an entry is
deleted, then all [possible] duplicates are deleted as well.

Fixing the above problems required (and/or benefited from) many related
improvements, including some Store API changes. It is impractical to
detail each change here, but several are highlighted below.

To propagate DELETEs across workers, every public StoreEntry now has a
Transients entry.

Prevented concurrent cache readers from aborting when their entry is
release()d. Unlike abort, release should not affect current readers.

Fixed store.log code to avoid "Bug: Missing MemObject::storeId value".

Removed Transients extras used to initialize MemObject StoreID/method in
StoreEntry objects created by Transients::get() for collapsed requests.
Controlled::get() and related Controller APIs do not _require_ setting
those MemObject details: get() methods for all cache stores return
StoreEntry objects without them (because entry basics lack Store ID and
request method). The caller is responsible for cache key collision
detection. Controlled::get() parameters could include Store ID and
request method for early cache key collision detection, but adding a
StoreQuery class and improving collision detection code is outside this
project scope (and requires many changes).

Found more cases where release() should not prevent sharing.
Remaining cases need further analysis as discussed in master 39fe14b2.

Greatly simplified UFS store rebuilding, possibly fixing subtle bug(s).

Clarified RELEASE_REQUEST flag meaning, becoming 'a private StoreEntry
which can't become public anymore'. Refactored the related code,
combining two related notions: 'a private entry' and 'an entry marked
for removal'.

Do not abort collapsed StoreEntries during syncing just because the
corresponding being stored shared entry was marked for deletion. Abort
them if the shared entry has been also aborted.

Added StoreEntry helper methods to prevent direct manipulation of
individual disk-related data members (swap_dirn, swap_filen, and
swap_status). These methods help keep these related data members in a
coherent state and minimize code duplication.

6 years agoFixed "Cannot assign requested address" for to-origin TPROXY FTP data (#142)
Rybakov Andrey [Fri, 2 Feb 2018 15:26:34 +0000 (18:26 +0300)] 
Fixed "Cannot assign requested address" for to-origin TPROXY FTP data (#142)