]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
5 years agoBug 4861: HTTPMSGLOCK missing pointer safety (#228) M-staged-PR228
Amos Jeffries [Mon, 2 Jul 2018 16:36:38 +0000 (16:36 +0000)] 
Bug 4861: HTTPMSGLOCK missing pointer safety (#228)

Check that HttpMsg pointers are not nullptr before attempting to lock.

5 years ago4.1 (#236) SQUID_4_1
Amos Jeffries [Mon, 2 Jul 2018 14:57:43 +0000 (02:57 +1200)] 
4.1 (#236)

* v4.1 release notes (#234)

* Release Notes update for 4.1

* Update CONTRIBUTORS from changeset records

* Add ChangeLog entries for scheduled backports

* 4.1

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 agoFix --with-netfilter-conntrack error message (#225)
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 agoBug 4791: Build failure on MacOS (#220)
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)
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 ago4.0.25 (#222) SQUID_4_0_25
squidadm [Mon, 11 Jun 2018 16:30:57 +0000 (04:30 +1200)] 
4.0.25 (#222)

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)
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)
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)
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 agoDocs: fix many spelling mistakes (#206)
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 4811: supply AccessLogEntry (ALE) for more fast ACL checks. (#182)
Eduard Bagdasaryan [Fri, 11 May 2018 08:32:06 +0000 (08:32 +0000)] 
Bug 4811: 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 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 agoBug 4042: ext_kerberos_ldap_group: add -P principal option (#195)
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.

5 years agoSourceFormat Enforcement
SquidAdm [Wed, 9 May 2018 10:29:15 +0000 (10:29 +0000)] 
SourceFormat Enforcement

6 years agoDocumentation for several ACL types (#189)
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 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 agoBug 4816: update negotiate_kerberos_auth helper protocol to v3.4 (#196)
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)
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)
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 agoDo not abuse argv[0] to supply roles and IDs to SMP kids (#176)
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)
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)
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 agoFixed Transient reader locking broken by 4310f8b (#161)
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 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)
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 ago4.0.24 (#171) SQUID_4_0_24
squidadm [Wed, 7 Mar 2018 13:16:46 +0000 (02:16 +1300)] 
4.0.24 (#171)

6 years agoPrep for 4.0.24 (#168) (#169)
squidadm [Wed, 7 Mar 2018 12:03:50 +0000 (01:03 +1300)] 
Prep for 4.0.24 (#168) (#169)

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 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 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 agoTLS: GnuTLS implementation for listening ports and client connections (#81) (#152)
squidadm [Fri, 16 Feb 2018 22:04:09 +0000 (11:04 +1300)] 
TLS: GnuTLS implementation for listening ports and client connections (#81) (#152)

Move the http_port cert= and key= options logic to libsecurity and add GnuTLS implementation for PEM file loading. Also adds some extra debugging to clarify listening port initialization problems with the PEM files.

Enable most of the http(s)_port listening socket logic to always build except where OpenSSL-specific dependency still exists. It may seem reasonable to leave it optionally excluded for minimal builds, however a minimal proxy that does not support HTTPS in any way is increasingly useless in the modern web so preference is given to building the generic TLS related code. This also simplifies the required testing to detect code portability issues.

GnuTLS implementation is added for https_port configured with static cert=/key= parameters and the resulting TLS handshake behaviour. Squid built with GnuTLS can now act as useful parent proxies behind a SSL-Bump'ing frontend or for other clients which require a TLS explicit proxy.

Also fixes the definitions for the CertPointer and PrivateKeyPointer.

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.
Conflicts:
src/MemObject.cc

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 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)

6 years agoMake ESIParser::Parsers a std::list (#138)
Amos Jeffries [Tue, 30 Jan 2018 13:13:38 +0000 (02:13 +1300)] 
Make ESIParser::Parsers a std::list (#138)

... and Replace ESIParser::Parsers global with ESIParser::GetRegistry() lookup function

Resolves assertions on shutdown and an outstanding TODO.

6 years agoFix 889fc47 for SSL bumping with an authentication type other than the Basic (#104)
Vadim Aleksandrov [Wed, 24 Jan 2018 02:12:06 +0000 (05:12 +0300)] 
Fix 889fc47 for SSL bumping with an authentication type other than the Basic (#104)

Commit 889fc47 was made to fix issue with Basic authentication and SSL bumping. But after this commit we can no longer properly use http_access with proxy_auth/proxy_auth_regex ACL because that type of ACL always return 1(match) regardless of the conditions in the rules.

Use the caches authentication results (if any) instead of a fixed 1(match) result.

6 years agoDocs: release notes update for v4 (#137)
Amos Jeffries [Tue, 23 Jan 2018 06:55:51 +0000 (19:55 +1300)] 
Docs: release notes update for v4 (#137)

* Update reference to Squid-3.6

* Add missing squid.conf change details

6 years agoFixed store.cc "!mem_obj" assertion via peerDigestRequest (#134)
Alex Rousskov [Tue, 23 Jan 2018 21:08:02 +0000 (14:08 -0700)] 
Fixed store.cc "!mem_obj" assertion via peerDigestRequest (#134)

Broken by commit 76d61119 which (correctly) made createMeObject() assert
but missed one case where the old code should have been converted to
call the new ensureMemObject() instead.

peerDigestRequest() is called every 5 minutes, triggered by the
peerDigestCheck event. Most calls find the old digest entry that has the
same method and URIs.

6 years agoFixed Ip::Address copying (#126)
Amos Jeffries [Sat, 20 Jan 2018 04:54:16 +0000 (17:54 +1300)] 
Fixed Ip::Address copying (#126)

Explicit copy construction was slow and unnecessary.
Explicit copy assignment mishandled self copying and was unnecessary.
The remaining memcpy() calls mishandled self copying.

There are no known cases of Ip::Address self copying.

6 years ago4.0.23 release (#133) SQUID_4_0_23
Amos Jeffries [Fri, 19 Jan 2018 14:14:42 +0000 (03:14 +1300)] 
4.0.23 release (#133)

6 years agoFix indirect IP logging for transactions without a client connection (#129)
Amos Jeffries [Fri, 19 Jan 2018 01:56:49 +0000 (14:56 +1300)] 
Fix indirect IP logging for transactions without a client connection (#129)

6 years agoESI: remove custom parser (#128)
Amos Jeffries [Thu, 18 Jan 2018 20:54:50 +0000 (09:54 +1300)] 
ESI: remove custom parser (#128)

Alex Rousskov:
  let's consider removing the custom ESI parser from Squid. It is of
terrible quality and "nobody" is testing ESI code when things change. Is
the CVE risk worth supporting few platforms that do not have the right
parser libraries?

* Fixed configure.ac tests for ESI libraries

6 years agoAdded clientside_mark ACL for checking CONNMARK (#111)
Andrey [Tue, 16 Jan 2018 23:28:59 +0000 (02:28 +0300)] 
Added clientside_mark ACL for checking CONNMARK (#111)

Matches CONNMARK of accepted connections. Takes into account
clientside_mark and qos_flows mark changes (because Squid-set marks are
cached by Squid in conn->nfmark). Ignores 3rd-party marks set after
Squid has accepted the connection from a client (because Squid never
re-queries the connection to update/sync conn->nfmark).

Also added a debugs()-friendly API to print hex values.

6 years agoBug 3911: clang -fsanitize warnings (#125)
Amos Jeffries [Mon, 15 Jan 2018 18:59:37 +0000 (07:59 +1300)] 
Bug 3911: clang -fsanitize warnings (#125)

Fixes warnings from clang when -fsanitize is used. Many of these are also part of the bug 4738 issues.

    error: private field 'callback' is not used [-Werror,-Wunused-private-field]
    error: private field 'cbdata' is not used [-Werror,-Wunused-private-field]
    error: private field 'IO' is not used [-Werror,-Wunused-private-field]
    error: variable 'wccp2_router_id_element' is not needed and
    will not be emitted [-Werror,-Wunneeded-internal-declaration]

We cannot set these warnings as default options yet because the STUB code intentionally does not use any private class members, so it would error on every unit test.

* Convert Store::LocalSearch to C++ initialization

* DiskThreadsDiskFile::IO is unused after setting by the constructor

Also, take the opportunity to redo the construct using C++11 initialization

* Remove currently unused wccp2_router_id_element

This resolves clang warnings until the WCCP redesign is completed.

6 years agoSupport sending SNI in all TLS connections opened by Squid (#123)
Rusty Bird [Fri, 12 Jan 2018 14:46:39 +0000 (14:46 +0000)] 
Support sending SNI in all TLS connections opened by Squid (#123)

Add SNI support to regular (i.e., not SslBumped) TLS connections,
including transparent http->https rewrite and Secure ICAP.

6 years agoReport exception locations and exception-related polish (#119)
Alex Rousskov [Fri, 19 Jan 2018 03:27:01 +0000 (03:27 +0000)] 
Report exception locations and exception-related polish (#119)

Without location, many exceptions look identical: A growing number of
Must(entry != NULL) and Must(request) complicate triage. The location
info was already stored in TextException but was not reported.

Reporting exception location on a separate line makes admin-visible
FATAL/ERROR/WARNING messages easier to comprehend, and their primary
text becomes more "stable", which is good for documentation. Also, some
future exceptions will probably report multiple details, possibly even
context details collected as a low-level exception bubbles up to its
high-level handling/reporting code.

Also simplified/optimized TextException:

* TextException now reuses std::runtime_error message memory management
  code, including its CoW optimizations/guarantees.

* Debug and TextException code now share the source location reporting
  code (including Squid build prefix elision) in base/Here.{cc,h}.

Also simplified and polished SBuf-related exceptions, removing a few:

* Removed InvalidParamException as unused.

* Replaced SBufTooBigException with generic exceptions.
  SBufTooBigException was misused (by SBuf::plength) and not useful. No
  need to create a whole class just to parameterize an object!

* Replaced OutOfBoundsException with a generic exception.
  OutOfBoundsException was not very useful (see SBufTooBigException). It
  was used by one test case, that did not justify adding a whole class.

Also added SWALLOW_EXCEPTIONS() API to protect any code that may throw
unwanted exceptions. Reworked a few destructors after Must() changes
made it easier for GCC v6 to detect (and warn about) throwing code:

* Polished Ipc::Forwarder cleanup sequence. For Forwarders, I see no
  reason to split/duplicate swanSong() functionality via a cleanup()
  method. The swanSong() API exists so that job destructors do not need
  to make confusing virtual method calls!

* Hid the AsyncJob destructor because all jobs should be "automatically"
  deleted by the internal job code that guarantees a swanSong() call.

* Removed a bad (pair-less) StoreEntry::unregisterAbort() call from
  Mgr::Forwarder destructor, possibly left behind in or around 51ea090.

* Removed ctor/dtor entrance debugging from the classes affected by the
  "throwing destructor issue". AsyncJob covers that debugging need.

* TODO: Adjust all throwing destructors.

Conflicts:
src/SquidString.h
src/tests/testSBuf.h
test-suite/mem_hdr_test.cc

6 years agoBug 4631: security_file_certgen helper without disk cache (#95)
Dan Searle [Fri, 19 Jan 2018 01:37:16 +0000 (01:37 +0000)] 
Bug 4631: security_file_certgen helper without disk cache (#95)

* disable the certificate DB disk cache if -s and -M command line options are omitted.

E.g. with this you can change squid.conf from:
 sslcrtd_program security_file_certgen -s /var/lib/ssl_db -M 32MB
...to...
 sslcrtd_program security_file_certgen

...and it will operate without the disk cache, generating certs fresh every time.

* Remove Ssl::CertificateDb::IsEnabledDiskStore()
 Make the CertificateDb temporary objects dynamically allocated instead.

* Do command line checks in main() not the CertificateDb object.
 This avoids a risky constructor exception and simplifies validity testing of parameters.

* Update man(8) documentation

 The helper version is now 1.1. A minor version bump since it is being kept compatible with
installations using 1.0 properly but new feature available.

 Also simplify the command line SYNOPSIS and incomplete mention of sslcrtd_* squid.conf directives.

6 years agoNettle v3.4 support
squidadm [Thu, 11 Jan 2018 10:30:38 +0000 (23:30 +1300)] 
Nettle v3.4 support

Nettle crypto library v3.4 changes the Base64 coder API to require less casting between uint8_t and char types.

6 years agoRestored Squid ability to serve pure hits broken by d816577 (#107)
Eduard Bagdasaryan [Tue, 19 Dec 2017 19:11:13 +0000 (22:11 +0300)] 
Restored Squid ability to serve pure hits broken by d816577 (#107)

Since PR #79, most incoming objects got wrong served_date, becoming
immediately stale, and usually requiring revalidation.

6 years agoFix formatting errors in d8165775
SquidAdm [Sat, 25 Nov 2017 09:46:02 +0000 (09:46 +0000)] 
Fix formatting errors in d8165775

6 years agoFixed %<Hs, %<pt, %<tt, %<bs calculation bugs for error responses (#79)
Alex Rousskov [Thu, 16 Nov 2017 05:11:19 +0000 (22:11 -0700)] 
Fixed %<Hs, %<pt, %<tt, %<bs calculation bugs for error responses (#79)

This change started as a %<Hs fix described in the first bullet but
subsequent testing exposed the bug described in the second bullet,
fixing which resulted in other related fixes/improvements:

* Fixed %<Hs for received CONNECT errors: Correctly store the response
  status code for %<Hs logging (instead of misplacing it in the %>Hs
  location that was later overwritten with the correct to-client value).

* Fixed %<pt and %<tt for received CONNECT errors: Squid tunneling code
  was missing message I/O timing maintenance required for those %codes.

* Probably fixed %<bs logging bug on forwarding retries: Squid did not
  clear the (bodyBytesRead) counter between retries.

* Possibly improved %<Hs, %<pt, %<tt, %<bs logging on SslBump errors:
  request->hier member did not copy all the sslServerBump->request->hier
  details when generating an error response in
  ConnStateData::serveDelayedError().

* Probably fixed a server.all.kbytes_out and server.other.kbytes_out
  statistics bug: Squid missed written CONNECT request header bytes.

Also improved HierarchyLogEntry-related code: Reduced code duplication,
removed unnecessary destructor, and described the class. Removed
peer_http_request_sent timestamp because it ought to be equal to the
last request write time (now peer_last_write_).

TODO: Relay (expected) peer CONNECT error responses to users (instead of
hiding them behind a Squid-generated ERR_CONNECT_FAIL) and support %<h.

6 years agoBug 4679: User names not sent to url_rewrite_program (#78)
Amos Jeffries [Fri, 3 Nov 2017 05:38:40 +0000 (18:38 +1300)] 
Bug 4679: User names not sent to url_rewrite_program (#78)

Add accessors to AccessLogEntry for retrieving IDENT and External ACL user
labels in a consistent way. Use these accessors for all log and logformat
outputs.

NP: does not hide/remove the original cache.* members due to direct use
    remaining in some code locations that cannot yet be avoided.

6 years agoBug 2378: Duplicates in selected peer destinations (#112)
Alex Rousskov [Thu, 28 Dec 2017 16:35:32 +0000 (09:35 -0700)] 
Bug 2378: Duplicates in selected peer destinations (#112)

Duplicates in FwdServers lead to excessive peer connection retries, skew
in round-robin peer selection, and probably other problems.

This bug was fixed in 2008 but that v2 fix was never ported to v3. This
fix includes a bug 2408 fix for the original (bug 2378) fix, although I
adjusted bug 2408 logic to explicitly reject duplicate PINNED
destinations and to clarify why PINNED connection handling is "special".

I also centralized and improved peerAddFwdServer-related debugging,
removing duplicated and slightly inconsistent code.

6 years agoDocs: Copyright updates for 2018 (#114)
squidadm [Wed, 3 Jan 2018 17:51:55 +0000 (06:51 +1300)] 
Docs: Copyright updates for 2018 (#114)

6 years agoAutomatically revive hopeless kids on reconfigure and after a timeout. (#117)
squidadm [Thu, 4 Jan 2018 13:52:55 +0000 (02:52 +1300)] 
Automatically revive hopeless kids on reconfigure and after a timeout. (#117)

Squid declares kids with "repeated, frequent failures" as hopeless.
Hopeless kids were not automatically restarted. In the absence of
automated recovery, admins were forced to restart the whole Squid
instance (after fixing the underlying problem that led to those kid
failures). Squid instance restarts hurt users.

In many cases, the underlying kid-killing problem is temporary, and
Squid can eventually fully recover without any admin involvement.

Squid now automatically restarts a hopeless kid after a configurable
downtime (a new hopeless_kid_revival_delay directive with a 60 minute
default value).

Also restart all hopeless kids upon receiving a reconfiguration signal.

Also avoid sending signals to non-running kids, fixing an old minor bug.

6 years agoDocs: fix typo in ssl::<cert_issuer documentation (#99)
Christos Tsantilas [Mon, 11 Dec 2017 15:24:56 +0000 (17:24 +0200)] 
Docs: fix typo in ssl::<cert_issuer documentation (#99)

6 years agoFix Coverity Scan CID 1424887 (#100)
Christos Tsantilas [Wed, 13 Dec 2017 11:15:25 +0000 (13:15 +0200)] 
Fix Coverity Scan CID 1424887 (#100)

Fixed harmless missing data member initialization

6 years agoSquid FTP server dying because of an unhandled exception. (#102)
Christos Tsantilas [Thu, 14 Dec 2017 23:44:12 +0000 (01:44 +0200)] 
Squid FTP server dying because of an unhandled exception. (#102)

Related message in cache.log:
  FATAL: Dying from an exception handling failure; exception: reply

Unfortunately, Squid does not report the exact place where the exception
was thrown, however the most possible reason is a "Must(reply)" failure inside
Ftp::Server::writeErrorReply.

This is a Measurement Factory project

6 years agoBug 4715: security_file_certgen: Remove -g and -n options docs (#110)
Amos Jeffries [Fri, 22 Dec 2017 03:14:59 +0000 (16:14 +1300)] 
Bug 4715: security_file_certgen: Remove -g and -n options docs (#110)

6 years ago4.0.22 SQUID_4_0_22
squidadm [Thu, 7 Dec 2017 15:12:12 +0000 (04:12 +1300)] 
4.0.22

6 years agoValidate the shortest certificate chain
Christos Tsantilas [Mon, 4 Dec 2017 10:07:10 +0000 (12:07 +0200)] 
Validate the shortest certificate chain

Do not download remote certificate for issuer X if the received server
certificate (signed by X) can be validated using a locally available CA
certificate. According to our tests, a typical browser does not follow
'CA Issuers' references to download 'missing' certificates when the
browser can validate the origin server certificate (or its chain) using
a local CA certificate. Avoiding unnecessary validations and downloads
not only saves time, but can prevent validation failures as well!

This is Measurement Factory project

6 years agoFix compile errors on GNU/Hurd (#82)
Amos Jeffries [Sun, 26 Nov 2017 01:17:40 +0000 (14:17 +1300)] 
Fix compile errors on GNU/Hurd (#82)

LOCK_UN definition in base/File.h require sys/file.h.

6 years agoRelay peer CONNECT error status line and headers to users (#80)
Alex Rousskov [Fri, 17 Nov 2017 16:30:09 +0000 (09:30 -0700)] 
Relay peer CONNECT error status line and headers to users (#80)

Automated agents and human users (or their support staff!) often benefit
from knowing what went wrong. Dropping such details is a bad default.
For example, automation may rely on receiving the original status code.

Our CVE-2015-5400 fix (74f35ca) was too aggressive -- it hid all peer
errors behind a generic 502 (Bad Gateway) response. Pass-through peer
authentication errors were later (971003b) exposed again, but our CVE
fix intent was _not_ to hide _any_ peer errors in the first place! The
intent was to close the connection after delivering the error response.
Hiding peer errors was an (unfortunate) implementation choice.

It could be argued that some peer errors should not be relayed, but
since Squid successfully relayed all peer errors prior to 74f35ca and
continues to relay all non-CONNECT peer errors today, discriminating
peer errors is a separate (and possibly unnecessary) feature.

Ideally, Squid should mangle and relay the whole error message (instead
of sending small original headers). Squid should also relay 1xx control
messages while waiting for the final response. Unfortunately, doing so
properly, without reopening CVE-2015-5400 or duplicating a lot of
complex code, is a huge project. This small change fixes the most acute
manifestation of the "hiding errors from users" problem. The rest is a
long-term TODO.

6 years agoBug 2821: Ignore Content-Range in non-206 responses (#77)
Eduard Bagdasaryan [Thu, 16 Nov 2017 00:05:21 +0000 (03:05 +0300)] 
Bug 2821: Ignore Content-Range in non-206 responses (#77)

Squid used to honor Content-Range header in HTTP 200 OK (and possibly
other non-206) responses, truncating (and possibly enlarging) some
response bodies. RFC 7233 declares Content-Range meaningless for
standard HTTP status codes other than 206 and 416. Squid now relays
meaningless Content-Range as is, without using its value.

Why not just strip a meaningless Content-Range header? Squid does not
really know whether it is the status code or the header that is "wrong".
Let the client figure it out while the server remains responsible.

Also ignore Content-Range in 416 (Range Not Satisfiable) responses
because that header does not apply to the response body.

Also fixed body corruption of (unlikely) multipart 206 responses to
single-part Range requests. Valid multipart responses carry no
Content-Range (in the primary header), which confused Squid.

6 years agoMove TLS/SSL http_port config values to libsecurity (#51)
Amos Jeffries [Thu, 2 Nov 2017 08:14:54 +0000 (21:14 +1300)] 
Move TLS/SSL http_port config values to libsecurity (#51)

These are most of the minor shuffling prerequisite for the proposal to allow generate-host-certificates to set a CA filename. These are required in libsecurity in order to prevent circular dependencies between libsecurity, libssl and libanyp.

Also contains some improvements to how configuration errors are displayed for these affected settings and some bugs fixed where the configured values were handled incorrectly.

6 years agoBug 4718: Support filling raw buffer space of shared SBufs (#64)
Christos Tsantilas [Fri, 6 Oct 2017 04:20:31 +0000 (07:20 +0300)] 
Bug 4718: Support filling raw buffer space of shared SBufs (#64)

SBuf::forceSize() requires exclusive SBuf ownership but its precursor
SBuf::rawSpace() method does not guarantee exclusivity. The pair of
calls may result in SBuf::forceSize() throwing for no good reason.

New SBuf API provides a new pair of raw buffer appending calls that
reduces the number of false negatives.

This change may alleviate bug 4718 symptoms but does not address its
core problem (which is still unconfirmed).

This is a Measurement Factory project.

6 years agoFix build errors with clang 3.8 (#63)
Amos Jeffries [Mon, 18 Sep 2017 11:30:25 +0000 (23:30 +1200)] 
Fix build errors with clang 3.8 (#63)

6 years agoUpdate Jakub Wilk's e-mail address in CONTRIBUTORS (#61)
Jakub Wilk [Sat, 16 Sep 2017 00:05:42 +0000 (02:05 +0200)] 
Update Jakub Wilk's e-mail address in CONTRIBUTORS (#61)

6 years agoBug 4616: store_client.cc:92: "mem" assertion (#50)
Eduard Bagdasaryan [Fri, 15 Sep 2017 14:13:01 +0000 (17:13 +0300)] 
Bug 4616: store_client.cc:92: "mem" assertion (#50)

This bug was probably caused by Bug 2833 feature/fix (1a210de).

The primary fix here is limited to clientReplyContext::processExpired():
Collapsed forwarding code must ensure StoreEntry::mem_obj existence. It
was missing for cache hits purged from (or never admitted into) the
memory cache. Most storeClientListAdd() callers either have similar code
or call storeCreateEntry() which also creates StoreEntry::mem_obj.

Also avoided clobbering known StoreEntry URIs/method in some cases. The
known effect of this change is fixed store.log URI and method fields
when a hit transaction did not match the stored entry exactly (e.g., a
HEAD hit for a GET cached entry), but this improvement may have even
more important consequences: The original method is used by possibly
still-running entry filling code (e.g., determining the end of the
incoming response, validating the entry length, finding vary markers,
etc.). Changing the method affects those actions, essentially corrupting
the entry state. The same argument may apply to store ID and log URI.

We even tried to make URIs/method constant, but that is impractical w/o
addressing an XXX in MemStore::get(), which is outside this issue scope.
To facilitate that future fix, the code now distinguishes these cases:

* createMemObject(void): Buggy callers that create a new memory object
  but do not know what URIs/method the hosting StoreEntry was based on.
  Once these callers are fixed, we can make the URIs/method constant.

* createMemObject(trio): Callers that create a new memory object with
  URIs/method that match the hosting StoreEntry.

* ensureMemObject(trio): Callers that are not sure whether StoreEntry
  has a memory object but have URIs/method to create one if needed.

6 years ago'capath=' ignored in Squid 4 and 5 (#58)
Christos Tsantilas [Mon, 4 Sep 2017 16:22:53 +0000 (19:22 +0300)] 
'capath=' ignored in Squid 4 and 5 (#58)

The capath= is ignored if cafile= is not set. This is affect tls_outgoing_options, cache_peer and *_port configuration parameters.

This is a Measurement Factory project

6 years agoBug 4767: SMP breaks IPv6 SNMP and cache manager queries
DrDaveD [Sun, 3 Sep 2017 04:17:08 +0000 (23:17 -0500)] 
Bug 4767: SMP breaks IPv6 SNMP and cache manager queries

6 years agoAdd checks for OpenSSL 1.1.0f API changes (#54)
Amos Jeffries [Wed, 30 Aug 2017 16:38:07 +0000 (04:38 +1200)] 
Add checks for OpenSSL 1.1.0f API changes (#54)

6 years agoBackwards compatibility for 3.5 external_acl_type formats (#52)
Amos Jeffries [Sun, 26 Nov 2017 13:41:58 +0000 (13:41 +0000)] 
Backwards compatibility for 3.5 external_acl_type formats (#52)

* Fix missing Squid-3 external_acl_type format codes compatibility

  The %<{...} and %>{...} may produce header, or header-element type codes.

* Fix incomplete compatibility for %EXT_TAG code

* Add config test for old external_acl_type format codes

6 years agoFix SSL certificate cache refresh and collision handling (#40)
Christos Tsantilas [Sun, 26 Nov 2017 12:01:36 +0000 (12:01 +0000)] 
Fix SSL certificate cache refresh and collision handling (#40)

SslBump was ignoring some origin server certificate changes or differences,
incorrectly using the previously cached fake certificate (mimicking
now-stale properties or properties of a slightly different certificate).
Also, Squid was not detecting key collisions inside certificate caches.

On-disk certificate cache fixes:

    Use the original certificate signature instead of the certificate
    subject as part of the key. Using signatures reduces certificate key
    collisions to deliberate attacks and woefully misconfigured origins,
    and makes any mishandled attacks a lot less dangerous because the
    attacking origin server certificate cannot by trusted by a properly
    configured Squid and cannot be used for encryption by an attacker.

    We have considered using certificate digests instead of signatures.
    Digests would further reduce the attack surface to copies of public
    certificates (as if the origin server was woefully misconfigured).
    However, unlike the origin-supplied signatures, digests require
    (expensive) computation in Squid, and implemented collision handling
    should make any signature-based attacks unappealing. Signatures won
    on performance grounds.

    Other key components remain the same: NotValidAfter, NotValidBefore,
    forced common name, non-default signing algorithm, and signing hash.

    Store the original server certificate in the cache (together with
    the generated certificate) for reliable key collision detection.

    Upon detecting key collisions, ignore and replace the existing cache
    entry with a freshly computed one. This change is required to
    prevent an attacker from tricking Squid into hitting a cached
    impersonating certificate when talking to a legitimate origin.

In-memory SSL context cache fixes:

    Use the original server certificate (in ASN.1 form) as a part of the
    cache key, to completely eliminate cache key collisions.

Other related improvements:

    Make the LruMap keys template parameters.
    Polish Ssl::CertificateDb class member names to match Squid coding
    style. Rename some functions parameters to better match their
    meaning.
    Replace Ssl::CertificateProperties::dbKey() with:
        Ssl::OnDiskCertificateDbKey() in ssl/gadgets.cc for
        on-disk key generation by the ssl_crtd helper;
        Ssl::InRamCertificateDbKey() in ssl/support.cc for
        in-memory binary keys generation by the SSL context memory cache.
    Optimization: Added Ssl::BIO_new_SBuf(SBuf*) for OpenSSL to write
    directly into SBuf objects.

This is a Measurement Factory project.

6 years agoDo not die silently when dying early. (#43)
Alex Rousskov [Tue, 22 Aug 2017 01:09:23 +0000 (19:09 -0600)] 
Do not die silently when dying early. (#43)

Report (to stderr) various problems (e.g., unhandled exceptions) that
may occur very early in Squid lifetime, before stderr-logging is forced
by SquidMain() and way before proper logging is configured by the first
_db_init() call.

To enable such early reporting, we started with a trivial change:
  -FILE *debug_log = NULL;
  +FILE *debug_log = stderr;
... but realized that debug_log may not be assigned early enough! The
resulting (larger) changes ensure that we can log (to stderr if
necessary) as soon as stderr itself is initialized. They also polish
related logging code, including localization of stderr checks and
elimination of double-closure during log rotation on Windows.

These reporting changes do not bypass or eliminate any failures.

6 years agoDo not output extra new lines at the end of debugs() lines (#44)
Alex Rousskov [Thu, 10 Aug 2017 14:42:25 +0000 (08:42 -0600)] 
Do not output extra new lines at the end of debugs() lines (#44)

Debugs() adds a new line automatically. Extra new lines complicate
parsing and viewing cache logs.

6 years agoDo not use AS_VAR_APPEND
Francesco Chemolli [Sun, 6 Aug 2017 07:24:54 +0000 (08:24 +0100)] 
Do not use AS_VAR_APPEND

AS_VAR_APPEND is not available on older versions of autoconf.
Do not use it.

6 years agoFixed, changed addresses in README. Made README look better on Github.
Alex Rousskov [Sun, 6 Aug 2017 00:20:40 +0000 (18:20 -0600)] 
Fixed, changed addresses in README. Made README look better on Github.

Why not add README.md? Not enough reasons to warrant info duplication:
Markdown is not particularly helpful for rendering a trivial list of
references, and Github already renders HTTP links appropriately.

Why not move README to README.md? Many tools and console humans still
look for README rather than README.md.

Why not use Markdown in README? Github does not render such markup.

TODO: Consider removing detailed distribution terms at the bottom
because "everybody" knows what GPLv2 basically means, and we already
tell the reader where to find the exact licensing terms.

6 years agoBug 4648: Squid ignores object revalidation for HTTPS scheme
Garri Djavadyan [Tue, 1 Aug 2017 00:03:18 +0000 (18:03 -0600)] 
Bug 4648: Squid ignores object revalidation for HTTPS scheme

Squid skips object revalidation for HTTPS scheme and, hence, does not
honor a reload_into_ims option (among other settings).

TODO: Add an httpLike() method or function to detect all HTTP-like
schemes instead of comparing with AnyP::PROTO_HTTP directly. There are
20+ candidates for similar bugs: git grep '[!=]= AnyP::PROTO_HTTP'.

6 years agoCleaned up net_db structures. Made Coverity happier? (#27)
Alex Rousskov [Sat, 22 Jul 2017 03:47:06 +0000 (21:47 -0600)] 
Cleaned up net_db structures. Made Coverity happier? (#27)

Fixes false positive by Coverity Scan. Issue 1415048 (RESOURCE_LEAK)?

No runtime testing.

6 years agoTLS: move X509_NAME_STACK_Pointer to Security::ServerOptions
Amos Jeffries [Mon, 10 Jul 2017 15:11:52 +0000 (03:11 +1200)] 
TLS: move X509_NAME_STACK_Pointer to Security::ServerOptions

This Pointer is only used by the Server port options.

No GnuTLS support added in this patch, just a straight shuffle
of the OpenSSL code.

6 years agoBug 1961 extra: Convert the URL::parse method API to take const URI strings
Amos Jeffries [Sun, 9 Jul 2017 08:16:33 +0000 (20:16 +1200)] 
Bug 1961 extra: Convert the URL::parse method API to take const URI strings

The input buffer is no longer truncated when overly long. All callers have
been checked that they handle the bool false return value in ways that do
not rely on that truncation.

Callers that were making non-const copies of buffers specifically for the
parsing stage are altered not to do so. This allows a few data copies and
allocations to be removed entirely, or delayed to remove from error handling
paths.

While checking all the callers of Http::FromUrl several places were found to
be using the "raw" URL string before the parsing and validation was done. The
simplest in src/mime.cc is already applied to v5 r15234. A more complicated
redesign in src/store_digest.cc is included here for review. One other marked
with an "XXX: polluting ..." note.

Also, added several TODO's to mark code where class URL needs to be used when
the parser is a bit more efficient.

Also, removed a leftover definition of already removed urlParse() function.

6 years agoFix ignored-qualifiers warning in class String
Amos Jeffries [Sat, 8 Jul 2017 19:28:42 +0000 (07:28 +1200)] 
Fix ignored-qualifiers warning in class String

6 years agoValidate mime icon URL before allocating store entries
Amos Jeffries [Sat, 8 Jul 2017 10:04:48 +0000 (22:04 +1200)] 
Validate mime icon URL before allocating store entries

6 years agoRemove unnecessary assert in NetDB
Amos Jeffries [Sat, 8 Jul 2017 10:00:57 +0000 (22:00 +1200)] 
Remove unnecessary assert in NetDB

6 years agoIgnore HTCP packets with invalid URI
Amos Jeffries [Sat, 8 Jul 2017 09:58:09 +0000 (21:58 +1200)] 
Ignore HTCP packets with invalid URI

6 years agoDocument the ssl::<cert_subject and ssl::<cert_issuer log formating codes (#83)
Christos Tsantilas [Fri, 24 Nov 2017 13:11:59 +0000 (15:11 +0200)] 
Document the ssl::<cert_subject and ssl::<cert_issuer log formating codes (#83)

This is a Measurement Factory project

6 years agoDocument lack of slow ACL support in more squid.conf directives. (#76)
Alex Rousskov [Fri, 27 Oct 2017 14:57:00 +0000 (08:57 -0600)] 
Document lack of slow ACL support in more squid.conf directives. (#76)

TODO: Documentation and API restrictions on slow ACL checks ought to be
generated via a (required) declaration like "ACL_SPEED: slow|fast".

6 years agoDocumentation updates (#62)
Amos Jeffries [Sun, 17 Sep 2017 05:32:17 +0000 (17:32 +1200)] 
Documentation updates (#62)

* Docs: RFC 8246 published

* Docs: Update email addresses

* Docs: updated manual text for log_db_daemon

* Docs: update man(8) page for security_fake_certverify

* Docs: convert negotiate_sspi_auth readme.txt to man(8) page

* Update error page .pot and .po for translate-toolkit 2.2.5

* Re-enable po4a man(8) page translation

* Docs: update .po and .pot files for man(8) translation

* Docs: update doxygen config

6 years agoFix typo in SPONSORS listing
Amos Jeffries [Thu, 6 Jul 2017 04:20:10 +0000 (16:20 +1200)] 
Fix typo in SPONSORS listing

The website is auto-generated from this file. It needs to have accurate whitespace.