]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
2 years agoMaintenance: Remove a stale sponsor URL (#1351)
Francesco Chemolli [Wed, 31 May 2023 17:13:51 +0000 (17:13 +0000)] 
Maintenance: Remove a stale sponsor URL (#1351)

SpinUp has ceased operations. Their URL is used by an unrelated entity.

2 years agoMaintenance: update release process script (#1340)
Amos Jeffries [Wed, 24 May 2023 03:57:07 +0000 (03:57 +0000)] 
Maintenance: update release process script (#1340)

* release notes no longer mention specific version since
  c0789db1f479206e43f96add370363127834757a. No more need to
  validate it is correct before release.

* web server has not been the direct release destination for
  many years. Remove mentions of $dst/changesets/

* web server references github repository for basic
  information. Do not push CONTRIBUTORS, COPYING, README,
  CREDITS and SPONSORS files to staging area.

* release notes no longer link to local ChangeLog file.
  No need to adjust the hyperlink.

2 years agoRemove obsolete caddr_t (#1362)
Amos Jeffries [Mon, 22 May 2023 14:32:31 +0000 (14:32 +0000)] 
Remove obsolete caddr_t (#1362)

2 years agoFix time_t type conflicts in libdebug (#1357)
Amos Jeffries [Mon, 22 May 2023 04:30:00 +0000 (04:30 +0000)] 
Fix time_t type conflicts in libdebug (#1357)

    error: cannot convert 'const long int*' to 'const time_t*'

On Windows, time_t is 64-bit, and long is not.

2 years agoBug 5148: Log %Ss of failed tunnels as TCP_TUNNEL (#1354)
Alex Rousskov [Sat, 20 May 2023 21:38:38 +0000 (21:38 +0000)] 
Bug 5148: Log %Ss of failed tunnels as TCP_TUNNEL (#1354)

    ERR_CONNECT_FAIL/errno=111 NONE_NONE/503 CONNECT

    TAG_NONE/503 0 CONNECT example.com:443 - HIER_NONE/- -

When Squid failed to open a TCP connection to an origin server (or
through a cache peer) while handling a CONNECT request, Squid logged %Ss
as NONE_NONE because TunnelStateData waited for a successful TCP
connection to update the log tag. That unnecessary wait (modeled after
the necessary HTTP status code wait) complicated code. Squid now logs
TCP_TUNNEL to indicate the request handling path chosen by Squid.

We already use the same "handling path" approach for most other request
status codes. For example, TCP_MISS does not mean the miss transaction
was successful. It only means that Squid satisfied the request using the
cache miss forwarding logic. Even the LOG_TCP_REFRESH_FAIL_ERR status
code does not imply that the error response was successfully forwarded
to the client; only that the request was satisfied on a particular
(albeit very detailed in this case!) handling path.

Apply the same logic to tunneling attempts blocked by miss_access. They
were also logged as NONE_NONE and are now logged as TCP_TUNNEL.

The actual outcome of a tunneling attempt can usually be determined
using %err_code/%err_detail and %>Hs logformat codes.

2 years agoFix fatalf() undefined for environments without syslog (#1356)
Amos Jeffries [Sat, 20 May 2023 05:23:23 +0000 (05:23 +0000)] 
Fix fatalf() undefined for environments without syslog (#1356)

src/debug/debug.cc:1087
error: 'fatalf' was not declared in this scope

2 years agoDo not erase aborted StoreMap entries that are still being read (#1344)
Alex Rousskov [Wed, 17 May 2023 19:33:51 +0000 (19:33 +0000)] 
Do not erase aborted StoreMap entries that are still being read (#1344)

The old `!s.lock.readers` precondition for calling freeChain() in
StoreMap::abortWriting() was not broad enough: It covered "old" readers
that have incremented ReadWriteLock::readers already while missing those
lockShared() callers that have fully qualified for becoming a reader but
have not incremented the `readers` counter yet. A correct test is now
implemented by ReadWriteLock::stopAppendingAndRestoreExclusive().

This code was broken since appending mode was introduced in 2013 commit
ce49546. Evidently, the mishandled race condition is short-lived enough
and abortWriting() calls are rare enough, that there are no (known)
relevant bug reports. This bug was accidentally discovered while reading
the code to explain another SMP bug.

Controller::markedForDeletionAndAbandoned() similarly misjudges
readers(), but that bug does not lead to serious problems, and we would
like to find a fix that identifies such entries without false positives
(that looking at ReadWriteLock::readLevel instead of readers creates).

Also polished Ipc::StoreMap::abortWriting() debugging a little.

2 years agoDo not leak Security::CertErrors created in X509_verify_cert() (#1346)
Alex Rousskov [Wed, 10 May 2023 20:45:27 +0000 (20:45 +0000)] 
Do not leak Security::CertErrors created in X509_verify_cert() (#1346)

ACLFilledChecklist was using a raw C pointer for handling cbdata-managed
Security::CertErrors. Some sslErrors users knew about hidden cbdata
requirements, some did not, resulting in inconsistent locking/unlocking
and associated memory leaks. Upgrading ACLFilledChecklist::sslErrors to
smart CbcPointer fixes those leaks (and simplifies code).

2 years ago6.0.2 SQUID_6_0_2
squidadm [Sun, 30 Apr 2023 21:33:35 +0000 (09:33 +1200)] 
6.0.2

* Prepare ChangeLog for v6.0.2 (#1326)

* 6.0.2

---------

Co-authored-by: Francesco Chemolli <5175948+kinkie@users.noreply.github.com>
2 years agoFix default build with libgnutls but absent GnuTLS headers (#1332)
Francesco Chemolli [Thu, 27 Apr 2023 16:42:02 +0000 (16:42 +0000)] 
Fix default build with libgnutls but absent GnuTLS headers (#1332)

Ensure that when libgnutls is found but any of the required GnuTLS
headers cannot be used, GnuTLS support is not enabled by default and an
explicit request for GnuTLS support is fatally rejected during
./configure. Otherwise, the build fails later anyway, during "make".

The problem was exposed by a mingw-cross build.

2 years agoDocs: Update 6.0.1 bug reference (#1328)
Amos Jeffries [Tue, 25 Apr 2023 20:58:51 +0000 (20:58 +0000)] 
Docs: Update 6.0.1 bug reference (#1328)

2 years agoPrepare ChangeLog for v5.9 (#1327)
Francesco Chemolli [Tue, 25 Apr 2023 07:59:45 +0000 (07:59 +0000)] 
Prepare ChangeLog for v5.9 (#1327)

2 years agoImprove reply_body_max_size matching accuracy (#1324)
Alex Rousskov [Sat, 22 Apr 2023 16:45:07 +0000 (16:45 +0000)] 
Improve reply_body_max_size matching accuracy (#1324)

    HttpReply.cc(553) receivedBodyTooLarge: -4096 >? -1

ClientHttpRequest::out.offset is documented to only count body bytes,
and that is what receivedBodyTooLarge() needs. We should not subtract
the guessed header size, occasionally violating reply_body_max_size
configuration and often leading to a confusing negative body size in
receivedBodyTooLarge() debugging.

Possibly broken since 2003 commit b51aec6: out.offset was not documented
back then, but, AFAICT, it was already used just for the body bytes.

2 years agoFix GCC v13 build [-Warray-bounds] (#1318)
Alex Rousskov [Sun, 2 Apr 2023 07:42:10 +0000 (07:42 +0000)] 
Fix GCC v13 build [-Warray-bounds] (#1318)

    src/ipc/mem/FlexibleArray.h:34:52: error: array subscript -1 is
    below array bounds of 'int [1]' [-Werror=array-bounds]

We suspect this warning is a GCC v13 regression bug because the callers
marked as problematic by GCC (e.g., Rock::LoadingEntry::LoadingEntry) do
not use "array subscript -1", and the Ipc::StoreMapItems::at() operator
they use even asserts that the subscript is not negative. It might be
GCC bug 107699: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107699

This change replaces the fake one-item array hack with a properly
aligned byte (still used as the "start of the real array" marker).

Also removed some unused and problematic code (instead of polishing it).

2 years agoImprove detection of lonely StoreEntry clients (#1312)
Alex Rousskov [Sat, 25 Mar 2023 03:40:27 +0000 (03:40 +0000)] 
Improve detection of lonely StoreEntry clients (#1312)

The first storeClientType() call still sees zero nclients because
storeClientListAdd() creates a store_client object (which triggers
storeClientType()) first and only then adds it to the list of clients
(which increases nclients). This off-by-one bug was introduced in commit
528b2c6 that reordered nclients increase and the storeClientType() call.

The bug could lead to excessive disk I/O in some environments because
Squid could see more STORE_DISK_CLIENT store_client objects, and those
may trigger startSwapin() in store_client::doCopy(). However, the exact
effects of this bug/fix are difficult to predict because startSwapin()
may be separated by async calls and is guarded by additional conditions.

A full fix requires refactoring the caller, but there are so many
problems associated with storeClientType() and startSwapin() calls that
such refactoring deserves a dedicated effort.

Technically, this "first" client may be 10th client this StoreEntry has
seen, but it is the first one among the _current_ entry clients.

2 years agonegotiate_kerberos_auth: Fix build [-Wunused-but-set-variable] (#1294)
gkinkie@gmail.com [Thu, 2 Mar 2023 23:50:10 +0000 (23:50 +0000)] 
negotiate_kerberos_auth: Fix build [-Wunused-but-set-variable] (#1294)

Unused variable discovered by clang v15.

2 years agoESI: Fix build [-Wdeprecated-declarations] (#1295)
gkinkie@gmail.com [Sat, 4 Mar 2023 01:46:20 +0000 (01:46 +0000)] 
ESI: Fix build [-Wdeprecated-declarations] (#1295)

Replaced deprecated htmlDefaultSAXHandlerInit() libxml2 initialization
call with xmlInitParser().

2 years agoFix build with clang v15 [-Wunused-but-set-variable] (#1296)
gkinkie@gmail.com [Sat, 4 Mar 2023 04:53:55 +0000 (04:53 +0000)] 
Fix build with clang v15 [-Wunused-but-set-variable] (#1296)

Remove unused variable in neigbours.cc:neighborsUdpPing

2 years agoFix build with clang v15.0.6 [-Warray-parameter] (#1297)
gkinkie@gmail.com [Sat, 4 Mar 2023 16:08:26 +0000 (16:08 +0000)] 
Fix build with clang v15.0.6 [-Warray-parameter] (#1297)

Adapt a mismatching function signature in stub_libip.cc to the
corresponding declaration.

2 years agoFix several broken or missing copyright statements (#1300)
Amos Jeffries [Mon, 6 Mar 2023 00:05:19 +0000 (00:05 +0000)] 
Fix several broken or missing copyright statements (#1300)

2 years agobootstrap.sh: Polish output (#1301)
Amos Jeffries [Wed, 8 Mar 2023 12:52:53 +0000 (12:52 +0000)] 
bootstrap.sh: Polish output (#1301)

We use bootstrap.sh a lot in maintenance scripts but do not
need to see its output on success.

 * Fix some incorrect uses of stderr and stdout such that
   all (and only) errors appear on stderr

 * Polish the message display when an error does occur
    detecting one of the tools.

2 years agoCI: Remove irrelevant branch from v6 GitHub Actions config (#1311)
Alex Rousskov [Fri, 24 Mar 2023 23:58:42 +0000 (19:58 -0400)] 
CI: Remove irrelevant branch from v6 GitHub Actions config (#1311)

The original GitHub Actions configuration (see commit 2ed8cc4)
incorrectly assumed that GitHub will use that configuration (stored in
the master branch) for testing _all_ repository branches. In reality,
GitHub uses configuration from the being-tested branch. Thus, we do not
need to (and, hence, should not) list any branches in the X branch
configuration, with the exception of the X branch itself and the "auto"
branch where all PRs (including all X-targeting PRs) are staged for the
final "as if merged" testing.

----

Cherry-picked master/v7 commit 58ecf6052ef258aaafd6d4c810a0757299113e9b
and then replaced "master" with "v6" because "this branch" is v6.

2 years ago6.0.1 SQUID_6_0_1
Amos Jeffries [Mon, 27 Feb 2023 00:33:45 +0000 (00:33 +0000)] 
6.0.1

2 years agoMaintenance: Updated CONTRIBUTORS (#1289)
Alex Rousskov [Mon, 27 Feb 2023 16:54:10 +0000 (16:54 +0000)] 
Maintenance: Updated CONTRIBUTORS (#1289)

This change is a reference point for automated CONTRIBUTORS updates.

2 years agoTranslation: Update Georgian translation (#1279)
NorwayFun [Sat, 25 Feb 2023 14:51:58 +0000 (14:51 +0000)] 
Translation: Update Georgian translation (#1279)

2 years agoMaintenance: improve release notes automation (#1264)
Amos Jeffries [Mon, 20 Feb 2023 07:05:13 +0000 (07:05 +0000)] 
Maintenance: improve release notes automation (#1264)

* auto-update the text version numbers
* add template for automatic series creation

2 years agoRemoved unused StoreIOState::STFNCB callbacks (#1283)
Alex Rousskov [Mon, 20 Feb 2023 03:07:45 +0000 (03:07 +0000)] 
Removed unused StoreIOState::STFNCB callbacks (#1283)

Unused since before 2016 commit abf396e that discovered the problem.

2 years agoRemoved unused storeClientCopyPending() (#1282)
Alex Rousskov [Mon, 20 Feb 2023 00:06:21 +0000 (00:06 +0000)] 
Removed unused storeClientCopyPending() (#1282)

Unused since 2002 commit edce4d9.

2 years agoEnsure StoreEntry presence during store_client lifetime (#1281)
Alex Rousskov [Sun, 19 Feb 2023 00:23:31 +0000 (00:23 +0000)] 
Ensure StoreEntry presence during store_client lifetime (#1281)

Most likely, all store_client users already lock their StoreEntry
objects, so this change is unlikely to affect any current use cases.
However, objects like store_client that store StoreEntry objects for
long-term/asynchronous reuse should lock their entries rather than rely
on others to do that for them. Being able to rely on StoreEntry locking
also clarifies existing logic in several store_client methods.

2 years agoSource Format Enforcement (#1280)
Alex Rousskov [Sat, 18 Feb 2023 18:12:17 +0000 (18:12 +0000)] 
Source Format Enforcement (#1280)

    NOTICE: File tools/squidclient/squidclient.cc changed: by astyle

2 years agoCI: Disable optimizations in "minimal" build tests (#1278)
Alex Rousskov [Tue, 14 Feb 2023 21:31:11 +0000 (21:31 +0000)] 
CI: Disable optimizations in "minimal" build tests (#1278)

Our "minimal" layer tests had to stop disabling optimizations in 2019
commit 4f3c41b due to problems specific to GCC v9 (v9.1 or earlier). GCC
v9.4 (and later) appear to work OK (at least on Ubuntu 22.04), so let's
try to resume testing --disable-optimizations ./configure option.

2 years agoEnable compiler checks for printf-like SBuf methods (#1270)
Eduard Bagdasaryan [Tue, 14 Feb 2023 16:25:32 +0000 (16:25 +0000)] 
Enable compiler checks for printf-like SBuf methods (#1270)

After commit 0f17e25, these two are the only known printf()-like
functions not already covered by these compiler checks. Some helper
debugging hacks do not have PRINTF_FORMAT_ARG2 or similar attributes,
but they are covered because their `__GNUC__` variants use standard
fprintf().

2 years agoFix --disable-optimizations build: Undefined RetryGapUsec (#1276)
Alex Rousskov [Tue, 14 Feb 2023 14:23:33 +0000 (14:23 +0000)] 
Fix --disable-optimizations build: Undefined RetryGapUsec (#1276)

Since inception (2017 commit e99fa72), FileOpeningConfig::RetryGapUsec
was declared but not defined in any translation unit (a bug). The build
probably "worked" because compilers simply inlined the value of the
constant data member when calling xusleep(). Commit 5eee0e4 removed code
that passed RetryGapUsec to that external "C" function. Now, the same
member is passed to a heavily-inlined and convoluted STL code, and at
least some compilers (e.g., GCC v10-v12 on Ubuntu 22.04) stopped
inlining RetryGapUsec unless optimization is enabled. Our CI tests
passed because we do not test --disable-optimizations builds (yet).

We do not need FileOpeningConfig::RetryGapUsec to be static, breaking
builds, requiring extra code, and triggering questions. We do not even
need it to be constant, but removing "const" is an arguably out-of-scope
change, as is improving its type.

File::InvalidHandle is missing a definition as well, except on Windows,
but we are leaving that code "as is" for now, until we can test whether
Windows is OK with removing that "static" keyword.

2 years agoCI: Extend GitHub Actions build-tests to doc/release-notes/ (#1275)
Alex Rousskov [Tue, 14 Feb 2023 10:03:34 +0000 (10:03 +0000)] 
CI: Extend GitHub Actions build-tests to doc/release-notes/ (#1275)

"make dist[check]" does nothing in doc/release-notes unless a linuxdoc
tool has been detected during ./configure, missing errors like this:

    make[6]: Entering directory /squid/doc/release-notes
    linuxdoc -B html -T 2 --split=0 release-6.sgml
    Processing file release-6.sgml
    onsgmls: ...E: end tag for element "E" which is not open

2 years agoPlace more msgs under cache_log_message control, downgrade some (#1273)
Alex Rousskov [Tue, 14 Feb 2023 00:00:20 +0000 (00:00 +0000)] 
Place more msgs under cache_log_message control, downgrade some (#1273)

Also support cache_log_message-controlled messages in ::Config-unaware
libraries (e.g., libip) used by tools (e.g., cachemgr.cgi).

Restricting the very first (i.e. "depth 0") "Processing Configuration
File" message does not work during startup (before that file is parsed),
and does not work during reconfiguration (because the old configuration
is reset shortly before logging that line). Future reconfiguration
support improvements may fix the reset problem. Restrictions do work as
expected for included files (i.e. positive "depth" levels).

Restricting "BCP 177 violation" WARNINGs does not work because the
warnings are printed _before_ Squid configuration is parsed. Future
initialization improvements may fix this.

Also downgraded the importance of a few (re)configuration
progress-reporting messages from level 1 to level 2.

2 years agoRemove unused clientReplyContext::holdingBuffer (#1272)
Alex Rousskov [Mon, 13 Feb 2023 20:38:38 +0000 (20:38 +0000)] 
Remove unused clientReplyContext::holdingBuffer (#1272)

The data member has been unused since inception in 2003 commit 4993f57.
The underlying dumb StoreIOBuffer class does not lock/copy anything.

2 years agoFix typo in release notes (#1274)
Amos Jeffries [Mon, 13 Feb 2023 14:31:03 +0000 (14:31 +0000)] 
Fix typo in release notes (#1274)

2 years agoRemove unused Ftp::Gateway::printfReplyBody() (#1271)
Eduard Bagdasaryan [Mon, 13 Feb 2023 02:57:14 +0000 (02:57 +0000)] 
Remove unused Ftp::Gateway::printfReplyBody() (#1271)

Ftp::Gateway::printfReplyBody() has been unused since 0477a07.

2 years agoRun cache_peer probes without transaction context (#1256)
Eduard Bagdasaryan [Fri, 10 Feb 2023 15:44:18 +0000 (15:44 +0000)] 
Run cache_peer probes without transaction context (#1256)

Even when triggered by a master transaction, these background probes
should not be associated with it. That transaction just wants to know
whether the neighbor is "up" right now. The transaction does not wait
(and is not aware of) the background probe its question may or may not
have triggered.

2 years agoCleanup: remove xusleep() hacks (#613)
Amos Jeffries [Fri, 10 Feb 2023 12:25:07 +0000 (12:25 +0000)] 
Cleanup: remove xusleep() hacks (#613)

usleep() has been obsolete for a long time. C++11 provides better and
portable waiting mechanism we can use easily instead of these hacks
trying to replicate and extend usleep().

2 years agoMaintenance: Add ACL key change tests (#1269)
Eduard Bagdasaryan [Tue, 7 Feb 2023 20:22:54 +0000 (20:22 +0000)] 
Maintenance: Add ACL key change tests (#1269)

Squid bans key changes in req_header/rep_header and note ACLs
since 4a3b853.

2 years agoPrep for 6.0.1 (#1263)
Amos Jeffries [Mon, 6 Feb 2023 23:06:48 +0000 (23:06 +0000)] 
Prep for 6.0.1 (#1263)

2 years agoDocumentation: Polish "refresh_pattern percent" description (#1260)
Amos Jeffries [Sun, 5 Feb 2023 21:00:38 +0000 (21:00 +0000)] 
Documentation: Polish "refresh_pattern percent" description (#1260)

The original text contained a "last modification age" typo and was
misinterpreted by some admins as if Squid applied the configured percent
to the current object age.

The text also did not make it clear that the percent-based heuristic is
effectively only applied to responses with a Last-Modified header (in
addition to the usual "without an explicit expiry time" precondition).

2 years agoAdd memFreeRigid to mem/libminimal.la (#1258)
gkinkie@gmail.com [Sun, 5 Feb 2023 10:08:41 +0000 (10:08 +0000)] 
Add memFreeRigid to mem/libminimal.la (#1258)

Complement the already-included memAllocRigid,
to better support unit tests

2 years agoUpdate ChangeLog for latest merges (#1257)
Amos Jeffries [Sat, 4 Feb 2023 08:43:30 +0000 (08:43 +0000)] 
Update ChangeLog for latest merges (#1257)

2 years agoFix stub for ip/libip.la (#1254)
Amos Jeffries [Fri, 3 Feb 2023 14:07:53 +0000 (14:07 +0000)] 
Fix stub for ip/libip.la (#1254)

Use to build disk I/O tests which do not need IP address
operations. This also ensures bitrot does not reappear.

2 years agocachemgr.cgi: Drop cache_object protocol support (#1252)
Eduard Bagdasaryan [Thu, 2 Feb 2023 22:42:48 +0000 (22:42 +0000)] 
cachemgr.cgi: Drop cache_object protocol support (#1252)

2 years agoV6 release prep (#1245)
Amos Jeffries [Thu, 2 Feb 2023 19:47:05 +0000 (19:47 +0000)] 
V6 release prep (#1245)

2 years agosquidclient: Drop cache_object protocol support (#1251)
Eduard Bagdasaryan [Thu, 2 Feb 2023 12:25:10 +0000 (12:25 +0000)] 
squidclient: Drop cache_object protocol support (#1251)

Use `http` URL scheme for `mgr:command` cache manager requests instead.

Also fixed a bug: When `mgr:command` was used together with a `-w X`
command-line option, squidclient sent that proxy authentication password
`X` in the `cache_object` URL instead of sending the `Y` password from
the `-W Y` option (or no password at all if no `-W` option was given).
If no Authorization header had been sent, Squid's cachemgr_passwd
honored the `-w X` password sent in the cache_object URL.  If
Authorization header had been sent, Squid's cachemgr_passwd honored the
corresponding `-W Y` password, ignoring any password sent in the
cache_object URL.

Now, squidclient uses Authorization HTTP header for sending cache
manager authentication credentials with `mgr:command` requests. Those
credentials are taken either from the `-U` and `-W` command-line options
(if `mgr:command` parameter lacks an embedded password) or from the `-U`
command line option and from the `mgr:command@password` parameter
(otherwise).

squidclient now sends Proxy authentication credentials if and only if
`-u` and `-w` command line options are given. These credentials may be
required to authenticate with the proxy, but they do not affect cache
manager authentication driven by the cachemgr_passwd directive.

Also prohibit specifying a command-line option with a password (`-w` or
`-W`) without specifying the corresponding user name (`-u` or `-U`).
Prior to this change, squidclient did not send the Proxy-Authorization
or Authorization header if the corresponding user name was missing but
did not complain about the problem.

2 years agoRemove broken -sha1 option from server_cert_fingerprint (#1249)
Eduard Bagdasaryan [Wed, 1 Feb 2023 19:25:10 +0000 (19:25 +0000)] 
Remove broken -sha1 option from server_cert_fingerprint (#1249)

server_cert_fingerprint support for the sha1 parameter has been broken
for years, probably since its inception (2012 commit 42d3334). The bug
was known since at least 2018 when it was mentioned in Bug 4847
discussion.  The single-dash syntax violates the double-dash pattern
used for other --long ACL options. If fixed, using the option would not
change Squid behavior because SHA1 is the default (and the only
supported) fingerprinting algorithm.

The option was meant to allow admins to be explicit about that default
in case it changes in the future, but implementation bugs derailed that
plan. The fix is not straightforward, and we should be focusing on more
important things.

2 years agoImprove error message storage in Dns::LookupDetails (#1241)
Francesco Chemolli [Sun, 29 Jan 2023 21:59:41 +0000 (21:59 +0000)] 
Improve error message storage in Dns::LookupDetails (#1241)

Removed one more deprecated String usage and optimized handling of a
common "no error, no lookup" case as well as portions of the "no-error
lookup" code paths. Further optimizations need similar ipcache_entry and
fqdncache_entry error storage changes (at least).

Co-authored-by: Alex Rousskov <rousskov@measurement-factory.com>
2 years agoFix logging of responses truncated by premature EOF (#1244)
Eduard Bagdasaryan [Sat, 28 Jan 2023 09:36:56 +0000 (09:36 +0000)] 
Fix logging of responses truncated by premature EOF (#1244)

When a transaction failed due to a premature EOF while receiving an HTTP
response, %Ss logformat code was missing the ABORTED suffix (e.g.,
logging TCP_MISS instead of TCP_MISS_ABORTED). When premature EOF
truncated the header, the default "squid" access log format contained a
502 sent status code (%>Hs), hinting at the problem. When the body was
truncated, even that weak hint was usually absent because the actual
status code returned by the server (usually 200) was usually logged.

Similarly, %err_code/%err_detail logformat codes for HTTP responses with
truncated by a premature EOF bodies carried no information. Now they
expand to ERR_READ_ERROR/SRV_PREMATURE_EOF in those cases.

No changes to requests truncated by Squid-server read timeouts. They
were and are still logged with TIMEDOUT %Ss suffix and
ERR_READ_TIMEOUT/WITH_SERVER %err_code/%err_detail.

Also adjusted WHOIS to mark zero-length responses with
ERR_ZERO_SIZE_OBJECT instead of default ERR_READ_ERROR. This affects
forwarded WHOIS transactions and AS number queries generated during
(re)configuration.

2 years agoReduce code duplication in ACLCertificateData::parse() (#1242)
Eduard Bagdasaryan [Sat, 28 Jan 2023 05:34:27 +0000 (05:34 +0000)] 
Reduce code duplication in ACLCertificateData::parse() (#1242)

ACLs ca_cert and user_cert already prohibit key changes. And
server_cert_fingerprint ACL only supports one option name spelling, so,
while "-sha1" is not, technically, a "key", it still cannot be
"changed". Adjust SetAclKey() (added in recent commit 4a3b853) and reuse
it to implement those existing "key change" checks.

2 years agoMerge MemImplementingAllocator and Mem::Allocator (#1211)
Amos Jeffries [Sat, 28 Jan 2023 01:40:22 +0000 (01:40 +0000)] 
Merge MemImplementingAllocator and Mem::Allocator (#1211)

2 years agoConvert MimeEntry to use RegexPattern API (#1233)
Amos Jeffries [Fri, 27 Jan 2023 20:04:05 +0000 (20:04 +0000)] 
Convert MimeEntry to use RegexPattern API (#1233)

Restore 318f2c8d3418a73946ae947d84f7696a381628b1
with modifications for current RegexPattern API.

2 years agoFix build with clang v15.0.6 [-Wunused-but-set-variable] (#1247)
gkinkie@gmail.com [Fri, 27 Jan 2023 14:43:41 +0000 (14:43 +0000)] 
Fix build with clang v15.0.6 [-Wunused-but-set-variable] (#1247)

clang v15.0.6 distributed with Fedora Rawhide complains about a variable
that is updated but never used:

    net_db.cc:230:9: error: variable 'removed' set but not used
    [-Werror,-Wunused-but-set-variable]`

2 years agoFix build with clang v15.0.6 [-Wdeprecated-non-prototype] (#1246)
gkinkie@gmail.com [Wed, 25 Jan 2023 15:00:42 +0000 (15:00 +0000)] 
Fix build with clang v15.0.6 [-Wdeprecated-non-prototype] (#1246)

clang v15.0.6 distributed with Fedora Rawhide complains about function
definitions using K&R style:

    lib/snmplib/mib.c:229:1: error: a function definition without a
    prototype is deprecated in all versions of C and is not supported in
    C2x [-Werror,-Wdeprecated-non-prototype]

2 years agoSource Format Enforcement (#1234)
squidadm [Sun, 22 Jan 2023 02:14:40 +0000 (02:14 +0000)] 
Source Format Enforcement (#1234)

2 years agoRemoved tcp-banger* and pconn-banger tools (#1236)
Amos Jeffries [Tue, 17 Jan 2023 02:19:01 +0000 (02:19 +0000)] 
Removed tcp-banger* and pconn-banger tools (#1236)

We do not have enough resources/demand for maintaining these tools, they
do require maintenance, and there are better tools available.

* tcp-banger2 is not built by default and probably could not be built at
  all since at least 2006 commit 5679212.

* tcp-banger3 lacked build rules since inception (1998 commit 2742510)
  and probably could not be built manually (by mimicking tcp-banger2
  build commands) without warnings since 2002 commit 88d8a2a.

* pconn-banger lacked build rules since inception (1997 commit eb5f55b)
  and probably could not be built manually since at least 2007 commit
  cc192b5.

* tcp-banger.pl has portability and code quality issues; its basic
  functionality is supported by squidclient, wget, curl, and others.

Co-authored-by: Alex Rousskov <rousskov@measurement-factory.com>
2 years agoMaintenance: Check for expected squid-conf-tests notifications (#1231)
Alex Rousskov [Mon, 16 Jan 2023 23:24:41 +0000 (23:24 +0000)] 
Maintenance: Check for expected squid-conf-tests notifications (#1231)

Sometimes, Squid must accept a configuration file while also logging a
WARNING or even an ERROR message. The new "expect-message" test case
instruction tells test-suite/test-squid-conf.sh to check for a given
expected message while still expecting configuration acceptance.

Two test cases (mgr_passwd.conf and time_units.conf) were enhanced. We
plan to use this feature in future tests already under development.

2 years agoMaintenance: Do not hide squid-conf-tests errors (#1227)
Alex Rousskov [Mon, 16 Jan 2023 20:28:49 +0000 (20:28 +0000)] 
Maintenance: Do not hide squid-conf-tests errors (#1227)

These "make installcheck" failures were ignored since commit 5992004.

2 years agoMove Namespace::Foo printing operators to Namespace (#1218)
Alex Rousskov [Sat, 14 Jan 2023 18:29:18 +0000 (18:29 +0000)] 
Move Namespace::Foo printing operators to Namespace (#1218)

... where C++ Argument-Dependent Lookup (ADL) can find them.

These specific printing operators did not encounter build problems yet,
but they were misplaced. See commit XXX for rationale and details.

Also removed unimplemented Mgr::ActionParams printing operator.

Also removed excessive "Namespace::" prefixes inside Namespace in
several printing operators declarations that were already properly
placed in their argument's namespaces (e.g., Ipc::ReadWriteLock).

No functionality changes expected.

2 years agoBug 5256: Intercepting port fails to accept (#1238)
Alex Rousskov [Fri, 13 Jan 2023 22:33:35 +0000 (22:33 +0000)] 
Bug 5256: Intercepting port fails to accept (#1238)

    ERROR: NF getsockopt(ORIGINAL_DST) failed on ... Bad file descriptor
    ERROR: NAT lookup failed to locate original IPs on ...

Ip::Interceptor.LookupNat() needs an open Connection, but commit 7185c9e
supplied a half-baked details object, resulting in ERRORs (showing a
closed connection -- no FD... field) for every otherwise successful
accept(2) attempt on an intercepting port.

Refactored oldAccept() to use exceptions for error handling and false
return result for no-error-but-no-connection cases (Comm::NOMESSAGE).
This refactoring allows us to centralize connection closing code instead
of chasing individual COMM_ERROR and NOMESSAGE cases while still missing
connection closure (if a function called by oldAccept() throws). With
connection closure handled, we can now open the details Connection
earlier, as we have done before commit 7185c9e, meeting current
LookupNat() and other/future code expectations.

Positive side effects of this fix include elimination of the following
old error reporting problems that left admins puzzled why Squid is not
handling new connections with no error messages in non-debugging
cache.log (and with the socket listening queue growing).

* Silent lack of accept() after an ENFILE or EMFILE failure.
* Silent lack of accept() if some function used by oldAccept() throws.
* Silent at level-0 lack of accept() after logging a level-1 ERROR. This
  problem was specific to ALL,0 and similar (rare) configurations.

2 years agoMaintenance: Consistent use of C++11 "override" specifier (#1224)
Alex Rousskov [Mon, 9 Jan 2023 21:12:02 +0000 (21:12 +0000)] 
Maintenance: Consistent use of C++11 "override" specifier (#1224)

Start following CppCoreGuidelines recommendation C.128: Virtual
functions should specify exactly one of virtual, override, or final.

Used clang-tidy modernize-use-override check to mark overridden methods.
Clang-tidy uses clang AST, so we can only modernize code that clang can
see, but we can enable enough ./configure options for clang to reach
most (possibly all) relevant classes in a single build.

Manual gradual conversion of modified (for other reasons) method
declarations is impractical because some compilers complain when a class
uses an inconsistent _mix_ of virtual and override declarations:

    warning: 'toCbdata' overrides a member function but is not marked
    'override' [-Winconsistent-missing-override]

### cbdata changes

The following manual changes avoid -Winconsistent-missing-override
warnings. Doing these separately, either before or after applying
modernize-use-override, would trigger those warnings.

* Replaced CbdataParent-CBDATA_CLASS with CbdataParent-CBDATA_CHILD
  class inheritance sequences. This fix does not really change anything
  except for making toCbdata() specifiers consistent.

* Replaced CbdataParent-CBDATA_CLASS-CBDATA_CHILD with
  CbdataParent-CBDATA_INTERMEDIATE-CBDATA_CHILD class inheritance
  sequences. This fix removes unused new/delete operators in
  intermediate classes (and associated unused static memory pools) and
  makes toCbdata() specifiers consistent. This fix was difficult to get
  right because of the old design problem discussed below.

While working on the second bullet changes, we first tried to simply
drop the intermediate CBDATA_CLASS sequence element because it should
never be needed/used in class hierarchies ending with CBDATA_CHILD.
Fortunately, CI tests discovered that dropping CBDATA_CLASS converts an
old design problem into runtime bugs: Those intermediate class
constructors (e.g., Mgr::StoreToCommWriter) actually call toCbdata()
when creating connection closure callbacks and such!

During intermediate constructor execution, the class virtual table does
not yet point to toCbdata() defined by CBDATA_CHILD. If we simply remove
CBDATA_CLASS, then, during that intermediate constructor execution, the
virtual table would still point to pure CbdataParent::toCbdata(). Those
intermediate constructors would then crash Squid:

    FATAL: Dying from an exception handling failure;
    exception: [no active exception]

    in OnTerminate () at main.cc:1310
    in std::terminate() () from libstdc++.so.6
    in __cxa_pure_virtual () from libstdc++.so.6
    in CbcPointer<Mgr::StoreToCommWriter>::CbcPointer at CbcPointer.h:94
    in Mgr::StoreToCommWriter::StoreToCommWriter at ...oCommWriter.cc:29

We now use lighter CBDATA_INTERMEDIATE() instead of intermediate
CBDATA_CLASS. The resulting code is as risky as it used to be, but at
least we are marking this (old) design problem (in some cases).

We rejected the idea of defining CbdataParent::toCbdata() instead. It
would work fine for linear class inheritance where "this" does not
change -- in those simple class hierarchies, we do not need toCbdata()!
However, such a change would make any constructor-time bugs in multiple
inheritance hierarchies much more difficult to find because the faulty
constructor will work instead of triggering the above FATAL error. The
crashes would happen later, when wrong cbdata pointer is used. While
CBDATA_INTERMEDIATE() cannot fix this design problem, it does not make
it _worse_, so we prefer that solution.

2 years agoWarn about some bad from-helper annotations (#1221)
Alex Rousskov [Sun, 8 Jan 2023 12:43:48 +0000 (12:43 +0000)] 
Warn about some bad from-helper annotations (#1221)

From-helper annotations may belong to one or more of the following
(partially overlapping) categories:

* A1: Annotations with a name ending with an underscore. Those
  annotations are reserved for admin use. Example: "category_".

* A2: Annotations that this Squid version knows about and treats
  specially. Example: "clt_conn_tag".

* B1: Annotations that this Squid version does not know about at all.
  Future Squids may start using them specially. Example: "detail".

* B2: Annotations unused by this Squid build. Example: Squid
  ./configured with --disable-auth does not use "user" and "password"
  annotations received from an external ACL helper.

* B3: Annotations incompatible with the current helper response
  type/kind. Example: Digest authentication code does not use "ha1"
  annotation in ERR responses received from digest authentication
  helpers.

* B4: Annotations with repeated names (the first of them will be used).
  Example: "user" in OK replies from negotiate authentication helpers.

Warn about received helper annotations in the B1 category.

It is possible to also warn about B2 and B3 annotations, but several
draft implementations imply that such an improvement requires complex
code changes that may also increase Squid code maintenance overheads.

Warning about B4 annotations is not that difficult, but we must decide:

* Whether custom repeated annotation are actually bad (and should be
  reported or even ignored).

* Whether Squid-recognized repeated annotations are bad enough to
  warrant the decreased performance and increased code complexity that
  reporting them would require. In other words, do we want to penalize
  good helpers that do _not_ send any repeated Squid-recognized
  annotations (except, perhaps, "message") to warn about bad helpers
  that do?

2 years agoRemove bundled GnuRegex library (#1229)
gkinkie@gmail.com [Sun, 8 Jan 2023 00:10:31 +0000 (00:10 +0000)] 
Remove bundled GnuRegex library (#1229)

Modern operating systems provide a functioning regex
library, so we don't need to carry one anymore.

2 years agoFix ./configure --enable-poll and --disable-poll (#1228)
Alex Rousskov [Sat, 7 Jan 2023 00:27:12 +0000 (00:27 +0000)] 
Fix ./configure --enable-poll and --disable-poll (#1228)

    ./configure: line 42685: xyes: command not found
    ./configure: line 42685: xno: command not found

Since commit a1c2236, these options triggered errors messages above, and
--enable-poll did not affect syscall selection for the I/O loop:

    ./configure --enable-poll
    configure: Using epoll for the IO loop.

2 years agoLog the number of request sending attempts (#541)
Eduard Bagdasaryan [Fri, 6 Jan 2023 20:32:17 +0000 (20:32 +0000)] 
Log the number of request sending attempts (#541)

Squid retries certain request forwarding failures. When the problem is
persistent, and there are many peers (or the origin server has many
IPs), many retries are possible. Absence of Squid-server transaction log
hides these retries from admins. The new logformat code helps discover
and triage problems, especially when Squid retries many times.

2 years agoMaintenance: Updated CONTRIBUTORS (#1225)
Alex Rousskov [Wed, 4 Jan 2023 18:53:30 +0000 (18:53 +0000)] 
Maintenance: Updated CONTRIBUTORS (#1225)

This change is a reference point for automated CONTRIBUTORS updates.

2 years ago%busy_time: Time spent in transaction-related code (#1216)
Alex Rousskov [Tue, 3 Jan 2023 12:20:27 +0000 (12:20 +0000)] 
%busy_time: Time spent in transaction-related code (#1216)

Configuration tuning, problems triage, and performance optimization
often benefit from knowing how much time Squid spent on a particular
transaction (or a typical transaction in a category like "cache hits").

We already log total transaction response time (%tr), but that time
includes transaction queuing time (i.e. the time when Squid could
advance our transaction but was advancing other transactions) and
various waiting periods (e.g., waiting for a helper response). The new
measurement focuses on time periods when Squid was actively working on
(as in "was blocked on") our transaction.

CodeContext coverage problems do affect this measurement, but the
existing coverage is already good enough for usable measurements in some
cases, and it is getting better. It will take us a long time to cover
all cases; we should not wait for that to happen (as long as we warn
admins about these problems).

2 years agoMaintenance: source maintenance script improvements (#1220)
gkinkie@gmail.com [Fri, 30 Dec 2022 18:07:12 +0000 (18:07 +0000)] 
Maintenance: source maintenance script improvements (#1220)

- Allow passing astyle program name via ASTYLE environment variable.
- By default, use "astyle-3.1" if present or "astyle" otherwise.
- Add an option to format changed source files only.

No changes to the default behavior except for environments where a
program named "astyle-3.1" is present but a program named "astyle" was
previously used.

2 years agoFix errorpage.cc build on MacOS (#1219)
gkinkie@gmail.com [Wed, 28 Dec 2022 13:38:35 +0000 (13:38 +0000)] 
Fix errorpage.cc build on MacOS (#1219)

    errorpage.cc:153:44: error: implicit instantiation of undefined
    template std::array<HardCodedError, 7> HardCodedErrors

2 years agoFix ./configure --with-filedescriptors=NUMBER (#1217)
Alex Rousskov [Sat, 24 Dec 2022 17:00:32 +0000 (17:00 +0000)] 
Fix ./configure --with-filedescriptors=NUMBER (#1217)

Commit a1c2236 forgot to quote AS_CASE argument of AC_ARG_WITH(),
resulting in the following ./configure-time errors:

    error: --with-filedescriptors expects a numeric argument

We now quote AS_CASE argument of AC_ARG_WITH(), as recommended by
Autoconf and for consistency sake. More (hopefully automated) work is
needed to quote all function call arguments (that should be quoted).

Also use m4 quadrigraphs for quoting safety sake and to attract readers
attention to a risky (from writing in m4 point of view) expression. This
particular improvement is not required to fix the bug.

The other two AC_ARG_WITH() are modified for consistency sake but they
were not broken and their compiled versions have not changed.

2 years agoFix GCC v12 build errors related to ADL in "printing" code (#1215)
Alex Rousskov [Thu, 22 Dec 2022 02:12:12 +0000 (02:12 +0000)] 
Fix GCC v12 build errors related to ADL in "printing" code (#1215)

This change contains three fixes/adjustments described below.

### Fix Store::SwapMetaView printing

    src/sbuf/Stream.h:66:20: error: no match for 'operator<<' (operand
    types are 'std::basic_ostream<char>' and 'const
    Store::SwapMetaView'): (out << ... << args);

Disclaimer: This explanation omits many details that become important in
some other contexts. Most Argument-Dependent Lookup details are
documented at https://en.cppreference.com/w/cpp/language/adl

    // In some printer.h, we define a printing function for any type A.
    // This is similar to an ToSBuf() declaration in sbuf/Stream.h.
    template <typename A>
    void print(ostream &os, const A &argument) { os << argument; }

    // In some n/t.h, we define how to print objects of type N::T.
    // This is similar to store/SwapMetaView.h.
    operator <<(ostream &os, const N::T &argument);

    // In some caller1.cc, we include both headers and call print():
    #include "printer.h"
    #include "n/t.h"
    void caller1(const N::T &argument) { print(std::cout, argument); }

    // In some caller2.cc, we do the same but change #include order:
    #include "n/t.h"
    #include "printer.h"
    void caller2(const N::T &argument) { print(std::cout, argument); }

When looking at "os << argument", the compiler considers two sets of
argument printing operators, formed by the following two sources:

* The usual unqualified name lookup. This set includes N::T printing
  operator if that operator is declared in global namespace somewhere
  above the print() _template declaration_. In the example above, only
  caller2() will have that printing operator in this set, provided that
  operator is declared in global namespace (as it used to be). None of
  the callers will have that printing operator in this set otherwise.

* ADL. This set is computed from the caller point of view. It includes
  N::T printing operator if that operator is declared inside namespace N
  somewhere above the print() _caller_. In the example above, both
  caller1() and caller2() will have that printing operator in this set,
  provided that operator is declared in namespace N (as it is now). None
  of the callers will have that printing operator in this set otherwise.

For code to compile, one of the sets must contain the printing operator.
Given the above outcomes, there is only one sane solution that allows
any caller to instantiate print() with an N::T argument: The argument
printing operator must be declared inside namaspace N! Declaring in
global namespace would require maintaining certain #include order (that
will cause headaches and, eventually, circular dependencies).

In other words, we must rely on ADL, and that means declaring operators
in the namespace of one of their argument types.

### Fix std::optional<Ip::Address> printing (in src/icap/Xaction.cc)

    src/base/AsyncJobCalls.h:115:61: error: no match for 'operator<<'
    (operand types are 'std::basic_ostream<char>' and 'const
    std::optional<Ip::Address>'):
    void print(std::ostream &os) const { os << '(' << arg1 << ')'; }

In this context, both printing operator argument types are in std, but
ADL also looks at template parameters of argument types (if an argument
type is a template). That recursion adds the Ip namespace to the search.

This is a minimal fix. We should move both Ip::Address printers into
ip/print.h or similar, away from Ip::Address users that print nothing.

### Do not declare an overly general std::optional printer

The removed declaration:

* evidently became unused (after the other changes described above);
* places std::optional<N::T> printers in the wrong namespace (global
  instead of N), where ADL cannot find them;
* exposes all I/O manipulators to a, technically, unrelated
  std::optional interface.

Co-authored-by: Amos Jeffries <squid3@treenet.co.nz>
2 years agoSupport "negative" squid-conf-tests (#1214)
Alex Rousskov [Tue, 20 Dec 2022 15:41:40 +0000 (15:41 +0000)] 
Support "negative" squid-conf-tests (#1214)

The test suite can now check that Squid rejects a given malformed
configuration file and that the rejection reason matches the expected
one. The latter reduces the probability that a successful "negative"
test outcome would hide a bug (because Squid has rejected a malformed
file but for a reason unrelated to what the test was trying to verify).

For now, enable just one acl regex test case, addressing an old TODO.

To improve "negative" test coverage, we would need to generate test
configurations using a configuration template and a list of problematic
expressions (with corresponding failure messages), but this hard-coded
approach is already better than nothing.

2 years agoRequire C++17 (#1212)
Alex Rousskov [Tue, 13 Dec 2022 23:17:48 +0000 (23:17 +0000)] 
Require C++17 (#1212)

Modern environments support C++17 well. We are wasting significant
amounts of time on emulating such basic C++17 features as std::optional.
We are writing worse code than we can because we lack access to such
C++14 and C++17 features like std::make_unique and std::byte.

The following language-standard-dependent TODOs were completed:

* Switched to [[fallthrough]] attributes.
* Replaced Optional with std::optional.
* Replaced EnableIfType with std::enable_if_t.
* Removed old C++11 type replacements (e.g., xuniform_int_distribution).
* Removed std::allocator declarations deprecated in C++17.
* Made ToSBuf() readable using a fold expression.
* Simplified compile-time "natural type" assertions.
* Used std::container::emplace*() return value where warranted.

Moved BUILDCXX-setting code after AX_CXX_COMPILE_STDCXX adds -std=c++17
to CXX (rather than CXXFLAGS!). Our cf_gen was built with compiler's
default C++ standard version! Ideally, BUILDCXX block should be lowered
further -- other macros might alter CXX -- but its CXXFLAGS adjustment
may affect subsequent code, warranting a careful/dedicated change.

2 years agoBan acl key changes in req_header, rep_header, and note ACLs (#1210)
Alex Rousskov [Mon, 12 Dec 2022 13:34:12 +0000 (13:34 +0000)] 
Ban acl key changes in req_header, rep_header, and note ACLs (#1210)

* req_header and rep_header ACLs; the key is the header-name argument:

    acl barred req_header X-1 bar
    acl barred req_header X-2 bar # never matches since commit a0b240c
    http_access deny barred

* the "note" ACL; the key is the annotation name argument:

    acl banned note color green  # never matches since commit 39baccc
    acl banned note weight heavy
    http_access deny banned

Squid did write a cache.log ERROR for req_header/rep_header key changes
but was silent about the preceding "note" ACL rules being ineffective
after a key change (e.g., Squid was not denying "green" requests above).

Now, Squid rejects configurations containing such ACL key changes.

Also significantly reduced the corresponding parsing code duplication.

2 years agoFix ACL type typo in req_header, rep_header key-changing ERRORs (#1208)
Alex Rousskov [Sat, 10 Dec 2022 14:18:18 +0000 (14:18 +0000)] 
Fix ACL type typo in req_header, rep_header key-changing ERRORs (#1208)

2 years agoext_kerberos_ldap_group_acl: Support -b with -D (#1207)
Alexander Bokovoy [Sat, 10 Dec 2022 11:50:27 +0000 (11:50 +0000)] 
ext_kerberos_ldap_group_acl: Support -b with -D (#1207)

When both '-b' (i.e. bind DN) and '-D' (i.e. Kerberos domain) options
are specified, '-b' is ignored completely. This breaks the helper when a
search subtree has to be limited (e.g., when using FreeIPA).

Fix it to take '-b' into account if it was specified with '-D'.

2 years agoUpdate LruNode to MEMPROXY_CLASS (#1206)
Amos Jeffries [Fri, 9 Dec 2022 21:54:31 +0000 (21:54 +0000)] 
Update LruNode to MEMPROXY_CLASS (#1206)

2 years agosquid-conf-tests should test installed Squid (#1204)
Alex Rousskov [Fri, 9 Dec 2022 11:51:39 +0000 (11:51 +0000)] 
squid-conf-tests should test installed Squid (#1204)

    FATAL: ..._inst/etc/mime.conf: (2) No such file or directory
    FATAL: ..._inst/share/icons: (2) No such file or directory

Our squid-conf-tests are running "squid -k parse" that requires icons
and other supplementary files to be _installed_. Thus, squid-conf-tests
must run during "make installcheck" rather than during "make check".

With this change, "make distcheck" triggers squid-conf-tests at the
right time, after "all", "check", and "install" targets are built.
Also, we are now testing installed Squid binaries, as we should.

2 years agoUpdate Host, Via, and other headers in-place when possible (#1203)
Eric Walters [Fri, 9 Dec 2022 05:58:43 +0000 (05:58 +0000)] 
Update Host, Via, and other headers in-place when possible (#1203)

This change optimizes Host header synchronization code that usually does
not need to change the Host header field but was always deleting the old
field and generating/appending a new one. Appending Host also violated
an RFC 9110 section 7.2 rule (on behalf of the user agent whose Host we
were rewriting): "A user agent that sends Host SHOULD send it as the
first field in the header section".

Also, removing old header fields and appending new ones introduced HTTP
header changes that broke otherwise working peers. For example, some
origins denied Squid-proxied messages exclusively due to an unusual
(from those origins point of view) Host header position. This change
reduces (but does not eliminate) such unnecessary and risky changes.

2 years agoFix helper module auto-detection algorithm (#1194)
Amos Jeffries [Fri, 9 Dec 2022 01:08:03 +0000 (01:08 +0000)] 
Fix helper module auto-detection algorithm (#1194)

Two issues here causing no helpers to be detected as buildable when
./configure parameters are missing entirely (eg "./configure ").
These were not detected by our build farm because missing helpers
is not an error, they are optional, and we lack tests validating
optional helpers.

1) Over-escaping of "$" variable prefix (M4 "$$" expands to "$")
   prevented the path string being expanded to correct value for
   the helper directory test. Causing it to always fail.

2) The $ac_top_srcdir variable internal to autoconf may not be set
   at the time AC_DEFUN macros are expanded. Making it unreliable.
   The $top_srcdir variable which should be used instead has the
   same problem with "top" not yet being determined. As such we
   use $srcdir instead and hope it expands correctly at ./configure
   run time.

2 years agoDo not overwrite caching bans (#1189)
Alex Rousskov [Thu, 8 Dec 2022 08:25:44 +0000 (08:25 +0000)] 
Do not overwrite caching bans (#1189)

To ban caching, Squid made RequestFlags::cachable false in several
places (e.g., when a "cache deny" rule matched). To permit caching,
Squid also made the flag true in several places (e.g., when
maybeCacheable() was true). That combination worked as intended only
when the cachable=false veto always came after all the cachable=true
support votes. The code did not (and should not) enforce such a
complicated/fragile timing invariant.

Squid now correctly honors caching bans regardless of the updates order.

This change addresses an old XXX, but we are not aware of any specific
bugs fixed by this change. The primary purpose of this change is to make
the existing baseline ban-honoring functionality easy to maintain.

Also reduced code duplication across cachable=false,noCache=true code.

2 years agoSource Format Enforcement (#1201)
squidadm [Thu, 8 Dec 2022 02:50:15 +0000 (02:50 +0000)] 
Source Format Enforcement (#1201)

2 years agoFix regression test configuration (#1198)
Eduard Bagdasaryan [Wed, 7 Dec 2022 20:15:17 +0000 (20:15 +0000)] 
Fix regression test configuration (#1198)

The regressions-3.4.0.1 configuration produces an error message:

    ERROR: Can not open file empty for reading

Broken since commit 6c9a5e8 that renamed "empty" to "empty.conf".

2 years agoOptimize RefCount comparison with raw pointers (#1200)
sameer-here [Wed, 7 Dec 2022 17:27:47 +0000 (17:27 +0000)] 
Optimize RefCount comparison with raw pointers (#1200)

GCC v12 and Clang v12 tests show that compilers cannot avoid creating
temporaries when comparing RefCount objects with arbitrary pointers.

Also fixes (not yet supported) C++20 build. C++20 automatically reverses
equality comparisons, triggering an ambiguity:

    src/esi/Esi.cc:1920:26: error: ambiguous overload for 'operator=='
        (operand types are 'ESISegment::Pointer' {aka
        'RefCount<ESISegment>'} and std::nullptr_t)
        assert (output->next == nullptr);

    src/esi/Esi.cc:77:6: note: candidate: 'bool operator==(const
        ESIElement*, const Pointer&)' (reversed)

    src/base/RefCount.h:82:10: note: candidate: 'bool
        RefCount<C>::operator==(const RefCount<C>&) const [with C =
        ESISegment]'

2 years agoDrop CBDATA debugging (#1199)
Amos Jeffries [Mon, 5 Dec 2022 15:52:26 +0000 (15:52 +0000)] 
Drop CBDATA debugging (#1199)

This was occasionally (but still rare) useful when CBDATA was the
only method of passing callback parameters. Much of that has now
been replaced with AsyncJob/AsyncCall logic. Making this debug
much less useful.

Remove the --enable-debug-cbdata build option and two cache manager
reports only enabled when that option is built. Greatly reducing
the cbdata logic complexity and removing one of its five APIs
permutations entirely.

2 years agoAvoid level-3 "failed to find or read error text file" WARNINGs (#1176)
Eduard Bagdasaryan [Sun, 4 Dec 2022 22:00:20 +0000 (22:00 +0000)] 
Avoid level-3 "failed to find or read error text file" WARNINGs (#1176)

... when (re)configuring ERR_REQUEST_PARSE_TIMEOUT and ERR_RELAY_REMOTE
error templates. These errors cannot be customized externally and should
have been listed as such in commits 9ce4a1e and f5e1794, respectively.

Also polished hard-coded error storage code.

2 years agobasic_ncsa_auth: Fix missing libnettle dependency (#1193)
Amos Jeffries [Fri, 2 Dec 2022 14:11:22 +0000 (14:11 +0000)] 
basic_ncsa_auth: Fix missing libnettle dependency (#1193)

Broken since b12b66cdd75835c6fb92bf25c2f68272f55d21cd

2 years agokerberos_ldap_group: fix unused variable warnings (#1192)
Amos Jeffries [Fri, 2 Dec 2022 09:11:39 +0000 (09:11 +0000)] 
kerberos_ldap_group: fix unused variable warnings (#1192)

When built with disabled LDAP support.

2 years agoRefactor memory pools statistics gathering (#1186)
Amos Jeffries [Fri, 2 Dec 2022 05:02:44 +0000 (05:02 +0000)] 
Refactor memory pools statistics gathering (#1186)

2 years agoBug 5162: mgr:index URL do not produce MGR_INDEX template (#1191)
Eduard Bagdasaryan [Thu, 1 Dec 2022 18:50:37 +0000 (18:50 +0000)] 
Bug 5162: mgr:index URL do not produce MGR_INDEX template (#1191)

Satisfy mgr:index requests using

* a 200 OK response with a body derived from the MGR_INDEX template (if
  that template file was found during (re)configuration) or
* a 404 (Not Found) error response (otherwise).

Broken in 2019 commit 7e6eabb, when Squid started replying using a 200
OK response with a hard-coded "mgr_index" text as a body, ignoring any
configured MGR_INDEX template.

2 years agoMake Optional<bool> trivially copyable (#1188)
Alex Rousskov [Thu, 1 Dec 2022 05:49:57 +0000 (05:49 +0000)] 
Make Optional<bool> trivially copyable (#1188)

    ipc/TypedMsgHdr.h: static assertion failed: putPod() used for a POD
    ActionParams.cc:44: required from here [with Pod = RequestFlags]

The known XXX in Optional destructor has started to bite us because
pending changes expose memcpy(3)-based IPC serialization code to
Optional<bool> flags. It is possible to mimic standard std::optional
implementations, avoiding that XXX, but that requires rather
sophisticated C++ tricks with placement new() and such. Specializing the
whole Optional is a better alternative for this _temporary_ class IMO.

2 years agoMaintenance: Missing squid.h include (#1190)
Alex Rousskov [Wed, 30 Nov 2022 18:09:02 +0000 (18:09 +0000)] 
Maintenance: Missing squid.h include (#1190)

Broken since inception (i.e. master/v6 commit 4a28fc5).
Detected by scripts/source-maintenance.sh.

2 years agoCI: Test handling of truncated responses (#1187)
Alex Rousskov [Tue, 29 Nov 2022 02:57:15 +0000 (02:57 +0000)] 
CI: Test handling of truncated responses (#1187)

Use Daft truncated-responses test to monitor for bugs like those fixed
by master/v6 commit ba3fe8d.

2 years agoShuffle MemAllocator to Mem namespace (#1181)
Amos Jeffries [Mon, 28 Nov 2022 14:46:51 +0000 (14:46 +0000)] 
Shuffle MemAllocator to Mem namespace (#1181)

Update and add missing documentation for class members.

Update syntax to latest standard compliance and Squid
coding guideline style.

2 years agoMove MemPoolMeter into Mem namespace (#1183)
Amos Jeffries [Thu, 24 Nov 2022 00:17:11 +0000 (00:17 +0000)] 
Move MemPoolMeter into Mem namespace (#1183)

Simplified PoolMeter::flush() implementation
and inlined it for performance.

Convert mgb_t type to a sub-struct and inline
C++11 initialization for performance.

Also update Mem::Meter initialization.

2 years agoRemove Mem::Report() and polish memory_pools_limit storage (#1184)
Amos Jeffries [Mon, 21 Nov 2022 05:20:32 +0000 (05:20 +0000)] 
Remove Mem::Report() and polish memory_pools_limit storage (#1184)

The official code should not call Mem::Report(). There is no
justification for main.cc treating memory module in such a
special way. The reporting code itself has problems.
Removing all this code is better than leaving or polishing it.

2 years agoDo not blame cache_peer for 4xx CONNECT responses (#1166)
Eduard Bagdasaryan [Sun, 13 Nov 2022 16:00:21 +0000 (16:00 +0000)] 
Do not blame cache_peer for 4xx CONNECT responses (#1166)

To avoid using a problematic cache_peer, Squid penalizes cache_peers for
a variety of problems. However, a problem like an HTTP 403 Forbidden
response may be caused by the client or other factors unrelated to the
cache_peer that sent the response to Squid. In those cases, the
cache_peer is not at fault and should not be marked dead, even after
many such responses.

This change stops blaming cache_peers for HTTP 4xx outcomes of Squid
CONNECT requests. Currently, such outcomes only happen when a cache_peer
responds with a 4xx reply, but the new code also treats Squid-generated
4xx error responses (while trying to establish a connection to the
cache_peer) the same way.

This hard-coded logic covers known use cases. If different use cases
surface, we can make Squid behavior configurable.

Co-authored-by: Amos Jeffries <squid3@treenet.co.nz>