]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
28 hours agoCI: Update GitHub actions/checkout to v4 (#1786) master
Francesco Chemolli [Thu, 18 Apr 2024 15:41:58 +0000 (15:41 +0000)] 
CI: Update GitHub actions/checkout to v4 (#1786)

3 days agoNoNewGlobals for cache_mem_map (#1781)
Francesco Chemolli [Tue, 16 Apr 2024 02:48:26 +0000 (02:48 +0000)] 
NoNewGlobals for cache_mem_map (#1781)

Detected by Coverity. CID 1554648: Initialization or destruction
ordering is unspecified (GLOBAL_INIT_ORDER).

4 days agoBug 5352: Do not get stuck when RESPMOD is slower than read(2) (#1777)
Alex Rousskov [Sat, 13 Apr 2024 08:15:00 +0000 (08:15 +0000)] 
Bug 5352: Do not get stuck when RESPMOD is slower than read(2) (#1777)

    ... RESPMOD BodyPipe buffer becomes full ...
    maybeMakeSpaceAvailable: will not read up to 0
    The AsyncCall Client::noteDelayAwareReadChance constructed

    ... RESPMOD consumes some buffered virgin body data ...
    entering BodyProducer::noteMoreBodySpaceAvailable
    leaving BodyProducer::noteMoreBodySpaceAvailable

    ... read_timeout seconds later ...
    http.cc(148) httpTimeout
    FwdState.cc(471) fail: ERR_READ_TIMEOUT "Gateway Timeout"

When RESPMOD does not empty its adaptation BodyPipe buffer fast enough,
readReply() may eventually fill that buffer and call delayRead(),
anticipating a noteDelayAwareReadChance() callback from Store or Server
delay pools. That callback never happens if Store and Server are not
getting any data -- they do not even start working until RESPMOD service
starts releasing adapted/echoed response back to Squid! Meanwhile, our
flags.do_next_read (cleared by readReply() caller) remains false.

When/if RESPMOD service eventually frees some BodyPipe buffer space,
triggering noteMoreBodySpaceAvailable() notification, nothing changes
because maybeReadVirginBody() quits when flags.do_next_read is false.

noteMoreBodySpaceAvailable() could not just make flags.do_next_read true
because that flag may be false for a variety of other/permanent reasons.
Instead, we replaced that one-size-fits-all flag with more specific
checks so that reading can resume if it is safe to resume it. This
change addresses a couple of flag-related XXXs.

The bug was introduced in 2023 commit 50c5af88. Prior that that change,
delayRead() was not called when RESPMOD BodyPipe buffer became full
because maybeMakeSpaceAvailable() returned false in that case, blocking
maybeReadVirginBody() from triggering readReply() via Comm::Read(). We
missed flags.do_next_read dependency and that Store-specific delayRead()
cannot be used to wait for adaptation buffer space to become available.

XXX: To reduce risks, this change duplicates a part of
calcBufferSpaceToReserve() logic. Removing that duplication requires
significant (and risky) refactoring of several related methods.

6 days agoAdd AsList::quoted() (#1779)
Francesco Chemolli [Thu, 11 Apr 2024 14:22:46 +0000 (14:22 +0000)] 
Add AsList::quoted() (#1779)

10 days agoMaintenance: update --with-tdb detection (#1776)
Amos Jeffries [Tue, 9 Apr 2024 02:26:59 +0000 (02:26 +0000)] 
Maintenance: update --with-tdb detection (#1776)

11 days agoUpgrade Acl::Node::name to SBuf; remove AclMatchedName global (#1766)
Alex Rousskov [Mon, 8 Apr 2024 22:06:02 +0000 (22:06 +0000)] 
Upgrade Acl::Node::name to SBuf; remove AclMatchedName global (#1766)

AclMatchedName global has been localized into a regular Acl::Answer data
member (Acl::Answer maintains the result of ACLChecklist evaluations).
This long overdue change resolves an old TODO and XXXs, paving the way
for Acl::Node reference counting.

No significant functionality changes are expected, but it is possible
that some deny_info configurations will now be handled better in
reconfiguration corner cases (because Squid no longer forgets the name
of the last checked ACL when a slow ACL check crosses reconfiguration
barrier).

Most of these changes are performance-neutral or -positive because they
eliminate or reduce memory allocations and associated name copying (and
more reduction will become possible after upgrading squid.conf parsers
to use SBuf). This change adds SBuf object copies when Acl::Answer is
propagated to ACLCB callbacks, but those read-only copies are cheap.

Also renamed and polished aclGetDenyInfoPage() because we had to update
its parameter type (to supply the last evaluated ACL). All callers were
also supplying the same first argument (that is unlikely to change in
the foreseeable future); that argument is now gone. We  did not fix the
redirect_allowed name and debugs(): Fixing that behavior deserves a
dedicated change.

Also polished legacy aclIsProxyAuth() profile and description because we
have to change the parameter type (to supply the last evaluated ACL).

Also removed 63-character aclname parameter limit for acl directives.

11 days agoNoNewGlobals for HttpHdrCc:ccLookupTable (#1750)
Francesco Chemolli [Mon, 8 Apr 2024 18:50:51 +0000 (18:50 +0000)] 
NoNewGlobals for HttpHdrCc:ccLookupTable (#1750)

Detected by Coverity. CID 1554655: Initialization or destruction
ordering is unspecified (GLOBAL_INIT_ORDER).

Also switched to compile-time checks for table initialization records.

11 days agoAdd AtMostOnce stream manipulator (#1742)
Francesco Chemolli [Mon, 8 Apr 2024 15:24:39 +0000 (15:24 +0000)] 
Add AtMostOnce stream manipulator (#1742)

11 days agoRefactor and improve ErrorState::Dump (#1730)
Francesco Chemolli [Mon, 8 Apr 2024 12:01:32 +0000 (12:01 +0000)] 
Refactor and improve ErrorState::Dump (#1730)

Rework the internals for generating output in ErrorState::Dump,
used for expanding the '%W' token in error page templates.

Also fix a bug with excessive html-quoting of the output.

11 days agoNoNewGlobals for MemBlob::Stats (#1749)
Francesco Chemolli [Sun, 7 Apr 2024 16:51:02 +0000 (16:51 +0000)] 
NoNewGlobals for MemBlob::Stats (#1749)

Detected by Coverity. CID 1554656: Initialization or destruction
ordering is unspecified (GLOBAL_INIT_ORDER).

Also update MemBlobStats initialization.

12 days agoHave SQUID_CHECK_LIB_WORKS do state SAVE/RESTORE (#1774)
Amos Jeffries [Sun, 7 Apr 2024 11:34:49 +0000 (11:34 +0000)] 
Have SQUID_CHECK_LIB_WORKS do state SAVE/RESTORE (#1774)

Removing a lot of duplicated code and further
simplifying library detection.

2 weeks agoMaintenance: Remove several unused files (#1773)
Amos Jeffries [Fri, 5 Apr 2024 13:58:27 +0000 (13:58 +0000)] 
Maintenance: Remove several unused files (#1773)

2 weeks agoFix eCAP header includes (#1753)
Amos Jeffries [Fri, 5 Apr 2024 03:39:57 +0000 (03:39 +0000)] 
Fix eCAP header includes (#1753)

Squid style guidelines require .h files to be wrapped with
HAVE_*_H protection and placed after all Squid internal file
includes.

Add the missing ./configure header checks to generate the
needed wrappers and refactor the include sequences to meet
current guidelines.

2 weeks agoFix const-correctness of ACLHTTPHeaderData::match() parameter (#1771)
Alex Rousskov [Wed, 3 Apr 2024 09:25:55 +0000 (09:25 +0000)] 
Fix const-correctness of ACLHTTPHeaderData::match() parameter (#1771)

ACLHTTPHeaderData::match() required a pointer to non-const HttpHeader
but does not (and should not) modify the supplied HttpHeader.

Also removed support for nil HttpHeader in that method. All callers
already require HttpHeader presence. If that changes, it is the _caller_
that should decide what HttpHeader absence means (match, mismatch,
exception/dunno, etc.); ACLHTTPHeaderData does not have enough
information to make the right choice and, hence, should not be asked to
choose.

Also polished related #includes to remove unnecessary ones.

2 weeks agoDo not blame cache_peer for CONNECT errors (#1772)
Alex Rousskov [Tue, 2 Apr 2024 20:37:31 +0000 (20:37 +0000)] 
Do not blame cache_peer for CONNECT errors (#1772)

    ERROR: Connection to [such-and-such-cache_peer] failed
    TCP_TUNNEL/503 CONNECT nxdomain.test:443 FIRSTUP_PARENT

Squid does not alert an admin about (and decrease health level of) a
cache_peer that responded with an error to a GET request. Just like GET
responses from a cache_peer, CONNECT responses may (and often do!)
reflect client or origin server failures. We should not penalize
cache_peers (and alert admins) until we can distinguish these frequent
client/origin failures from (relatively rare) cache_peer problems. This
change absolves cache_peers of CONNECT problems, restoring parity with
GETs and restoring v4 behavior changed (probably by accident) in v5.

Also removed Http::StatusCode parameter from failure notification
functions because it became essentially unused after the primary
Http::Tunneler changes. Tunneler was the only source of status code
information that (in some cases) used received HTTP response to compute
that status code. All other cases extracted that status code from
Squid-generated errors. Those errors were arguably never meant to supply
status code information for "this failure is not our fault" decision,
and they do not supply 4xx status codes driving that decision.

### Problem evolution

2019 commit f5e1794 effectively started blaming cache_peer for all
FwdState CONNECT errors. That functionality change was probably
accidental, likely influenced by the names of noteConnectFailure() and
peerConnectFailed() functions that abbreviated "Connection", making the
functions look as applicable to CONNECT failures. Prior to that commit,
the functions were never used for CONNECT errors. After it, FwdState
started calling peerConnectFailed() for all CONNECT failures.

In 2020 commit 25b0ce4, TunnelStateData started blaming cache_peers as
well (by moving that FwdState-only error handling code into Tunneler).
The same "accidental functionality change" speculations apply here.

In 2022 commit 022dbab, we made an exception for 4xx CONNECT errors as
folks deploying newer code started complaining about cache_peers getting
blamed for client-caused errors (e.g., HTTP 403 Forbidden replies). We
did not realize that the blaming code itself was an unwanted accident.

Now we are getting complaints about cache_peers getting blamed for 502
and 503 CONNECT errors caused by, for example, domain names without IPs:
As these CONNECT error responses are propagated from parent to child
caches, every child cache in the chain logs ERRORs and every cache_peer
in the chain gets its health counter decreased!

2 weeks agoFix heap buffer overead in ConfigParser::UnQuote() (#1763)
xiaoxiaoafeifei [Tue, 2 Apr 2024 07:04:31 +0000 (07:04 +0000)] 
Fix heap buffer overead in ConfigParser::UnQuote() (#1763)

Detected by using AddressSanitizer.

2 weeks agoscripts/find-alive.pl: Auto-detect auto-added ctors/dtors names (#1769)
Alex Rousskov [Mon, 1 Apr 2024 19:43:21 +0000 (19:43 +0000)] 
scripts/find-alive.pl: Auto-detect auto-added ctors/dtors names (#1769)

    debugs(24, 9, "constructed, this=" << static_cast<void*>(this) ...

    MemBlob.cc(54) MemBlob: constructed, this=0x557f06b3ef00 ...

Class constructor and destructor sources should not manually duplicate
class names in debugs() statements. Many existing classes do the right
thing, but find-alive.pl still insists on a manually added class name,
forcing its users to add a colon: `find-alive.pl MemBlob:`.

We now accommodate both legacy/manual and modern/auto use cases.

2 weeks agoBug 5360: FwdState::noteDestinationsEnd() assertion "err" (#1767)
Alex Rousskov [Mon, 1 Apr 2024 02:53:39 +0000 (02:53 +0000)] 
Bug 5360: FwdState::noteDestinationsEnd() assertion "err" (#1767)

    FATAL: assertion failed: FwdState.cc:660: "err"

When FwdState decides to re-forward a request, it forgets the original
response[^1] but does not create an error object. Since commit e2bbd3b,
FwdState::noteDestinationsEnd() correctly assumed that we only idly wait
for additional destinations after encountering a problem, but
incorrectly asserted that past problems imply error object existence.

Now Squid generates an HTTP 502 (Bad Gateway) response while setting
%err_code/%err_detail to ERR_CANNOT_FORWARD/REFORWARD_TO_NONE.

TunnelStateData::noteDestinationsEnd() code is similar, but it probably
does not suffer from the same bug because an error object is created
before every retryOrBail() call, and there is no re-forwarding code that
forgets an HTTP error response without creating an error. Those
invariants are not well tracked, and this change mimics FwdState changes
in TunnelStateData just in case and to keep the two methods in sync. In
those hypothetical cases, ERR_CANNOT_FORWARD/RETRY_TO_NONE is logged.

[^1]: Long-term we probably want to preserve that original response so
that we do not have to replace it with a generated error, but doing so
requires significant refactoring and is outside this minimal fix scope.

3 weeks agoNoNewGlobals for Adaptation::Config::metaHeaders (#1747)
Francesco Chemolli [Thu, 28 Mar 2024 23:02:14 +0000 (23:02 +0000)] 
NoNewGlobals for Adaptation::Config::metaHeaders (#1747)

Detected by Coverity. CID 1554662: Initialization or destruction
ordering is unspecified (GLOBAL_INIT_ORDER).

3 weeks agoCI: Require source-maintenance.sh application before merging PRs (#1760)
Alex Rousskov [Wed, 27 Mar 2024 18:41:41 +0000 (18:41 +0000)] 
CI: Require source-maintenance.sh application before merging PRs (#1760)

By default, fixing PR-introduced code formatting problems should be that
PR responsibility. We did not enforced formatting because we did not
have CI automation to support that enforcement, and also because it was
tedious even for core developer to maintain the right astyle version.
Neither excuse remains valid these days.

In most development environments, it is not very difficult to install
Astyle v3.1 (and other Squid source maintenance tools). Our GitHub
Actions configuration file (.github/default.yaml) has a recipe. In
exceptional cases, including cases where a pull request was not
formatted because a different astyle version was installed, other
developers can (re)format PR sources (proactively or at author request).

Also fixed wrong error message when running source-maintenance.sh fails.

3 weeks agoRefactor portions of getCurrentTime() to use std::chrono (#1755)
Amos Jeffries [Tue, 26 Mar 2024 20:17:04 +0000 (20:17 +0000)] 
Refactor portions of getCurrentTime() to use std::chrono (#1755)

POSIX.1-2008 marks gettimeofday() as obsolete.

3 weeks agoSource Format Enforcement (#1759)
Alex Rousskov [Tue, 26 Mar 2024 17:58:07 +0000 (17:58 +0000)] 
Source Format Enforcement (#1759)

3 weeks agoMaintenance: Updated CONTRIBUTORS (#1758)
Alex Rousskov [Mon, 25 Mar 2024 20:24:52 +0000 (20:24 +0000)] 
Maintenance: Updated CONTRIBUTORS (#1758)

This change is a reference point for automated CONTRIBUTORS updates.

3 weeks agoHTTP: Protect just-parsed responses from accidental destruction (#1752)
Eduard Bagdasaryan [Sat, 23 Mar 2024 21:24:03 +0000 (21:24 +0000)] 
HTTP: Protect just-parsed responses from accidental destruction (#1752)

The lack of HttpReply locking meant that we could not (safely) pass the
freshly created reply object to ACLFilledChecklist because the checklist
destructor would unwittingly destroy the object (by unlocking it). There
is at least one applicable ACL check in handle1xx(), but we got lucky
because that method adds the reply object to ALE, increasing its
reference counter. This change stops relying on such "external" locks.

This change also protects from HttpReply memory leaks when an exception
is thrown between HttpReply creation and a setVirginReply() call.

TODO: Fix all cases where newly created HttpReply objects are remembered
using raw pointers (but may be passed to locking/unlocking code).

4 weeks agoMake BodyPipe::MaxCapacity constexpr (#1748)
Francesco Chemolli [Thu, 21 Mar 2024 05:43:10 +0000 (05:43 +0000)] 
Make BodyPipe::MaxCapacity constexpr (#1748)

Detected by Coverity. CID 1554661: Initialization or destruction
ordering is unspecified (GLOBAL_INIT_ORDER).

4 weeks agoNoNewGlobals for MapLabel (#1746)
Francesco Chemolli [Thu, 21 Mar 2024 02:22:37 +0000 (02:22 +0000)] 
NoNewGlobals for MapLabel (#1746)

Detected by Coverity. CID 1554668: Initialization or destruction
ordering is unspecified (GLOBAL_INIT_ORDER).

4 weeks agoNoNewGlobals for digestFieldsLookupTable (#1743)
Francesco Chemolli [Wed, 20 Mar 2024 22:59:46 +0000 (22:59 +0000)] 
NoNewGlobals for digestFieldsLookupTable (#1743)

Detected by Coverity. CID 1554677: Initialization or destruction
ordering is unspecified (GLOBAL_INIT_ORDER).

4 weeks agoMaintenance: rework SASL detection (#1694)
Francesco Chemolli [Wed, 20 Mar 2024 15:24:05 +0000 (15:24 +0000)] 
Maintenance: rework SASL detection (#1694)

MacOS Homebrew offers Cyrus SASL.

4 weeks agoNoNewGlobals: HttpUpgradeProtocolAccess::ProtoOther (#1745)
Francesco Chemolli [Tue, 19 Mar 2024 01:55:14 +0000 (01:55 +0000)] 
NoNewGlobals: HttpUpgradeProtocolAccess::ProtoOther (#1745)

Detected by Coverity. CID 1554674: Initialization or destruction
ordering is unspecified (GLOBAL_INIT_ORDER).

4 weeks agoMaintenance: update --with-ldap detection (#1736)
Amos Jeffries [Sun, 17 Mar 2024 20:13:13 +0000 (20:13 +0000)] 
Maintenance: update --with-ldap detection (#1736)

4 weeks agoDocs: Update CREDITS after code removals (#1741)
Amos Jeffries [Sat, 16 Mar 2024 10:56:54 +0000 (10:56 +0000)] 
Docs: Update CREDITS after code removals (#1741)

Commit eb9259b1a2f9b0a018cce8b692355969a92712df missed removing these
copyright declarations.

4 weeks agoConvert loadable_modules to SBufList (#1738)
Amos Jeffries [Fri, 15 Mar 2024 17:26:29 +0000 (17:26 +0000)] 
Convert loadable_modules to SBufList (#1738)

no behaviour changes.

5 weeks agoConvert hostname_aliases to SBufList (#1737)
Amos Jeffries [Fri, 15 Mar 2024 13:24:27 +0000 (13:24 +0000)] 
Convert hostname_aliases to SBufList (#1737)

Fix a bug where hostname_aliases was being
compared case-sensitively with HTTP request
Host / URL domain.

5 weeks agoMaintenance: update --with-xml2 detection (#1727)
Amos Jeffries [Fri, 15 Mar 2024 10:21:36 +0000 (10:21 +0000)] 
Maintenance: update --with-xml2 detection (#1727)

5 weeks agoMaintenance: update --with-expat detection (#1726)
Amos Jeffries [Wed, 13 Mar 2024 16:26:24 +0000 (16:26 +0000)] 
Maintenance: update --with-expat detection (#1726)

5 weeks agoESI: Disable by default (#1728)
Amos Jeffries [Wed, 13 Mar 2024 08:01:12 +0000 (08:01 +0000)] 
ESI: Disable by default (#1728)

5 weeks agoFix ./configure after strnstr() replacement removal (#1733)
Alex Rousskov [Tue, 12 Mar 2024 19:51:24 +0000 (19:51 +0000)] 
Fix ./configure after strnstr() replacement removal (#1733)

    configure: line 51104: SQUID_CHECK_FUNC_STRNSTR: command not found

The macro call should have been removed in recent commit 9d3433c.

5 weeks agoImplement iterator for wordlist (#1729)
Francesco Chemolli [Tue, 12 Mar 2024 15:08:26 +0000 (15:08 +0000)] 
Implement iterator for wordlist (#1729)

Also removed ToSBufList(): Unused since inception (2013 commit 6a17a36).

5 weeks agoImprove bounds checking in rfc1035NameUnpack (#1725)
Francesco Chemolli [Mon, 11 Mar 2024 12:06:41 +0000 (12:06 +0000)] 
Improve bounds checking in rfc1035NameUnpack (#1725)

Peter J. Philipp found an input buffer overread (by one byte) when
parsing certain malformed DNS responses. Add the missing check.

Co-authored-by: Peter J. Philipp <pbug44@delphinusdns.org>
5 weeks agoFix error: template-id not allowed for constructor in C++20 (#1731)
Amos Jeffries [Sun, 10 Mar 2024 20:16:22 +0000 (20:16 +0000)] 
Fix error: template-id not allowed for constructor in C++20 (#1731)

6 weeks agoDe-duplicate I/O error-detailing code (#1723)
Eduard Bagdasaryan [Fri, 8 Mar 2024 06:03:20 +0000 (06:03 +0000)] 
De-duplicate I/O error-detailing code (#1723)

This improvement eliminates code duplication introduced
in recent commit b850f8b.

6 weeks agoMaintenance: update --with-cap detection (#1718)
Amos Jeffries [Thu, 7 Mar 2024 09:55:50 +0000 (09:55 +0000)] 
Maintenance: update --with-cap detection (#1718)

6 weeks agoMaintenance: update --with-netfilter-conntrack detection (#1717)
Amos Jeffries [Wed, 6 Mar 2024 13:51:58 +0000 (13:51 +0000)] 
Maintenance: update --with-netfilter-conntrack detection (#1717)

Fixes pollution of global LIBS, LDFLAGS and CPPFLAGS
when the library and required headers are not
detected as usable.

6 weeks agomkrelease: ensure creation of translation: (#1716)
Francesco Chemolli [Wed, 6 Mar 2024 05:32:03 +0000 (05:32 +0000)] 
mkrelease: ensure creation of translation: (#1716)

Ensure presence of needed packages for release automation

6 weeks agoRemove unused strnstr() replacement (#1721)
Amos Jeffries [Tue, 5 Mar 2024 15:12:24 +0000 (15:12 +0000)] 
Remove unused strnstr() replacement (#1721)

Squid code does not actually use strnstr() so this copy of FreeBSD
code does not need to be shipped.

6 weeks agonegotiate_kerberos_auth: Support Kerberos PAC-ResourceGroups (#1597)
ankor2023 [Tue, 5 Mar 2024 11:13:19 +0000 (11:13 +0000)] 
negotiate_kerberos_auth: Support Kerberos PAC-ResourceGroups (#1597)

Parse the ResourceGroupIds pac-data structure to have information
about the user's membership in AD Domain Local groups.

Previously, the helper obtained user groups information only from
GroupIds and ExtraSids pac-data structures (of the
KERB_VALIDATION_INFO structure).
The patch extends the functionality of the helper.
Now it additionally parse the ResourceGroupIds pac-data structure
where Domain Local AD-group rids are located.
It appends these groups to the the list generated by parsing
GroupIds and ExtraSids.
No changes in existing helper deployments are required.

The new parsing functions are similar to those already used for
parsing GroupIds and ExtraSids.

6 weeks agoUse ERR_READ_ERROR for read-from-client I/O errors (#1720)
Eduard Bagdasaryan [Mon, 4 Mar 2024 18:37:22 +0000 (18:37 +0000)] 
Use ERR_READ_ERROR for read-from-client I/O errors (#1720)

ERR_CLIENT_GONE is still used for unexpected zero-size reads on
client-to-Squid connections. The two cases are now distinct.

6 weeks agoMaintenance: update --with-systemd detection (#1715)
Amos Jeffries [Mon, 4 Mar 2024 10:45:23 +0000 (10:45 +0000)] 
Maintenance: update --with-systemd detection (#1715)

Drop support for obsolete systemd v209 and older.

6 weeks agoMaintenance: update --with-mit-krb5 detection (#1709)
Amos Jeffries [Sun, 3 Mar 2024 13:24:30 +0000 (13:24 +0000)] 
Maintenance: update --with-mit-krb5 detection (#1709)

7 weeks agoBug 5069: Keep listening after getsockname() error (#1713)
Alex Rousskov [Fri, 1 Mar 2024 22:20:20 +0000 (22:20 +0000)] 
Bug 5069: Keep listening after getsockname() error (#1713)

    ERROR: Stopped accepting connections:
    error: getsockname() failed to locate local-IP on ...

In many cases, these failures are intermittent client-triggered errors
(e.g., client shut down the accepted socket); Squid will successfully
accept other connections and, hence, should keep listening for them.

7 weeks agoMaintenance: Use SQUID_CHECK_LIB_WORKS for PSAPI.dll detection (#1686)
Amos Jeffries [Fri, 1 Mar 2024 01:53:49 +0000 (01:53 +0000)] 
Maintenance: Use SQUID_CHECK_LIB_WORKS for PSAPI.dll detection (#1686)

Fixes an old bug with psapi.h detection not properly setting
HAVE_PSAPI_H.

7 weeks agoMaintenance: update --with-nettle detection (#1708)
Amos Jeffries [Thu, 29 Feb 2024 05:11:03 +0000 (05:11 +0000)] 
Maintenance: update --with-nettle detection (#1708)

Update to latest pkg-config requirement and
usage style.

Fix bug with header detect when library is
located in a custom location.

Drop outdated base64 API compatability check
not needed with Nettle 3.4 or later.

7 weeks agoFix Controller.cc TheRoot assertion during shutdown (#1707)
Alex Rousskov [Wed, 28 Feb 2024 19:27:15 +0000 (19:27 +0000)] 
Fix Controller.cc TheRoot assertion during shutdown (#1707)

    FATAL: assertion failed: Controller.cc:933: "TheRoot"

Store is an essential service, used by a lot of Squid code. As was
already established in 2022 commit 23b7963, this service should be
available during shutdown. That commit correctly removed explicit Store
service termination, but missed the fact that the reference-counting
TheRoot pointer (that provides access to the Store Controller singleton)
gets _automatically_ destroyed during C++ cleanup. This change removes
TheRoot reference counting, making that Controller singleton immortal.

Squid asserted when exiting with active entries in the shared memory
cache because TheRoot destruction leads to Controller destruction,
Controller destructor cleans up cache index, and that cleanup code may
result in calls to Store::Root() that dereferences destroyed TheRoot.

These assertions were seen when Squid was shutdown cleanly (e.g., using
SIGTERM) and when a kid process was exiting due to a fatal() error.

Making Store::Controller singleton immortal means that the class
destructor is never called. Fortunately, the destructor did nothing
particularly useful; Store flushing is performed by Controller::sync()
which is explicitly called during early stages of clean shutdown. The
now-unused destructor code was removed: Implementing this destructor in
a meaningful way (while avoiding accessing a being-destructed global
Store!) requires heroic efforts (which would be wasted since the
destructor is never actually called).

Also made Store Controller singleton available on the first use,
complying with Store's "essential, widely used service" status and
removing the need for an explicit Store::Init(void) call.

Also removed unit tests that required support for dynamic replacement of
Store Controller singleton. The minuscule value of the removed tests did
not justify the costs of supporting a replaceable Store Controller.

Also removed Store::FreeMemory(). Its implementation contradicted Store
status as an essential service. The function was only used by unit
tests, and its removal addresses the corresponding commit 23b7963 TODO.

7 weeks agoMaintenance: update --with-gnutls detection (#1685)
Amos Jeffries [Wed, 28 Feb 2024 13:01:02 +0000 (13:01 +0000)] 
Maintenance: update --with-gnutls detection (#1685)

Simplify the SQUID_CHECK_LIB_WORKS(gnutls,...) logic
to use all the latest abilities of that macro

7 weeks agoPortability: use printf(1) instead of echo -n (#1676)
Francesco Chemolli [Wed, 28 Feb 2024 03:37:39 +0000 (03:37 +0000)] 
Portability: use printf(1) instead of echo -n (#1676)

MacOS' implementation of echo(1) does not support the -n flag.

7 weeks agoMaintenance: update --with-heimdal-krb5 detection (#1687)
Amos Jeffries [Mon, 26 Feb 2024 03:42:35 +0000 (03:42 +0000)] 
Maintenance: update --with-heimdal-krb5 detection (#1687)

7 weeks agoMaintenance: increase portability of cf_gen automake rules (#1696)
Francesco Chemolli [Sat, 24 Feb 2024 12:37:05 +0000 (12:37 +0000)] 
Maintenance: increase portability of cf_gen automake rules (#1696)

The MacOS linker uses a subdirectory named [target].dSYM to hold debug
information. Ensure it is removed by 'make clean'.

7 weeks agoDocumentation: Update Programming Guide title (#1699)
Amos Jeffries [Fri, 23 Feb 2024 21:12:23 +0000 (21:12 +0000)] 
Documentation: Update Programming Guide title (#1699)

8 weeks agoRename --with-gnugss to --with-gss (#1688)
Amos Jeffries [Fri, 23 Feb 2024 17:53:14 +0000 (17:53 +0000)] 
Rename --with-gnugss to --with-gss (#1688)

Updating the library detection to use pkg-config and
bringing relevant macros up to current style.

8 weeks agonegotiate_wrapper: Do not use vfork() (#1697)
Francesco Chemolli [Fri, 23 Feb 2024 14:35:53 +0000 (14:35 +0000)] 
negotiate_wrapper: Do not use vfork() (#1697)

POSIX.1-2001 marks vfork(2) OBSOLETE.
POSIX.1-2008 removes the specification of vfork(2).
MacOS system headers declare vfork(2) as deprecated.
We only use vfork(2) in negotiate_wrapper, where it is not necessary.

8 weeks agoFix detection of cppunit (#1695)
Francesco Chemolli [Fri, 23 Feb 2024 11:25:11 +0000 (11:25 +0000)] 
Fix detection of cppunit (#1695)

On MacOS / Homebrew, libcppunit is not part of the system path.
pkg-config will report it; use it.

This change also ensures squid honours the promise made
in configure's help text to let administrators specify a
LIBCPPUNIT_LIBS environment variable to
override automatic detection

8 weeks agoFix misleading Dns::CachedIps::restoreGoodness() debugging (#1692)
Alex Rousskov [Fri, 23 Feb 2024 08:01:52 +0000 (08:01 +0000)] 
Fix misleading Dns::CachedIps::restoreGoodness() debugging (#1692)

8 weeks agoFix marking of problematic cached IP addresses (#1691)
Alex Rousskov [Fri, 23 Feb 2024 04:26:38 +0000 (04:26 +0000)] 
Fix marking of problematic cached IP addresses (#1691)

Since inception in 2017 commit fd9c47d, Dns::CachedIps::have() always
returned position zero after finding a matching IP address (at zero or
positive position). The bug affected two callers:

* markAsBad() always marked the first stored address (as bad);
* forgetMarking() always cleared the first stored address marking.

Buggy markings led to Squid sometimes not attempting to use a working
address (e.g., IPv4) while using a known problematic one (e.g., IPv6).

8 weeks agoImplement default Auth::UserRequest::authenticated() (#1679)
Francesco Chemolli [Fri, 23 Feb 2024 00:55:30 +0000 (00:55 +0000)] 
Implement default Auth::UserRequest::authenticated() (#1679)

8 weeks agoMaintenance: Remove Red Hat Linux workarounds predating RHEL (#1698)
Francesco Chemolli [Thu, 22 Feb 2024 09:24:10 +0000 (09:24 +0000)] 
Maintenance: Remove Red Hat Linux workarounds predating RHEL (#1698)

The last Red Hat Linux release went EOL in 2004, replaced by Red Hat
Enterprise Linux and Fedora Linux. We no longer support Red Hat Linux
releases and expect that these hacks are no longer necessary in
supported environments.

8 weeks agoMacOS compat: properly detect sasl2 (#1693)
Francesco Chemolli [Wed, 21 Feb 2024 10:23:33 +0000 (10:23 +0000)] 
MacOS compat: properly detect sasl2 (#1693)

On MacOS, squid_host_os is lowercase "darwin".

8 weeks agosquid-conf-tests: Ignore tests with mismatching autoconf macro (#1648)
Eduard Bagdasaryan [Mon, 19 Feb 2024 11:09:23 +0000 (11:09 +0000)] 
squid-conf-tests: Ignore tests with mismatching autoconf macro (#1648)

The 'skip-unless-autoconf-defines' directive should be able to
distinguish autoconf macro values, such as '0' (not defined) from '1'
(defined) ones.  For example, --disable-ipv6 configuration option
defines USE_IPV6 as '0'. This change allows IPv6 tests activation,
addressing a TODO.

8 weeks agoUpdate SQUID_CHECK_LIB_WORKS (#1684)
Amos Jeffries [Mon, 19 Feb 2024 02:29:46 +0000 (02:29 +0000)] 
Update SQUID_CHECK_LIB_WORKS (#1684)

When the checked library is found to be working:
 * Define ENABLE_LIBFOO for automake use.
 * Define HAVE_LIBFOO for code use.

2 months agoFix debugging for responses that Expire at check time (#1683)
Alex Rousskov [Sun, 18 Feb 2024 00:45:41 +0000 (00:45 +0000)] 
Fix debugging for responses that Expire at check time (#1683)

Since 2000 commit 65fa5c6, our level-3 debugging mislead about Expires
being less than the check time when the two times were identical. The
actual checked conditions are correct: Roughly speaking, the response
with Expires value T is considered expired at that time T.

Also dropped extra (and inconsistent) trailing space on debugs() lines.
This space was added by the same 2000 commit, probably accidentally.

2 months agoMaintenance: Removed unused bits of Format::FmtConfig code (#1681)
Alex Rousskov [Fri, 16 Feb 2024 13:02:54 +0000 (13:02 +0000)] 
Maintenance: Removed unused bits of Format::FmtConfig code (#1681)

This code was probably accidentally copied from Log::LogConfig when
FmtConfig was created in 2011 commit 31971e6. It mentions logfile_format
directive that never existed. The code also duplicates a dangerous
Log::LogConfig snippet (see Bug 5344).

2 months agoBug 5344: mgr:config segfaults without logformat (#1680)
Alex Rousskov [Fri, 16 Feb 2024 04:03:40 +0000 (04:03 +0000)] 
Bug 5344: mgr:config segfaults without logformat (#1680)

Since 2011 commit 38e16f9, Log::LogConfig::dumpFormats() dereferenced a
nil `logformats` pointer while reporting a non-existent logformat
configuration (e.g., squid.conf.default): `logformats->dump(e, name)`.

In most environments, that code "worked" because the corresponding
Format::Format::dump() method happens to do nothing if "this" is nil.
However, in some environments, Squid segfaulted.

2 months agoRemove unnecessary C linkage and unused code (#1677)
Francesco Chemolli [Thu, 15 Feb 2024 13:24:21 +0000 (13:24 +0000)] 
Remove unnecessary C linkage and unused code (#1677)

Also upgrade lib/util.c to C++.

2 months agoBug 5343: Fix remaining GCC v14 build issues (#1673)
Amos Jeffries [Wed, 14 Feb 2024 04:53:11 +0000 (04:53 +0000)] 
Bug 5343: Fix remaining GCC v14 build issues (#1673)

2 months agoMinGW-w64: enable native file locking (#1358)
Amos Jeffries [Tue, 13 Feb 2024 20:26:47 +0000 (20:26 +0000)] 
MinGW-w64: enable native file locking (#1358)

flock() and related API symbols are not defined by MinGW.

2 months agoBug 5343: Fix GCC v14 not finding std::find() (#1672)
Francesco Chemolli [Tue, 13 Feb 2024 11:14:02 +0000 (11:14 +0000)] 
Bug 5343: Fix GCC v14 not finding std::find() (#1672)

    Reply.cc:198: error: no matching function for call to find(...)

The required STL header was missed in 2023 commit 27c3677.

2 months agoFix MemObject.cc:123: "!updatedReply_" assertion (#1666)
Alex Rousskov [Sat, 10 Feb 2024 20:03:14 +0000 (20:03 +0000)] 
Fix MemObject.cc:123: "!updatedReply_" assertion (#1666)

    MemStore.cc(506) copyFromShm: entry 1284 copied ...
    FATAL: assertion failed: MemObject.cc:123: "!updatedReply_"

The code loading a response from the shared memory cache incorrectly
assumed that the being-loaded response could not have been updated by an
HTTP 304 (Not Modified) reply and called adjustableBaseReply() that is
banned for updated responses. The goal of that call was to determine
whether the cached response header has been parsed. That determination
can be made without using a method that is banned for updated responses.

StoreClient and clientReplyContext had very similar checks that used the
right/safe approach because their current code did not need an immediate
access to an "adjustable" response. We have updated all external
psParsed checks to reduce chances that this bug resurfaces.

2 months agoFix max-stale in default refresh_pattern (#1664)
Alex Rousskov [Thu, 8 Feb 2024 22:03:44 +0000 (22:03 +0000)] 
Fix max-stale in default refresh_pattern (#1664)

RefreshPattern constructor must set data fields to honor refresh_pattern
defaults promised in squid.conf.documented. For max-stale, that implies
making max_stale negative. A negative value allows refreshCheck() to use
a max_stale directive value (i.e. Config.maxStale that defaults to 1
week). The buggy constructor set max_stale to 0 instead and, hence,
refreshCheck() ignored max_stale directive when no refresh_pattern rules
were configured.

The fixed bug did not affect Squids configured using explicit
refresh_pattern rules because those rules are handled by
parse_refreshpattern() which sets max_stale to -1 by default. Our
squid.conf.default does have explicit refresh_pattern rules.

2 months agonegotiate_kerberos_auth: Do not prohibit all LDFLAGS (#1663)
Amos Jeffries [Thu, 8 Feb 2024 14:20:11 +0000 (14:20 +0000)] 
negotiate_kerberos_auth: Do not prohibit all LDFLAGS (#1663)

2 months agoUse AnyP::Uri::Decode() for urllogin checks (#1659)
Francesco Chemolli [Wed, 7 Feb 2024 14:19:28 +0000 (14:19 +0000)] 
Use AnyP::Uri::Decode() for urllogin checks (#1659)

2 months agoMaintenance: Detect mismatching .instructions files (#1661)
Eduard Bagdasaryan [Sun, 4 Feb 2024 03:20:04 +0000 (03:20 +0000)] 
Maintenance: Detect mismatching .instructions files (#1661)

2 months agoUse AnyP::Uri::Decode() for url_regex checks (#1658)
Francesco Chemolli [Fri, 2 Feb 2024 13:35:39 +0000 (13:35 +0000)] 
Use AnyP::Uri::Decode() for url_regex checks (#1658)

2 months agoExtra v6.7 ChangeLog addition (#1657)
Francesco Chemolli [Thu, 1 Feb 2024 13:27:04 +0000 (13:27 +0000)] 
Extra v6.7 ChangeLog addition (#1657)

2 months agoThrow, not self_destruct(), on qos_flow configuration errors (#1644)
Alexey [Thu, 1 Feb 2024 09:37:30 +0000 (09:37 +0000)] 
Throw, not self_destruct(), on qos_flow configuration errors (#1644)

2 months agoBug 5337: workaround for crash on startup if -a option is used (#1653)
Francesco Chemolli [Thu, 1 Feb 2024 06:05:40 +0000 (06:05 +0000)] 
Bug 5337: workaround for crash on startup if -a option is used (#1653)

Interpreting command-line arguments requires AnyP::UriScheme to be fully
initialized. Initialize AnyP::UriScheme earlier to ensure that happens.

2 months agoDocumentation: update release notes after PR 1632 (#1652)
Amos Jeffries [Thu, 1 Feb 2024 02:25:01 +0000 (02:25 +0000)] 
Documentation: update release notes after PR 1632 (#1652)

2 months agoMaintenance: automate header guards (#1630)
Francesco Chemolli [Wed, 31 Jan 2024 22:02:44 +0000 (22:02 +0000)] 
Maintenance: automate header guards (#1630)

Add a source-maintenance plugin to maintain a
header guard standard defined as SQUID_FILE_PATH_H.

2 months agoAdd AnyP::Uri::Decode() (#1626)
Francesco Chemolli [Wed, 31 Jan 2024 18:21:13 +0000 (18:21 +0000)] 
Add AnyP::Uri::Decode() (#1626)

Implement percent-decoding according to RFC 3986. Currently unused.
TODO: Upgrade rfc1738_unescape() callers.

2 months agoMaintenance: automate header guards 2/3 (#1655)
Francesco Chemolli [Wed, 31 Jan 2024 05:54:05 +0000 (05:54 +0000)] 
Maintenance: automate header guards 2/3 (#1655)

In preparation for merging the automated header-guards maintenance
script, merge the changes brought by that script.

2 months agoFix a possible integer overflow in Ftp::Gateway (#1647)
Štěpán Brož [Tue, 30 Jan 2024 21:35:37 +0000 (21:35 +0000)] 
Fix a possible integer overflow in Ftp::Gateway (#1647)

A static analysis tool has discovered that const int csize,
might have overflowed before being passed to writeReplyBody().

2 months agoChangeLog for v6.7 (#1646)
Francesco Chemolli [Tue, 30 Jan 2024 18:20:54 +0000 (18:20 +0000)] 
ChangeLog for v6.7 (#1646)

2 months agoMaintenance: automate header guards 1/3 (#1654)
Francesco Chemolli [Tue, 30 Jan 2024 09:24:14 +0000 (09:24 +0000)] 
Maintenance: automate header guards 1/3 (#1654)

In preparation for merging the automated header-guards maintenance
script, merge the manual changes required for that script to succeed.

2 months agoFix memory leak in ssl/gadgets/mimicAuthorityKeyId() (#1651)
Alexey [Mon, 29 Jan 2024 19:47:41 +0000 (19:47 +0000)] 
Fix memory leak in ssl/gadgets/mimicAuthorityKeyId() (#1651)

An unnecessary std::unique_ptr::release() call prevented temporary
extOct string from being automatically deallocated. The leak usually
happened when SslBump mimicked certificates with an Authority Key
Identifier extension. The leak was added in 2016 commit 5f1318b.

2 months agoRemove AclMatchedName from ACL::ParseAclLine() (#1642)
Alex Rousskov [Sun, 28 Jan 2024 09:51:37 +0000 (09:51 +0000)] 
Remove AclMatchedName from ACL::ParseAclLine() (#1642)

ACL parsing code needs to know the aclname parameter of the being-parsed
acl directive to report various errors. Most admins recognize their ACLs
by these names so reporting aclnames improves UX. Since before 1999
commit b6a2f15, Squid used a "temporary" and "ugly" trick that supplied
aclname via the unrelated global variable called AclMatchedName (which
has its own set of problems). Some ACL parsing code used AclMatchedName
in cache.log messages, but most ACL-related problems were still reported
without that information.

Passing ACL::name to each parsing-related function via an extra
parameter is not just ugly but impractical because some the low-level
parsing functions should not really know about ACLs. Instead, we reuse
existing CodeContext mechanism to report parsing context information (in
this case -- aclname).

We plan to enhance parsing context to cover directives other than "acl"
(without modifying every directive parser, of course), but this first
small step significantly reduces configuration code exposure to
AclMatchedName, unblocking ACL-related smooth reconfiguration
improvements.

2 months agoEmulate fsync on mingw (#1650)
Francesco Chemolli [Thu, 25 Jan 2024 13:48:35 +0000 (13:48 +0000)] 
Emulate fsync on mingw (#1650)

MS Windows (and mingw) do not offer fsync(),
but they offer the API-compatible _commit().

2 months agoTranslation: Drop deprecated language links (#1643)
Amos Jeffries [Tue, 23 Jan 2024 22:03:43 +0000 (22:03 +0000)] 
Translation: Drop deprecated language links (#1643)

Support for full-name languages has been deprecated since
Squid-3.1 it is long overdue to remove these symlinks and
simplify the default install footprint.

2 months agoNTLM/Negotiate: Fix crash on bad helper TT responses (#1645)
Alexey [Sun, 21 Jan 2024 16:24:57 +0000 (16:24 +0000)] 
NTLM/Negotiate: Fix crash on bad helper TT responses (#1645)

Helper lookup may be made without a client HTTP Request,
(stored in lm_request->request). But in Helper::TT cases the
lm_request->request was dereferenced without any checks.

3 months agoExtend cache_log_message to Bug 5187 and job invalidation BUGs (#1639)
Shmaya [Tue, 16 Jan 2024 20:51:43 +0000 (20:51 +0000)] 
Extend cache_log_message to Bug 5187 and job invalidation BUGs (#1639)

    70 ERROR: Squid BUG: Job invalidated during ... that threw...
    71 ERROR: Squid BUG: Job invalidated during ...
    72 WARNING: Squid bug 5187 workaround triggered

3 months agobasic_sspi_auth: Fix build on Windows with libnettle (#1640)
Francesco Chemolli [Tue, 16 Jan 2024 11:13:24 +0000 (11:13 +0000)] 
basic_sspi_auth: Fix build on Windows with libnettle (#1640)

Our detection logic relies on nettle's base64 decoding, if available.
Add libnettle to the basic/SSPI helper when libnettle is available.

3 months agoAvoid file name conflict with Windows WinSvc.h (#1637)
Francesco Chemolli [Mon, 15 Jan 2024 10:17:42 +0000 (10:17 +0000)] 
Avoid file name conflict with Windows WinSvc.h (#1637)

There is a conflict between our WinSvc.h header file and
Windows system include <winsvc.h>, which is one of the
factors preventing our ability to build native windows helpers.

3 months agoMaintenance: remove unused asnAclInitialize declaration (#1633)
Francesco Chemolli [Sat, 13 Jan 2024 22:10:36 +0000 (22:10 +0000)] 
Maintenance: remove unused asnAclInitialize declaration (#1633)