]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
13 months agoDo not populate StoreEntry basics from Transients (#1343)
Alex Rousskov [Sat, 13 May 2023 00:30:52 +0000 (00:30 +0000)] 
Do not populate StoreEntry basics from Transients (#1343)

    client_side_reply.cc:1078: "http->storeEntry()->objectLen() >= 0"
    inside clientReplyContext::storeOKTransferDone()

Since commit 24c9378, Transients are not supposed to maintain "basic"
cache entry information (i.e. StoreMapAnchor::Basics a.k.a. StoreEntry
STORE_META_STD fields). Using often-at-their-defaults Transient basics
may unexpectedly erase valuable StoreEntry information obtained from one
of the caches (e.g., swap_file_sz) and lead to assertions.

Consequently, do not populate unused Transients entry basics either.

Eventually, we may find a good way to parameterize StoreMapAnchor to
avoid keeping those unused fields in Transients StoreMap.

13 months 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).

13 months agoDo not check store_status when checking ENTRY_BAD_LENGTH (#1342)
Alex Rousskov [Wed, 3 May 2023 22:20:27 +0000 (22:20 +0000)] 
Do not check store_status when checking ENTRY_BAD_LENGTH (#1342)

Before 1997 commit b34ed72 (that introduced the current ENTRY_BAD_LENGTH
"cache"), checking store_status before calling storeEntryValidLength()
kind of made sense because storeEntryValidLength() did not support
STORE_PENDING entries with their unset object_len. Since that commit,
checking store_status does not cause any visible problems (i.e. the code
"works") because ENTRY_BAD_LENGTH implies STORE_OK. However, that
implication is not backed by some fundamental invariant and might
suddenly disappear. Checking two flags instead of one is also wasteful.

No Squid functionality changes are expected.

13 months agoPrepare ChangeLog for v6.0.2 (#1326)
Francesco Chemolli [Thu, 27 Apr 2023 23:25:38 +0000 (23:25 +0000)] 
Prepare ChangeLog for v6.0.2 (#1326)

13 months 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.

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

13 months agoDrop pointless testCharacterSet method (#1329)
Amos Jeffries [Tue, 25 Apr 2023 16:15:54 +0000 (16:15 +0000)] 
Drop pointless testCharacterSet method (#1329)

It does nothing and CharacterSet is tested elsewhere.

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

13 months agoMaintenance: remove some unit test headers (#1293)
Francesco Chemolli [Mon, 24 Apr 2023 20:23:37 +0000 (20:23 +0000)] 
Maintenance: remove some unit test headers (#1293)

When a unit test class is not reused across translation units, merge the
class declaration with its implementation and remove the header file. In
many cases, these classes are not meant/designed to be reusable that
way, and we should not imply otherwise by publishing a header file.

Excuse src/tests/testAuth.h until we make that test work again.

13 months 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.

14 months agoMaintenance: Use C++ stdlib headers (#1314)
Francesco Chemolli [Fri, 21 Apr 2023 16:25:02 +0000 (16:25 +0000)] 
Maintenance: Use C++ stdlib headers (#1314)

In C++ files, use C++ standard library headers instead of their
(guarded) C equivalents (e.g., use `<cstdlib>` instead of `<stdlib.h>`).

14 months agoWCCP: fix inverted range check (#1323)
Amos Jeffries [Wed, 19 Apr 2023 14:55:13 +0000 (14:55 +0000)] 
WCCP: fix inverted range check (#1323)

Correct a typo in 464223c147a568169e940fb466947bdb556d87af

14 months agoAdd buffered_logs OFF support to UDP logger (#1315)
Rybakov Andrey [Mon, 17 Apr 2023 09:46:32 +0000 (09:46 +0000)] 
Add buffered_logs OFF support to UDP logger (#1315)

UDP log module always buffers log entries with a limit of
1400 bytes. Enable the "buffered_logs off" squid.conf
setting to disable this behaviour.

14 months agoRemove dead "binary HTTP header logging" code (-DHEADERS_LOG) (#1319)
Alex Rousskov [Mon, 3 Apr 2023 22:14:26 +0000 (22:14 +0000)] 
Remove dead "binary HTTP header logging" code (-DHEADERS_LOG) (#1319)

The secret HEADERS_LOG hack was added in 2000 commit c360932 to collect
"better stats" than mgr:http_headers. The corresponding access_log.cc
code does not build since 2006 commit 985c86b (at least):

* 'm' was not declared in this scope
* cannot convert 'int*' to 'const char*'
* cannot convert 'short unsigned int*' to 'const char*'
* invalid conversion from 'unsigned char*' to 'const char*'
* invalid conversion from 'void*' to 'HttpReply*'
* invalid conversion from 'void*' to 'HttpRequest*'
* invalid use of incomplete type 'class HttpHdrCc'
* too few arguments to function 'logfileOpen(const char*, size_t, int)'

The removed hack is not to be confused with log_mime_hdrs directive.

14 months 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).

14 months agoSimplify use of DIST_SUBDIRS (#1309)
Amos Jeffries [Mon, 27 Mar 2023 10:12:46 +0000 (10:12 +0000)] 
Simplify use of DIST_SUBDIRS (#1309)

automake only needs the DIST_SUBDIRS list to be set 'manually' when
the SUBDIRS list is built using AC_SUBST variables.

For Makefile.am which exclusively use AC_CONDITIONAL we can leave
the DIST_SUBDIRS construction to automake.

14 months 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.

14 months agoFix rock/RockSwapDir.cc "slot->sameKey()" assertion (#1310)
Alex Rousskov [Fri, 17 Mar 2023 14:50:15 +0000 (14:50 +0000)] 
Fix rock/RockSwapDir.cc "slot->sameKey()" assertion (#1310)

Introduced in 2014 commit fa2301d, the assertion was too strict: Due to
store_client idiosyncrasies, openStoreIO() may be called long after the
initial cache hit is detected and locked for reading. It is possible
that the StoreEntry object has gone private since that detection and
locking. Private StoreEntry objects lose their public keys. The existing
anchor lock assures that we still point to the right disk entry, but we
cannot check that invariant using the now-private StoreEntry key.

There are no known sightings of this assertion in the wild, but we can
now reproduce it using high-load Web Polygraph tests. It is not clear
whether some other Squid changes made the triggering sequence of events
a bit more likely, or we were just lucky to discover the right workload.

15 months agoRemove some duplicate typedef and forward declarations (#1305)
Amos Jeffries [Sun, 12 Mar 2023 20:42:20 +0000 (20:42 +0000)] 
Remove some duplicate typedef and forward declarations (#1305)

15 months agoReplaced clientReplyContext::tempBuffer with old_reqofs (#1304)
Alex Rousskov [Sat, 11 Mar 2023 05:48:14 +0000 (05:48 +0000)] 
Replaced clientReplyContext::tempBuffer with old_reqofs (#1304)

The tempBuffer data member was not actually used as a buffer. We only
used its offset field, and only for saving reqofs (which has a different
type than tempBuffer.offset!). Replaced the buffer with old_reqofs,
consistent with the rest of the "saved stale entry state" code.

Also fixed old_reqsize type to match reqsize and grouped that member
with the other private "saved stale entry state" fields.

Bad old types probably did not trigger runtime failures because the
associated saved numbers are saved at the very beginning of fetching the
entry, when all these accumulation-related counters are still small.

The remaining reqofs and reqsize types are wrong for platforms where
size_t is not uint64_t, but fixing that deserves a dedicated change. For
now, we just made the types of "old_" and "current" members consistent.

15 months 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.

15 months agoReduce stale errno usage (#1302)
Alex Rousskov [Mon, 6 Mar 2023 18:44:38 +0000 (18:44 +0000)] 
Reduce stale errno usage (#1302)

This covers a few easy cases, one of which resulted in wasted triage
time. More changes are needed to cover all potentially stale errno uses.

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

15 months agoRemoved unused mem_hdr methods (#1298)
Eduard Bagdasaryan [Sat, 4 Mar 2023 18:09:05 +0000 (18:09 +0000)] 
Removed unused mem_hdr methods (#1298)

Unused probably since 2003 commit 528b2c6.

15 months 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.

15 months agoMaintenance: Better inet_ntop6() local variable declarations (#1080)
gkinkie@gmail.com [Sat, 4 Mar 2023 11:08:04 +0000 (11:08 +0000)] 
Maintenance: Better inet_ntop6() local variable declarations (#1080)

15 months 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

15 months 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().

15 months 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.

15 months agoCI: Remove irrelevant branch from master GitHub Actions config (#1292)
Alex Rousskov [Tue, 28 Feb 2023 21:40:14 +0000 (21:40 +0000)] 
CI: Remove irrelevant branch from master GitHub Actions config (#1292)

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.

15 months 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.

15 months agoImprove AnyP::Uri::port_ and related port storage types (#1255)
Alex Rousskov [Mon, 27 Feb 2023 10:56:57 +0000 (10:56 +0000)] 
Improve AnyP::Uri::port_ and related port storage types (#1255)

The old "unsigned short" type is used for various things all over the
code and cannot distinguish a parsed port zero from an absent port. In
theory, it could also hold values exceeding 65535, getting out of sync
with various (poorly duplicated) maximum port value checks.

No significant runtime changes are expected, but some transactions with
unknown request URI ports may now be reported correctly, showing "-"
instead of "0" for the missing port number. In some very special/rare
on_unsupported_protocol cases, Squid might no longer attempt to tunnel
non-HTTP requests to a zero port. Such attempts were failing anyway.

This change leaves many "unsigned short" port use cases untouched. Most
of them should be converted, but most (if not all) of those conversions
should be done in dedicated projects. Here are a few TODO highlights:

* ACLIntRange: Stores integers, is usable for integers, but assumes it
  is being configured with port numbers. We probably should enhance that
  class to handle "all" integers instead of expanding/deepening that
  rather limiting "input is just port numbers" assumption.

* CachePeer and internalRemoteUri(): Likely runtime changes related to
  squid.conf validity.

* Ftp::Server::listenForDataConnection() and friends: Triggers a few
  changes with runtime effects related to comm_local_port() failures.

* Ip::Address, Snmp::Session, fde: Too many low-level changes, some of
  which would be difficult to test.

* Config.Port.icp: Possible runtime changes related to squid.conf and
  command-line arguments validity.

Also used "%hu" instead of "%u" or "%d" to printf() ports. These changes
arguably improve code and might make some pedantic compiler happier, but
they do not fix any "real" bugs because variadic printf() arguments are
automatically promoted from short to int and, hence, printf()
implementations never get and never expect shorts.

15 months agoPrep for 5.8 and 6.0.1 (#1287)
Amos Jeffries [Mon, 27 Feb 2023 00:33:45 +0000 (00:33 +0000)] 
Prep for 5.8 and 6.0.1 (#1287)

15 months agopinger: improve timer accuracy and resolution (#1277)
Amos Jeffries [Sat, 25 Feb 2023 16:28:14 +0000 (16:28 +0000)] 
pinger: improve timer accuracy and resolution (#1277)

For consistency across platforms, we also increase the ICMP request
timeout on Windows systems from 5 to 10 seconds.

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

15 months agoMaintenance: Change unit test class names to CamelCase (#1288)
gkinkie@gmail.com [Sat, 25 Feb 2023 11:53:17 +0000 (11:53 +0000)] 
Maintenance: Change unit test class names to CamelCase (#1288)

Besides applying Project CamelCase class naming rules to all CppUnit
test class names, these script-driven changes also adjust affected class
name-dependent code, improve consistency across unit test declarations a
little, and rename a few test classes (e.g. testURL is not TestUri). The
corresponding source code filenames are left unchanged (for now).

15 months agoAdd unit tests for ClpMap (#1262)
gkinkie@gmail.com [Fri, 24 Feb 2023 20:45:27 +0000 (20:45 +0000)] 
Add unit tests for ClpMap (#1262)

15 months agoRemoved unused StoreSearchUFS (#1285)
Eduard Bagdasaryan [Thu, 23 Feb 2023 23:35:48 +0000 (23:35 +0000)] 
Removed unused StoreSearchUFS (#1285)

It is unused since 2015 commit 2745fea.

15 months ago7.0.0 (#1284)
squidadm [Tue, 21 Feb 2023 20:52:49 +0000 (20:52 +0000)] 
7.0.0 (#1284)

15 months 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

16 months 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.

16 months 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.

16 months 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.

16 months 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

16 months 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.

16 months 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().

16 months 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.

16 months 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

16 months 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.

16 months 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.

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

16 months 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.

16 months 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.

16 months 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().

16 months 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.

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

16 months 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).

16 months 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

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

16 months 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.

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

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

16 months 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.

16 months 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.

16 months 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>
16 months 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.

16 months 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.

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

16 months 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.

16 months 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]`

16 months 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]

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

17 months 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>
17 months 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.

17 months 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.

17 months 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.

17 months 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.

17 months 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.

17 months 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?

17 months 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.

17 months 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.

17 months 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.

17 months 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.

17 months 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).

17 months 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.

17 months 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

17 months 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.

17 months 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>
17 months 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.

18 months 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.

18 months 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.

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

18 months 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'.

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

18 months 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.

18 months 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.

18 months 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.

18 months 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.

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

18 months 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".