]> git.ipfire.org Git - thirdparty/squid.git/log
thirdparty/squid.git
9 years agoFix delay pool DeferredRead in HttpStateData
Amos Jeffries [Thu, 13 Nov 2014 12:09:11 +0000 (04:09 -0800)] 
Fix delay pool DeferredRead in HttpStateData

The deferred read action may have been delayed so long the read(2) is no
longer possible. It needs to restart from watching the socket instead of
just from performing read(2). This re-adds part of the latency when
delaying traffic but we retain the bytesWanted() speed up so not a big
loss.

9 years agoUse Http1::ResponseParser to process HTTP server responses
Amos Jeffries [Wed, 12 Nov 2014 11:48:07 +0000 (03:48 -0800)] 
Use Http1::ResponseParser to process HTTP server responses

Integrate the Http1::ResponseParser with HttpStateData to parse server
response buffer content.

Fixes one performance regression copying the entire mesage header
block from SBuf to String.

Adds a few much smaller performance regressions, data-copying the
reason phrase and status line details.

Update the EOF \r\n hack:
* move the hack from read(2) handler to depend on parse results.
* make the append operation only be performed if the header actually is
  missing the terminator sequence.
* extend to append two CRLF pairs so Squid can now process truncated
  header blocks.

9 years agoFix Http1::ResponseParser
Amos Jeffries [Wed, 12 Nov 2014 11:35:18 +0000 (03:35 -0800)] 
Fix Http1::ResponseParser

Fix detection of status code in status-line. The Tokenizer::prefix()
method with byte-limited scan needs to be passed a limit large enough to
include the terminator byte for the field.

Add missing logic to transform HTTP/0.9 response syntax to HTTP/1.1
mime header block.

Add additional debugging messages to trace parse operations.

9 years agoConvert HttpStateData (aka. Http::Client) response buffer to use SBuf
Amos Jeffries [Tue, 11 Nov 2014 13:55:41 +0000 (05:55 -0800)] 
Convert HttpStateData (aka. Http::Client) response buffer to use SBuf

This replaces the MemBuf used to receive server responses with an SBuf in
preparation for use by an Http1::ResponseParser.

As part of this convert the I/O read processing to Comm::Read / ReadNow
API with read(2) operation happening in the read handler instead of
buried in the comm code. A side effect of this is detaching the read
operation from StoreEntry::delayAwareRead().

Two temporary performance regressions are necessarily introduced with
these changes:
* The worst is a data copy from SBuf input buffer to a temporary MemBuf
  so that the chunked body decoder can process the content. This will
  only be able to be removed when teh chunked decoder is itself converted
  to process an SBuf.

* Also, until the new Http1::ResponseParser is implemented we need to
  copy the response header contents into a temporary MemBuf for the old
  HttpReply::parse() method to process.

9 years agoExtend Client API to estimate needed buffer space using an SBuf
Amos Jeffries [Tue, 11 Nov 2014 13:41:59 +0000 (05:41 -0800)] 
Extend Client API to estimate needed buffer space using an SBuf

Add Client::needBufferSpace() API method to estimate reuired buffer
space based on an SBuf buffer.

Deprecate the badly named Client::replyBodySpace() method and MemBuf API
for server connection I/O.

9 years agoAllow limiting of read(2) operations in SBuf I/O API
Amos Jeffries [Tue, 11 Nov 2014 13:37:41 +0000 (05:37 -0800)] 
Allow limiting of read(2) operations in SBuf I/O API

If params.size is non-zero limit size of the read to either the buffer
free space or params.size, whichever is smallest.

9 years agoAdd HTTP Response parser
Amos Jeffries [Sun, 9 Nov 2014 15:02:19 +0000 (07:02 -0800)] 
Add HTTP Response parser

9 years agoParser-NG: HTTP Parser structural redesign
Amos Jeffries [Fri, 7 Nov 2014 08:41:47 +0000 (00:41 -0800)] 
Parser-NG: HTTP Parser structural redesign

This update is to lay the groundwork for several planned future projects
implementing protocol specific parsers, seperating the currently
intertwinned client connection management and HTTP protocol parsing
logics, and for zero-copy processing of transactions using SBuf.

This patch renames the HttpParser class as RequestParser and moves it
into the Http::One:: namespace as child of an Http::Parser class with
generic API accessors for shared use by other HTTP message parsers.

The class API
 - is updated to process both the request-line and HTTP mime headers,
returning an incomplete parse result until the entire headers parts of
the message have been received.
 - now contains accessor methods for retrieving the method, URI,
protocol, mime headers block (as an SBuf) and some metrics about those.
 - the old request_offsets structure and similar offset details are no
longer exposed.
 - now emits 414 and 431 HTTP status codes as appropriate.

The parser is made partially incremental and some use of Tokenizer is
added for faster parsing. There is more that can be done to further
speed up parsing of slow or very large requests.

Much of the code from client_side.cc parseHttpRequest() and also the
header-field code from mime_headers.cc has been moved into the parser
class. The client_side.cc code now simply runs the main
Http1::RequestParser::parse() method then uses accessors to retrieve
and process the parse results.

A unit test for incremental parsing has been added to testHttpParser.

Also, the HttpRequestMethod class is moved into the Http:: namespace and
library to reduce dependencies on the parser class outside the library.

The gains made so far from incremental parse, reducing parser passes and
zero-copy SBuf are offset by several temporary performance regressions
added converting SBuf for legacy code use. These are marked for later
removal.

9 years agoFix two build errors in ufsdump
Amos Jeffries [Fri, 7 Nov 2014 08:37:45 +0000 (00:37 -0800)] 
Fix two build errors in ufsdump

9 years agoMerge from trunk rev.13687
Amos Jeffries [Wed, 5 Nov 2014 10:18:15 +0000 (02:18 -0800)] 
Merge from trunk rev.13687

9 years agoFix missed Peer Digest update in rev.13684
Amos Jeffries [Wed, 5 Nov 2014 04:09:20 +0000 (20:09 -0800)] 
Fix missed Peer Digest update in rev.13684

9 years agosquidclient: Fix display errors in man(1) page
Amos Jeffries [Tue, 4 Nov 2014 14:39:14 +0000 (06:39 -0800)] 
squidclient: Fix display errors in man(1) page

9 years agoRelease Notes: URI updates for 3.5
Amos Jeffries [Tue, 4 Nov 2014 14:23:42 +0000 (06:23 -0800)] 
Release Notes: URI updates for 3.5

9 years agoBug 1961 part 2: redesign of URL handling.
Amos Jeffries [Tue, 4 Nov 2014 08:47:03 +0000 (00:47 -0800)] 
Bug 1961 part 2: redesign of URL handling.

Move the HttpRequest::login detail into class URL. Renaming to userInfo
as per the RFC 3986 defined name for this URI piece.

Convert the details to SBuf gaining several minor str*() removals in
the process and a simpler FTP login parser based on SBuf capabilities.

Also, updated the base64 encoder API used for converting between URI
userInfo and Basic authentication header token. Gaining better control
over the length of maximum token size and a small speedup from pre-known
input length.

9 years agoFix rev.13668 strdup uses and removes the safe_free
Markus Moeller [Mon, 3 Nov 2014 03:42:31 +0000 (19:42 -0800)] 
Fix rev.13668 strdup uses and removes the safe_free

* use xstrdup() instead of strdup()

* replace safe_free() which should be just a setting to NULL.

9 years agoFix stub changes missed in rev.13680
Amos Jeffries [Mon, 3 Nov 2014 01:10:23 +0000 (17:10 -0800)] 
Fix stub changes missed in rev.13680

9 years agoSourceLayout: shuffle CbDataList to libbase
Amos Jeffries [Sun, 2 Nov 2014 05:51:22 +0000 (22:51 -0700)] 
SourceLayout: shuffle CbDataList to libbase

Fixing a layering violation between include/ and src/cbdata.h

9 years agoCleanup: Simplify CBDATA API and rename CBDATA_CLASS
Amos Jeffries [Sun, 2 Nov 2014 00:10:01 +0000 (17:10 -0700)] 
Cleanup: Simplify CBDATA API and rename CBDATA_CLASS

There are no logic changes here.

* Rename CBDATA_CLASS2() to CBDATA_CLASS()

* Remove cbdata*Dbg() duplicate interface for CBDATA.
  Inline it with the CBDATA_CLASS() API

* update public:/private: class section handling in CBDATA_CLASS() and
  place all uses at the top of class definition as with MEMPROXY_CLASS()
  and typedef coding style.
 - this highlights TunnelStateData API as previously broken in regards
   to private members. Leave it public: for now with TODO on fixing.

9 years agoDocs: Add man(8) page for helper-mux tool
Amos Jeffries [Sat, 1 Nov 2014 05:04:05 +0000 (22:04 -0700)] 
Docs: Add man(8) page for helper-mux tool

Convert the helper-mux.pl.README to inlineperl docs and generate a man(8)
page using pod2man when possible.

Also, shuffle the tool into a sub-directory of its own for easier build
management.

Also, add a automake conditional ENABLE_POD2MAN_DOC to allow optional
build of perl tools or helpers without depending on pod2man which is
only necessary for the documentation.

9 years agoDocs: convert purge tool README to man.1 page
antiago Garcia Mantinan [Sat, 1 Nov 2014 00:43:23 +0000 (17:43 -0700)] 
Docs: convert purge tool README to man.1 page

Initial conversion performed by Santiago Garcia Mantinan of Debian.

With po4a adjustments by Amos Jeffries.

9 years agoPrep for 3.5.0.2 and 3.4.9
Amos Jeffries [Fri, 31 Oct 2014 08:19:44 +0000 (01:19 -0700)] 
Prep for 3.5.0.2 and 3.4.9

9 years agoFix man(8)/man(1) page syntax
Amos Jeffries [Fri, 31 Oct 2014 08:02:57 +0000 (01:02 -0700)] 
Fix man(8)/man(1) page syntax

It seems automated tools such as lroff are not able to parse the groff
syntax accurately for automated indexing of our man pages.

The if-conditional syntax was only used to simplify translators lives
so we can live with the tools preferred 1-liner syntax for the NAME
section.

9 years agoSource Maintenance: bump astyle version to 2.03
Amos Jeffries [Thu, 30 Oct 2014 15:32:34 +0000 (08:32 -0700)] 
Source Maintenance: bump astyle version to 2.03

9 years agoSourceFormat Enforcement
squidadm@squid-cache.org [Thu, 30 Oct 2014 15:27:19 +0000 (15:27 +0000)] 
SourceFormat Enforcement

9 years agoFix: Unable to open FTP socket during reconfigure
Christos Tsantilas [Thu, 30 Oct 2014 15:18:20 +0000 (17:18 +0200)] 
Fix: Unable to open FTP socket during reconfigure

Squid does not close FTP listening ports on reconfigure.

9 years agoBoilerplate: add copyright blurb to auto-generated files and release notes
Amos Jeffries [Thu, 30 Oct 2014 11:48:18 +0000 (04:48 -0700)] 
Boilerplate: add copyright blurb to auto-generated files and release notes

9 years agoSource Maintenance: Add checks for copyright blurbs
Amos Jeffries [Thu, 30 Oct 2014 11:32:29 +0000 (04:32 -0700)] 
Source Maintenance: Add checks for copyright blurbs

* Check for copyright blurbs in repository files.

* Allow skipping of third-party and binary files.

* Add copyright blurb to auto-generated files created by maintenance
  script.

9 years agoFix typo in 3.4 release notes
Amos Jeffries [Thu, 30 Oct 2014 04:39:02 +0000 (21:39 -0700)] 
Fix typo in 3.4 release notes

9 years agoBoilerplate: add copyright blurbs on more files
Amos Jeffries [Thu, 30 Oct 2014 03:23:47 +0000 (20:23 -0700)] 
Boilerplate: add copyright blurbs on more files

9 years agoext_kerberos_ldap_group_acl: -n option to disable automated SASL/GSSAPI
Markus Moeller [Wed, 29 Oct 2014 04:47:53 +0000 (21:47 -0700)] 
ext_kerberos_ldap_group_acl: -n option to disable automated SASL/GSSAPI

The -n option disables the automated Kerberos authentication
(SASL/GSSAPI) to AD and requires username/password (SASL/SIMPLE)
instead.

Also, improvements in caching Kerberos credentials for setup with low
Squid cache TTL.

9 years agonegotiate_kerberos_auth: output group= kv-pair
Markus Moeller [Wed, 29 Oct 2014 04:26:36 +0000 (21:26 -0700)] 
negotiate_kerberos_auth: output group= kv-pair

Output group= if negotiate_kerberos_auth can retrieve AD groups from
Kerberos ticket for further processing by squid to external helpers.

9 years agoBoilerplate: add copyright blurb to error page templates
Amos Jeffries [Tue, 28 Oct 2014 05:21:28 +0000 (22:21 -0700)] 
Boilerplate: add copyright blurb to error page templates

9 years agoSource Maintenance
Amos Jeffries [Tue, 28 Oct 2014 02:47:36 +0000 (19:47 -0700)] 
Source Maintenance

9 years agoBoilerplate: add copyright blurb to misc files
Amos Jeffries [Tue, 28 Oct 2014 01:36:54 +0000 (18:36 -0700)] 
Boilerplate: add copyright blurb to misc files

9 years agoBoilerplate: add copyright blurb to doc/Programming-Guide/
Amos Jeffries [Tue, 28 Oct 2014 01:22:47 +0000 (18:22 -0700)] 
Boilerplate: add copyright blurb to doc/Programming-Guide/

9 years agoDrop dead code HttpStateData::ReadReplyWrapper()
Amos Jeffries [Wed, 22 Oct 2014 11:50:24 +0000 (04:50 -0700)] 
Drop dead code HttpStateData::ReadReplyWrapper()

9 years agoEnable flexible transport protocol in Server hierarchy
Amos Jeffries [Tue, 21 Oct 2014 11:10:13 +0000 (04:10 -0700)] 
Enable flexible transport protocol in Server hierarchy

We are quickly approaching a time when a client connection can freely
migrate between protocols or versions of protocols. Already we have
ssl-bump which can switch a connection from HTTP to HTTPS. We are also
expecting switching HTTP<->HTTPS via Upgrade, and HTTP/1<->HTTP/2 via
"magic", Upgrade, or ALPN.

Based on ssl-bump experience with switchedToHttps() and the pain that
can be predicted when there are several permutations of such accessors
to test against make the Server class aware of what transfer protocol
is in use at whatever the 'top' layer of the protocol stack is.

* Add a transportVersion member to ConnStateData which holds the current
  protocol to be used over the clientConnection socket. This variable can
  be altered whenever necessary to cause an on-wire protocol change. New
  connections default to the protocol signalled in the http(s)_port directive.

* ssl-bump transforms the transportVersion from whatever it was
  previously (usually HTTP or HTTPS) to HTTPS, and back to HTTP is splice
  action is performed.

* transparent and reverse-proxy URL reconstruction is updated to use the
  new member instead of the http(s)_port protocol= setting. This removes
  edge conditions where the URL reconstructor needs to figure out ssl-bump
  existence.

9 years agoFix typo in cbdata.cc
Amos Jeffries [Tue, 21 Oct 2014 11:08:12 +0000 (04:08 -0700)] 
Fix typo in cbdata.cc

9 years agoCleanup: Simplify MEMPROXY_CLASS_* macros
Amos Jeffries [Mon, 20 Oct 2014 06:58:59 +0000 (23:58 -0700)] 
Cleanup: Simplify MEMPROXY_CLASS_* macros

There are no logical changes in this patch.

* Make MEMPROXY_CLASS() macro inline its definitions.

* Remove MEMPROXY_CLASS_INLINE

* Remove last remaining mention of obsolete MEMPROXY_CLASS_INIT

* Adjust MEMPROXY_CLASS() to control its private/public definitions
  appropriate to their needs.

* Shuffle all MEMPROXY_CLASS() macro uses to the top of the relevant
  classes (in some cases renaming struct to class with public members
  if necessary) such that the new terminal private: does not affect
  existing class definitions.

9 years agoBug 4102: sslbump cert contains only a dot character in key usage extension
Christos Tsantilas [Mon, 20 Oct 2014 00:12:56 +0000 (17:12 -0700)] 
Bug 4102: sslbump cert contains only a dot character in key usage extension

The patch for bug 3966 was slightly incorrect. As a result the Key Usage
field for SSL-bump mimic'ed certificates could end up containing only a
dot (.) character.

9 years agoFix typo in squidclient.1
Amos Jeffries [Sun, 19 Oct 2014 22:52:35 +0000 (15:52 -0700)] 
Fix typo in squidclient.1

9 years agoEnable long (--foo) command line parameters on squid binary
Amos Jeffries [Sun, 19 Oct 2014 22:06:38 +0000 (15:06 -0700)] 
Enable long (--foo) command line parameters on squid binary

The squid binary is running out of single-character options that make
any sense phonetically or as abbreviations. This lays the groundwork for
future options to use words or even just more than a single character.

Since we cannot define an empty array for long options, add --help and
--version as initial expansions of -h and -v.

9 years agokerberos_ldap_group/cert_tool: Remove ksh dependency
Santiago Garcia Mantinan [Sun, 19 Oct 2014 03:27:07 +0000 (20:27 -0700)] 
kerberos_ldap_group/cert_tool: Remove ksh dependency

Shell scripts published with Squid should be POSIX neutral. Replace the
ksh-specific syntax with portable POSIX shell.

9 years agoBoilerplate: update release script COPYRIGHT file action
Amos Jeffries [Fri, 17 Oct 2014 05:16:05 +0000 (22:16 -0700)] 
Boilerplate: update release script COPYRIGHT file action

9 years agoFix Release Notes typos for 3.5
Amos Jeffries [Fri, 17 Oct 2014 01:31:07 +0000 (18:31 -0700)] 
Fix Release Notes typos for 3.5

9 years agoDocs: update CONTRIBUTORS from 3.5 commit log
Amos Jeffries [Fri, 17 Oct 2014 00:40:33 +0000 (17:40 -0700)] 
Docs: update CONTRIBUTORS from 3.5 commit log

9 years agoDocs: typo in logformat
Amos Jeffries [Fri, 17 Oct 2014 00:35:19 +0000 (17:35 -0700)] 
Docs: typo in logformat

9 years agoRelease Notes for Squid-3.6
Amos Jeffries [Fri, 17 Oct 2014 00:33:18 +0000 (17:33 -0700)] 
Release Notes for Squid-3.6

9 years agoRelease Notes for Squid-3.6
Amos Jeffries [Fri, 17 Oct 2014 00:29:51 +0000 (17:29 -0700)] 
Release Notes for Squid-3.6

9 years agoPrep for 3.5.0.1
Amos Jeffries [Thu, 16 Oct 2014 23:38:20 +0000 (16:38 -0700)] 
Prep for 3.5.0.1

9 years agoRelease Notes update for 3.4
Amos Jeffries [Thu, 16 Oct 2014 23:33:12 +0000 (16:33 -0700)] 
Release Notes update for 3.4

9 years agoBug 3803: ident leaks memory on failure
Amos Jeffries [Thu, 16 Oct 2014 18:01:46 +0000 (11:01 -0700)] 
Bug 3803: ident leaks memory on failure

Begin the process of conversion for IdentStateData to an AsyncJob.

* convert the object from CBDATA struct to a class with
CBDATA_CLASS2() API.

* Bug 3803 is caused by a lack of proper cleanup and consistent exit
actions terminating the job. Take the core logic changes from the
tested bug patch and;

 1) define a swanSong() method to cleanup the memory allocated

 2) define a deleteThis() method to emulate AsyncJob::deleteThis()

* Locate all code paths leveraging conn->close() to trigger cleanup
via the connection close handler and convert to explicit deleteThis()
with excuse. Including a few which were not but need to in order to
terminate the job correctly as fixed in bug 3803 patch.

The actions performed are nearly identical to the original code. The
differences are that many code paths now omit an AsyncCall step going
via the Comm close handler, and that all paths terminating the IDENT
lookup now go through swanSong() cleanup.

Further cleanup converting to a full AsyncJob is not included, since
there is an explicit hash of running IdentStateData object pointers
being used in the old code.

9 years agoAudit updates
Amos Jeffries [Wed, 15 Oct 2014 14:09:32 +0000 (07:09 -0700)] 
Audit updates

* rename HttpRequestMethod(char*) to HttpRequestMethodXXX() in order to
  assist removal since it is deprecated now
 - plus code polishing and unit-test updates to work with this as a
   method instead of constructor

* fix several potential out-of-bounds SBuf and MemBlob accesses

* reduce performance regression parsing ICAP/eCAP traffic

* simplify and optimize clear() operation

* documentation clarifications

* typos and spelling fixes

9 years agoCleanup: drop MemBuf.cci
Amos Jeffries [Tue, 14 Oct 2014 13:57:05 +0000 (06:57 -0700)] 
Cleanup: drop MemBuf.cci

Inline the code previously contained in MemBuf.cci.

Also, cleanup MemBuf.h TODOs.

9 years agoBug 4024: Bad host/IP ::1 when using IPv4-only environment
Amos Jeffries [Tue, 14 Oct 2014 07:27:42 +0000 (00:27 -0700)] 
Bug 4024: Bad host/IP ::1 when using IPv4-only environment

9 years agoWindows: link libgcc and libstdc statically
Amos Jeffries [Mon, 13 Oct 2014 14:40:35 +0000 (07:40 -0700)] 
Windows: link libgcc and libstdc statically

MinGW builds require static linking to libgcc and libstdc++ in order to
run natively on windows without additional DLL installation.

9 years agoUpdate RFC 7230 compliance
Amos Jeffries [Sat, 11 Oct 2014 19:44:29 +0000 (12:44 -0700)] 
Update RFC 7230 compliance

* Use status 414 on too-long URLs

* Use 431 on too-bit mime headers

* Enable the RFC 7230 tolerant parser CRLF / LF waiting for requests.

* Documentation updates.

9 years agoBug 4093: source-maintenance.sh errors and warnings due to wrong tools/options
Alex Rousskov [Sat, 11 Oct 2014 11:05:13 +0000 (04:05 -0700)] 
Bug 4093: source-maintenance.sh errors and warnings due to wrong tools/options

9 years agoDocs: CBDATA documentation update
Amos Jeffries [Fri, 10 Oct 2014 17:46:03 +0000 (10:46 -0700)] 
Docs: CBDATA documentation update

No logic changes.

* replace documentation advocating the deprecated CBDATA_TYPE() and
  CBDATA_TYPE_INIT() macros with text advocating CBDATA_CLASS2() API.

* remove unused macro CBDATA_GLOBAL_TYPE()

9 years agoCBDATA: log memory leak situations when --enable-debug-cbdata
Amos Jeffries [Fri, 10 Oct 2014 16:06:38 +0000 (09:06 -0700)] 
CBDATA: log memory leak situations when --enable-debug-cbdata

CBDATA objects are supposed to be explicitly locked and unlocked by all
users. The nominal 'owner' of the data is also supposed to mark it as
invalid when unlocking its reference.

If a CBDATA object reaches 0 locks and is still valid, it therefore
follows that either the locking or invalidate has not been properly
implemented.

Now that we are migrating to CbcPointer usage instead of explicit
lock/unlock macro calls we have started encountering these situations.
Any object reporting a 'leak' must be investigated;
 a) perhapse RefCount is better?
 b) using CbcPointer consistently and invalidating correctly.

9 years agoGopher: update to CBDATA_CLASS API
Amos Jeffries [Fri, 10 Oct 2014 16:00:52 +0000 (09:00 -0700)] 
Gopher: update to CBDATA_CLASS API

* Convert from typedef struct to full class

* Convert from old CBDATA API to CBDATA_CLASS2

* Add AsyncJob-alike methods to simplify the cleanup process and future
  conversion.

* Remove unused 'req' member

* Remove remove outdated doxygen documentation

9 years agoMerge from trunk rev.13638
Amos Jeffries [Fri, 10 Oct 2014 08:10:58 +0000 (01:10 -0700)] 
Merge from trunk rev.13638

9 years agoFix parse errors after trunk merge
Amos Jeffries [Fri, 10 Oct 2014 08:04:33 +0000 (01:04 -0700)] 
Fix parse errors after trunk merge

9 years agoFix typo in rev.13636
Amos Jeffries [Thu, 9 Oct 2014 08:49:40 +0000 (01:49 -0700)] 
Fix typo in rev.13636

9 years agoBranch 3.5.0.0
squidadm@squid-cache.org [Thu, 9 Oct 2014 06:44:29 +0000 (06:44 +0000)] 
Branch 3.5.0.0

9 years agoFix missing stub update in rev.13635
Amos Jeffries [Wed, 8 Oct 2014 17:08:57 +0000 (10:08 -0700)] 
Fix missing stub update in rev.13635

9 years agoBug 4088: memory leak in external_acl_type helper with cache=0 or ttl=0
Amos Jeffries [Wed, 8 Oct 2014 15:51:28 +0000 (08:51 -0700)] 
Bug 4088: memory leak in external_acl_type helper with cache=0 or ttl=0

ExternalACLEntry / external_acl_entry objects have been abusing the
CBDATA API for reference counting and since 3.4 this has resulted in
hidden memory leaks as object accounting shows all locks released but
the memory is not freed by any 'owner'.

* convert to using RefCount<> API.

* move ExternalACLEntry pre-define to acl/forward.h

* add ExternalACLEntryPointer in acl/forward.h

* convert LookupDone() method to using explicit typed pointer

* convert from CBDATA_CLASS to MEMPROXY_CLASS memory management.

* convert almost all raw ExternalACLEntry* to Pointer
 - remaining usage is in the cache hash pointers. Use an explicit 'cachd'
  lock/unlock until this hash is updated to std:: structure types.

9 years agoSourceFormat Enforcement
squidadm@squid-cache.org [Wed, 8 Oct 2014 15:31:21 +0000 (15:31 +0000)] 
SourceFormat Enforcement

9 years agoValidate server certificates without bumping: fix 'make distcheck' error
Christos Tsantilas [Wed, 8 Oct 2014 08:10:49 +0000 (11:10 +0300)] 
Validate server certificates without bumping: fix 'make distcheck' error

9 years agoValidate server certificates without bumping: fix compile error
Christos Tsantilas [Tue, 7 Oct 2014 17:26:33 +0000 (20:26 +0300)] 
Validate server certificates without bumping: fix compile error

Fix error: return-statement with a value, in function returning 'void'

9 years agosslproxy_cert_sign_hash configuration option
Christos Tsantilas [Tue, 7 Oct 2014 14:11:12 +0000 (17:11 +0300)] 
sslproxy_cert_sign_hash configuration option

Browser vendors will get rid of SSL certificates that use SHA-1 to generate
the hash that is then signed by the CA. For example, Google Chrome will start
to show an "insecure" sign for certificates that are valid after 1.1.2016 and
will generate a warning page for certificates that are valid after 1.1.2017 [1],
[2],[4]. Microsoft will block certificates with SHA-1 after 1.1.2017 [3].

This patch:
  1) Add a new configuration option to select the signing hash for
     generated certificates: sslproxy_cert_sign_hash.

  2) If sslproxy_cert_sign_hash is not set, then use the sha256 hash.

[1] https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/2-R4XziFc7A/YO0ZSrX_X4wJ
[2] https://code.google.com/p/chromium/issues/detail?id=401365
[3] http://blogs.technet.com/b/pki/archive/2013/11/12/sha1-deprecation-policy.aspx
[4] http://googleonlinesecurity.blogspot.ch/2014/09/gradually-sunsetting-sha-1.html

This is a Measurement Factory project

9 years agoCleanup CBDATA debugging messages
Amos Jeffries [Mon, 6 Oct 2014 19:38:03 +0000 (12:38 -0700)] 
Cleanup CBDATA debugging messages

* Remove duplicate labels from debug messages. function names are now
  automatically added.

* Add debug messages to display method used for freeing CBDATA.
  Whether the object was deleted, or placement destructor called.

9 years agoValidate server certificates without bumping
Christos Tsantilas [Mon, 6 Oct 2014 14:53:40 +0000 (17:53 +0300)] 
Validate server certificates without bumping

This patch add support for the "Validate server certificates without bumping"
use case described on the Peek and Splice wiki page:
    http://wiki.squid-cache.org/Features/SslPeekAndSplice

This patch send to the certificate validation helper the  certificates and
errors found in SslBump3 step, even if the splicing mode selected.
In the case the validation helper found errors in certificates an error
page returned to the http client.

The SSL error forwarding is controlled by ACLs along these lines:

   sslproxy_cert_error allow sslBoringErrors
   sslproxy_cert_error allow serversWithInvalidCerts
   sslproxy_cert_error deny all

This is a Measurement Factory project

9 years agoCleanup: restoreCapabilities() takes a bool parameter
Amos Jeffries [Sun, 5 Oct 2014 15:26:50 +0000 (08:26 -0700)] 
Cleanup: restoreCapabilities() takes a bool parameter

9 years agoMerged from trunk rev.13627
Amos Jeffries [Sun, 5 Oct 2014 10:46:34 +0000 (03:46 -0700)] 
Merged from trunk rev.13627

9 years agoRemove C++11'ism in rev.13604
Amos Jeffries [Sun, 5 Oct 2014 09:59:47 +0000 (02:59 -0700)] 
Remove C++11'ism in rev.13604

We are not quite going to require C++11 yet. Revert Helper::ChildConfig
default constructor to C++03 syntax.

9 years agoFix library dependency issue in rev.13604
Amos Jeffries [Sat, 4 Oct 2014 09:27:01 +0000 (02:27 -0700)] 
Fix library dependency issue in rev.13604

TODO: build true library dependency map and re-order all LDADD
statements according to the hierarchy found.

9 years agoWindows: remove alternative main()
Amos Jeffries [Fri, 3 Oct 2014 13:34:52 +0000 (06:34 -0700)] 
Windows: remove alternative main()

As a side effect this causes Windows builds to use the wrapper function
for handling exceptions.

9 years agoFix --enable-win32-service compile errors
Amos Jeffries [Fri, 3 Oct 2014 11:45:29 +0000 (04:45 -0700)] 
Fix --enable-win32-service compile errors

9 years agoWindows: add missing file permission definitions
Amos Jeffries [Thu, 2 Oct 2014 17:50:47 +0000 (10:50 -0700)] 
Windows: add missing file permission definitions

* initgroups() shim was building, but header not included correctly.

* POSIX 5.6 / 6.5 Protection Bits for group access do not exist in
  windows MinGW. Define as 0-bits until better API is found.

9 years agoAdd missing boilerplate for rev.13621
Amos Jeffries [Thu, 2 Oct 2014 12:12:52 +0000 (05:12 -0700)] 
Add missing boilerplate for rev.13621

9 years agoPortability: provide xstatvfs() shim for system call statvfs()
Amos Jeffries [Thu, 2 Oct 2014 12:07:26 +0000 (05:07 -0700)] 
Portability: provide xstatvfs() shim for system call statvfs()

statfs() and struct statfs have been deprecated for years. Hoewver the
POSIX statvfs replacements are still not universally available.

Remove deprecated statfs() and struct statfs usage from Squid. Although
they may still be used by the xstatvfs() compatibility wrapper if they
are the only available API.

9 years agoPolish peek-and-splice related code part2
Christos Tsantilas [Wed, 1 Oct 2014 12:46:44 +0000 (15:46 +0300)] 
Polish peek-and-splice related code part2

- Record SSL bump action in Ssl::ServerBump::act at step3

9 years agoPolish peek-and-splice related code
Christos Tsantilas [Wed, 1 Oct 2014 12:31:58 +0000 (15:31 +0300)] 
Polish peek-and-splice related code

 - Record SSL bump action at each bumping step in the Ssl::ServerBump.
   The new Ssl::ServerBump::act member added for this purpose.

 - Split Ssl::PeerConnector::checkForPeekAndSplice  to two methods
   (checkForPeekAndSplice and checkForPeekAndSpliceDone) add some
   documentation, and polish the code.

 - Polish  httpsSslBumpStep2AccessCheckDone function (client_side.cc file)

This is a Measurement Factory project

9 years agoWindows: getppid() is not supported.
Amos Jeffries [Tue, 30 Sep 2014 13:11:58 +0000 (06:11 -0700)] 
Windows: getppid() is not supported.

The PID and thus parent process PID concept is not available in Windows
and MinGW at least lacks the API mechanism.

This may re-open an issue with kid processes notifying the coordinator
when they are shutting down. If so we need to find an alternative
mechanism to replace this use of kill(getppid(), SIGUSR1)

9 years agoPolish: cleanup IDENT header
Amos Jeffries [Mon, 29 Sep 2014 13:41:03 +0000 (06:41 -0700)] 
Polish: cleanup IDENT header

9 years agoCleanup: convert AuthUserIP from CBDATA to MEMPROXY class
Amos Jeffries [Mon, 29 Sep 2014 09:24:20 +0000 (02:24 -0700)] 
Cleanup: convert AuthUserIP from CBDATA to MEMPROXY class

This object was not needing to be passed as callback arguments
but was using CBDATA type to gain memory pooling.

Converting to the correct pooling mechanism removes some more
uses of cbdataFree() and ensures the object and its members
destructors are called properly.

9 years agoCleanup: fix various uninitialized class members
Amos Jeffries [Mon, 29 Sep 2014 07:18:13 +0000 (00:18 -0700)] 
Cleanup: fix various uninitialized class members

Also, simplify some destructors. xfree() is faster than
safe_free() and both are ok in a destructor.

  Detected by Coverity Scan. Issue 740527, 740532, 740533,
    740534, 740563, 1241964

9 years agoCleanup: fix various uninitialized class members
Amos Jeffries [Mon, 29 Sep 2014 05:13:17 +0000 (22:13 -0700)] 
Cleanup: fix various uninitialized class members

Also, simplify some destructors. xfree() is faster than
safe_free() and both are ok in a destructor.

  Detected by Coverity Scan. Issue 971423, 11354441135445,
    123135312313541231355123135612345031241504,
    740531, 740566

9 years agoCleanup: use SBuf::npos instead of npos in SBuf::append()
Amos Jeffries [Sun, 28 Sep 2014 18:49:09 +0000 (11:49 -0700)] 
Cleanup: use SBuf::npos instead of npos in SBuf::append()

Small experiment. It is possible on some systems that std::npos / ::npos
is defined with a different integer size and value.
This may be what is confusing Coverity scan and producing buffer overrun
alerts in the append() c-string with default parameter case.

9 years agoCleanup: convert external_acl_format to ref-counted pooled object
Amos Jeffries [Sun, 28 Sep 2014 18:42:55 +0000 (11:42 -0700)] 
Cleanup: convert external_acl_format to ref-counted pooled object

CBDATA was used as a makeshift way to memory pool and ref-count these
objects. Do it properly now.

9 years agoFix various null dereferences
Amos Jeffries [Sun, 28 Sep 2014 18:35:47 +0000 (11:35 -0700)] 
Fix various null dereferences

Fairly rare occurances hard to hit but still possible. Any one of these
could crash Squid in their particular circumstances.

  Detected by Coverity Scan. Issue 1187972118797312320971241502.

9 years agoFix crash reading malformed config files
Amos Jeffries [Sun, 28 Sep 2014 16:38:44 +0000 (09:38 -0700)] 
Fix crash reading malformed config files

If ConfigParser::QuotedOrToEol() happend to return NULL. Which may happen
if there is no token before end of current file the auth module config
parser would crash.

  Detected by Coverity Scan. Issue 1222662.

9 years agoDo not crash when sending %ssl::cert_subject to external ACL w/o certificate.
Christos Tsantilas [Fri, 26 Sep 2014 10:01:19 +0000 (13:01 +0300)] 
Do not crash when sending %ssl::cert_subject to external ACL w/o certificate.

An ACL check in ConnStateData::postHttpsAccept (e.g., when dealing with an
intercepted SSL connection) uses an HttpRequest object that is not yet linked
with the ConnStateData object. Do not blindly dereference the pointer to the
latter.

This is a Measurement Factory project

9 years agoFixes a squid crash when a foreign protocol client connected to an https_port
Christos Tsantilas [Fri, 26 Sep 2014 09:54:50 +0000 (12:54 +0300)] 
Fixes a squid crash when a foreign protocol client connected to an https_port

The Ssl::Bio::read will fail to recognize SSL protocol and will return "-1"
as readed SSL bytes. The Ssl::ClientBio::read must return error (-1)
in this case.

This is a Measurement Factory project

9 years agoSend selected SSL version and cipher to the certificate validation helper.
Christos Tsantilas [Fri, 26 Sep 2014 09:32:48 +0000 (12:32 +0300)] 
Send selected SSL version and cipher to the certificate validation helper.

This patch sends the selected cipher suite and the selected SSL/TLS version
to the certificate verification helper using the "proto_version=v" and
"cipher=c" key=value pairs.

This is a Measurement Factory project

9 years agoWindows: rename Ip::Address::*AddrInfo() methods
Amos Jeffries [Thu, 25 Sep 2014 13:33:18 +0000 (06:33 -0700)] 
Windows: rename Ip::Address::*AddrInfo() methods

On MinGW at least macro replacement appears to be case insensitive.
The lower-case freeaddrinfo/initaddrinfo system functions are defined
with macros, both in MinGW headers and Squid libcompat.

9 years agoPortability: do not explicitly name enum type in enumeration values
Amos Jeffries [Thu, 25 Sep 2014 10:34:22 +0000 (03:34 -0700)] 
Portability: do not explicitly name enum type in enumeration values

Some compilers (specifically MinGW at least) do not accept the name of
enum type being in the symbol where enumerated values are used.

ie. we must use Helper::Okay instead of Helper::ResultCode::Okay.

9 years agoSourceLayout: shuffle HelperChildConfig into libhelper.la
Amos Jeffries [Thu, 25 Sep 2014 06:50:32 +0000 (23:50 -0700)] 
SourceLayout: shuffle HelperChildConfig into libhelper.la

9 years agoSourceLayout: rename auth module files to match guidelines
Amos Jeffries [Wed, 24 Sep 2014 17:10:37 +0000 (10:10 -0700)] 
SourceLayout: rename auth module files to match guidelines

* Squid-3 coding guidelines require that files are named after the
  class(es) contained within. Rename the files containing auth Config
  classes to match.

* Remove the unused DefaultAuthenticateChildrenMax macros.

* simplify included headers in auth modules.

* alphabetize the order auth modules are detected.