]> git.ipfire.org Git - thirdparty/haproxy.git/log
thirdparty/haproxy.git
5 years agoMEDIUM: http-rules: Rely on http reply for http deny/tarpit rules
Christopher Faulet [Wed, 13 May 2020 15:56:56 +0000 (17:56 +0200)] 
MEDIUM: http-rules: Rely on http reply for http deny/tarpit rules

"http-request deny", "http-request tarpit" and "http-response deny" rules now
use the same syntax than http return rules and internally rely on the http
replies. The behaviour is not the same when no argument is specified (or only
the status code). For http replies, a dummy response is produced, with no
payload. For old deny/tarpit rules, the proxy's error messages are used. Thus,
to be compatible with existing configuration, the "default-errorfiles" parameter
is implied. For instance :

  http-request deny deny_status 404

is now an alias of

  http-request deny status 404 default-errorfiles

5 years agoMINOR: http-ana: Use a dedicated function to send a response from an http reply
Christopher Faulet [Wed, 13 May 2020 14:38:37 +0000 (16:38 +0200)] 
MINOR: http-ana: Use a dedicated function to send a response from an http reply

The http_reply_message() function may be used to send an http reply to a
client. This function is responsile to convert the reply in HTX, to push it in
the response buffer and to forward it to the client. It is also responsible to
terminate the transaction.

This function is used during evaluation of http return rules.

5 years agoMINOR: http-htx: Use a dedicated function to check http reply validity
Christopher Faulet [Wed, 13 May 2020 13:02:59 +0000 (15:02 +0200)] 
MINOR: http-htx: Use a dedicated function to check http reply validity

A dedicated function is added to check the validity of an http reply object,
after parsing. It is used to check the validity of http return rules.

For now, this function is only used to find the right error message in an
http-errors section for http replies of type HTTP_REPLY_ERRFILES (using
"errorfiles" argument). On success, such replies are updated to point on the
corresponding error message and their type is set to HTTP_REPLY_ERRMSG. If an
unknown http-errors section is referenced, anx error is returned. If a unknown
error message is referenced inside an existing http-errors section, a warning is
emitted and the proxy's error messages are used instead.

5 years agoMINOR: http-htx: Use a dedicated function to parse http reply arguments
Christopher Faulet [Wed, 13 May 2020 12:36:55 +0000 (14:36 +0200)] 
MINOR: http-htx: Use a dedicated function to parse http reply arguments

A dedicated function to parse arguments and create an http_reply object is
added. It is used to parse http return rule. Thus, following arguments are
parsed by this function :

  ... [status <code>] [content-type <type>]
      [ { default-errorfiles | errorfile <file> | errorfiles <name> |
          file <file> | lf-file <file> | string <str> | lf-string <fmt> } ]
      [ hdr <name> <fmt> ]*

Because the status code argument is optional, a default status code must be
defined when this function is called.

5 years agoMINOR: http-htx: Use a dedicated function to release http_reply objects
Christopher Faulet [Tue, 12 May 2020 16:57:28 +0000 (18:57 +0200)] 
MINOR: http-htx: Use a dedicated function to release http_reply objects

A function to release an http_reply object has been added. It is now called when
an http return rule is released.

5 years agoMINOR: http-rules: Use http_reply structure for http return rules
Christopher Faulet [Tue, 12 May 2020 16:33:37 +0000 (18:33 +0200)] 
MINOR: http-rules: Use http_reply structure for http return rules

No real change here. Instead of using an internal structure to the action rule,
the http return rules are now stored as an http reply. The main change is about
the action type. It is now always set to ACT_CUSTOM. The http reply type is used
to know how to evaluate the rule.

5 years agoCLEANUP: http-htx: Rename http_error structure into http_error_msg
Christopher Faulet [Wed, 13 May 2020 19:45:22 +0000 (21:45 +0200)] 
CLEANUP: http-htx: Rename http_error structure into http_error_msg

The structure owns an error message, most of time loaded from a file, and
converted to HTX. It is created when an errorfile or errorloc directive is
parsed. It is renamed to avoid ambiguities with http_reply structure.

5 years agoMINOR: http-htx: Add http_reply type based on what is used for http return rules
Christopher Faulet [Tue, 12 May 2020 16:31:35 +0000 (18:31 +0200)] 
MINOR: http-htx: Add http_reply type based on what is used for http return rules

The http_reply structure is added. It represents a generic HTTP message used as
internal response by HAProxy. It is based on the structure used to store http
return rules. The aim is to store all error messages using this structure, as
well as http return and http deny rules.

5 years agoBUG/MINOR: http-rules: Mark http return rules as final
Christopher Faulet [Wed, 13 May 2020 06:50:07 +0000 (08:50 +0200)] 
BUG/MINOR: http-rules: Mark http return rules as final

For HTTP rules, this flag is only used to trigger a warning during HAProxy
startup when a final rule without ACL is not the last one. So this patch is
marked as a bug, but its impact is really limited.

No backport needed because http return rules were introduced in the 2.2.

5 years agoCLEANUP: http_ana: Remove unused TXN flags
Christopher Faulet [Wed, 13 May 2020 06:12:22 +0000 (08:12 +0200)] 
CLEANUP: http_ana: Remove unused TXN flags

TX_CLDENY, TX_CLALLOW, TX_SVDENY and TX_SVALLOW flags are unused. Only
TX_CLTARPIT is used to make the difference between an http deny rule and an http
tarpit rule. So these unused flags are removed.

5 years agoMINOR: ssl: split config and runtime variable for ssl-{min,max}-ver
William Lallemand [Wed, 20 May 2020 14:49:02 +0000 (16:49 +0200)] 
MINOR: ssl: split config and runtime variable for ssl-{min,max}-ver

In the CLI command 'show ssl crt-list', the ssl-min-ver and the
ssl-min-max arguments were always displayed because the dumped versions
were the actual version computed and used by haproxy, instead of the
version found in the configuration.

To fix the problem, this patch separates the variables to have one with
the configured version, and one with the actual version used. The dump
only shows the configured version.

5 years agoCI: travis-ci: fix libslz download URL
Ilya Shipitsin [Mon, 18 May 2020 20:47:07 +0000 (01:47 +0500)] 
CI: travis-ci: fix libslz download URL

let us switch to github mirror, travis cannot download original libslz

error is:
fatal: unable to access 'http://git.1wt.eu/git/libslz.git/': Failed
to connect to git.1wt.eu port 80: Connection timed out The command
"git clone http://git.1wt.eu/git/libslz.git/" failed and exited with
128...

5 years agoRevert "MEDIUM: sink: add global statement to create a new ring (sink buffer)"
Willy Tarreau [Wed, 20 May 2020 10:04:39 +0000 (12:04 +0200)] 
Revert "MEDIUM: sink: add global statement to create a new ring (sink buffer)"

This reverts commit 957ec59571ce7eead86fb138e506c937c271e0b6.

As discussed with Emeric, the current syntax is not extensible enough,
this will be turned to a section instead in a forthcoming patch.

5 years agoMINOR: ring: make the applet code not depend on the CLI
Willy Tarreau [Tue, 19 May 2020 17:14:42 +0000 (19:14 +0200)] 
MINOR: ring: make the applet code not depend on the CLI

The ring to applet communication was only made to deal with CLI functions
but it's generic. Let's have generic appctx functions and have the CLI
rely on these instead. This patch introduces ring_attach_appctx() and
ring_detach_appctx().

5 years agoMINOR: applet: adopt the wait list entry from the CLI
Willy Tarreau [Tue, 19 May 2020 15:07:30 +0000 (17:07 +0200)] 
MINOR: applet: adopt the wait list entry from the CLI

A few fields, including a generic list entry, were added to the CLI context
by commit 300decc8d9 ("MINOR: cli: extend the CLI context with a list and
two offsets"). It turns out that the list entry (l0) is solely used to
consult rings and that the generic ring_write() code is restricted to a
consumer on the CLI due to this, which was not the initial intent. Let's
make it a general purpose wait_entry field that is properly initialized
during appctx_init(). This will allow any applet to wait on a ring, not
just the CLI.

5 years agoBUG/MEDIUM: ring: write-lock the ring while attaching/detaching
Willy Tarreau [Tue, 19 May 2020 17:21:45 +0000 (19:21 +0200)] 
BUG/MEDIUM: ring: write-lock the ring while attaching/detaching

The LIST_ADDQ() and LIST_DEL_INIT() calls made to attach/detach a waiter
to the ring were made under a read lock which was sufficient in front of
the writer's write lock. But it's not sufficient against other readers!
Thus theorically multiple "show events" on the same ring buffer on the
CLI could result in a crash, even though for now I couldn't manage to
reproduce it.

This fixes commit 1d181e489c ("MEDIUM: ring: implement a wait mode for
watchers") so it must be backported to 2.1, possibly further if the ring
code gets backported.

5 years agoBUG/MAJOR: mux-fcgi: Stop sending loop if FCGI stream is blocked for any reason
Christopher Faulet [Tue, 19 May 2020 13:13:00 +0000 (15:13 +0200)] 
BUG/MAJOR: mux-fcgi: Stop sending loop if FCGI stream is blocked for any reason

Because of a typo error in conditions to exit the sending loop, it is possible
to loop infinitely in fcgi_snd_buf() function. Instead of checking the FCGI
stream is not blocked to continue sending data, the FCGI connection is used. So
it is possible to have a stream blocked because there is not enough space in the
mux buffers to copy more data but continue to loop to send more data.

This patch should fix the issue #637. It must be backported to 2.1.

5 years agoMEDIUM: hpack: use a pool for the hpack table
Willy Tarreau [Tue, 19 May 2020 09:31:11 +0000 (11:31 +0200)] 
MEDIUM: hpack: use a pool for the hpack table

Instead of using malloc/free to allocate an HPACK table, let's declare
a pool. However the HPACK size is configured by the H2 mux, so it's
also this one which allocates it after post_check.

5 years agoMEDIUM: sink: add global statement to create a new ring (sink buffer)
Emeric Brun [Mon, 11 May 2020 12:41:31 +0000 (14:41 +0200)] 
MEDIUM: sink: add global statement to create a new ring (sink buffer)

This patch adds the new global statement:
ring <name> [desc <desc>] [format <format>] [size <size>] [maxlen <length>]
  Creates a named ring buffer which could be used on log line for instance.

  <desc> is an optionnal description string of the ring. It will appear on
         CLI. By default, <name> is reused to fill this field.

  <format> is the log format used when generating syslog messages. It may be
           one of the following :

    iso       A message containing only the ISO date, followed by the text.
              The PID, process name and system name are omitted. This is
              designed to be used with a local log server.

    raw       A message containing only the text. The level, PID, date, time,
              process name and system name are omitted. This is designed to be
              used in containers or during development, where the severity only
              depends on the file descriptor used (stdout/stderr). This is
              the default.

    rfc3164   The RFC3164 syslog message format. This is the default.
              (https://tools.ietf.org/html/rfc3164)

    rfc5424   The RFC5424 syslog message format.
              (https://tools.ietf.org/html/rfc5424)

    short     A message containing only a level between angle brackets such as
              '<3>', followed by the text. The PID, date, time, process name
              and system name are omitted. This is designed to be used with a
              local log server. This format is compatible with what the systemd
              logger consumes.

    timed     A message containing only a level between angle brackets such as
              '<3>', followed by ISO date and by the text. The PID, process
              name and system name are omitted. This is designed to be
              used with a local log server.

  <length> is the maximum length of event message stored into the ring,
           including formatted header. If the event message is longer
           than <length>, it would be truncated to this length.

  <name> is the ring identifier, which follows the same naming convention as
         proxies and servers.

  <size> is the optionnal size in bytes. Default value is set to BUFSIZE.

Note: Historically sink's name and desc were refs on const strings. But with new
configurable rings a dynamic allocation is needed.

5 years agoMEDIUM: logs: buffer targets now rely on new sink_write
Emeric Brun [Wed, 6 May 2020 15:23:59 +0000 (17:23 +0200)] 
MEDIUM: logs: buffer targets now rely on new sink_write

Before this path, they rely directly on ring_write bypassing
a part of the sink API.

Now the maxlen parameter of the log will apply only on the text
message part (and not the header, for this you woud prefer
to use the maxlen parameter on the sink/ring).

sink_write prototype was also reviewed to return the number of Bytes
written to be compliant with the other write functions.

5 years agoMEDIUM: sink: build header in sink_write for log formats
Emeric Brun [Wed, 6 May 2020 12:33:46 +0000 (14:33 +0200)] 
MEDIUM: sink: build header in sink_write for log formats

This patch extends the sink_write prototype and code to
handle the rfc5424 and rfc3164 header.

It uses header building tools from log.c. Doing this some
functions/vars have been externalized.

facility and minlevel have been removed from the struct sink
and passed to args at sink_write because they depends of the log
and not of the sink (they remained unused by rest of the code
until now).

5 years agoBUG/MINOR: logs: prevent double line returns in some events.
Emeric Brun [Tue, 12 May 2020 17:33:15 +0000 (19:33 +0200)] 
BUG/MINOR: logs: prevent double line returns in some events.

Historically some messages used to already contain the trailing LF but
not all, and __do_send_log adds a new one in needed cases. It also does
trim a trailing LF in certain cases while computing the max message
length, as a result of subtracting 1 to the available room in the
destination buffer. But the way it's done is wrong since some messages
still contain it.

So the code was fixed to always trim the trailing LF from messages if
present, and then only subtract 1 from the destination buffer room
instead of the size..

Note: new sink API is not designed to receive a trailing LF on
event messages

This could be backported to relevant stable versions with particular
care since the logic of the code changed a bit since 1.6 and there
may be other locations that need to be adjusted.

5 years agoMEDIUM: checks: Make post-41 the default mode for mysql checks
Christopher Faulet [Mon, 18 May 2020 16:13:03 +0000 (18:13 +0200)] 
MEDIUM: checks: Make post-41 the default mode for mysql checks

MySQL 4.1 is old enough to be the default mode for mysql checks. So now, once a
username is defined, post-41 mode is automatically used. To do mysql checks on
previous MySQL version, the argument "pre-41" must be used.

Note, it is a compatibility breakage for everyone using an antique and
unsupported MySQL version.

5 years agoMINOR: config: Don't dump keywords if argument is NULL
Christopher Faulet [Mon, 18 May 2020 10:14:18 +0000 (12:14 +0200)] 
MINOR: config: Don't dump keywords if argument is NULL

Helper functions are used to dump bind, server or filter keywords. These
functions are used to report errors during the configuration parsing. To have a
coherent API, these functions are now prepared to handle a null pointer as
argument. If so, no action is performed and functions immediately return.

This patch should fix the issue #631. It is not a bug. There is no reason to
backport it.

5 years agoBUG/MINOR: cache: Don't needlessly test "cache" keyword in parse_cache_flt()
Christopher Faulet [Mon, 18 May 2020 09:58:16 +0000 (11:58 +0200)] 
BUG/MINOR: cache: Don't needlessly test "cache" keyword in parse_cache_flt()

parse_cache_flt() is the registered callback for the "cache" filter keyword. It
is only called when the "cache" keyword is found on a filter line. So, it is
useless to test the filter name in the callback function.

This patch should fix the issue #634. It may be backported as far as 1.9.

5 years agoDOC: SPOE is no longer experimental
Christopher Faulet [Wed, 13 May 2020 06:25:12 +0000 (08:25 +0200)] 
DOC: SPOE is no longer experimental

The SPOE was marked as experiemental since the begining. But, it is no longer
true. This can be an obstacle to its use.

5 years agoBUILD: ssl: fix build without OPENSSL_NO_ENGINE
William Lallemand [Mon, 18 May 2020 11:42:49 +0000 (13:42 +0200)] 
BUILD: ssl: fix build without OPENSSL_NO_ENGINE

The CI revealed that the boringssl build is still broken because of some
ifdef misplacement.

Bug introduced by dad3105 ("REORG: ssl: move ssl configuration to
cfgparse-ssl.c").

No backport needed.

Fix issue #633.

5 years agoDOC/MINOR: halog: Add long help info for ic flag
Aleksandar Lazi [Fri, 15 May 2020 20:58:30 +0000 (22:58 +0200)] 
DOC/MINOR: halog: Add long help info for ic flag

Add missing long help text for the ic (ip count) flag

5 years agoCLEANUP: acl: remove unused assignment
Ilya Shipitsin [Sat, 16 May 2020 17:42:12 +0000 (22:42 +0500)] 
CLEANUP: acl: remove unused assignment

Coverity found unused variable assignment

    CID 1299671 (#1 of 1): Unused value (UNUSED_VALUE)assigned_pointer:
    Assigning value from args[arg + 1] to word here, but that stored
    value is overwritten before it can be used.
 958                        word = args[arg + 1];
 959                        arg = arg_end;

5 years agoBUILD: ssl: include errno.h in ssl_crtlist.c
William Lallemand [Mon, 18 May 2020 06:33:09 +0000 (08:33 +0200)] 
BUILD: ssl: include errno.h in ssl_crtlist.c

In issue #632 boringssl build were broken by the lack of errno.h
include in ssl_crtlist.c

Bug introduced by 6e9556b ("REORG: ssl: move crtlist functions to src/ssl_crtlist.c").

No backport needed.

5 years agoBUILD: ssl: include buffer common headers for ssl_sock_ctx
William Dauchy [Sun, 17 May 2020 11:41:53 +0000 (13:41 +0200)] 
BUILD: ssl: include buffer common headers for ssl_sock_ctx

since commit c0cdaffaa338 ("REORG: ssl: move ssl_sock_ctx and fix
cross-dependencies issues"), `struct ssl_sock_ctx` was moved in
ssl_sock.h. As it contains a `struct buffer`, including
`common/buffer.h` is now mandatory. I encountered an issue while
including ssl_sock.h on another patch:

include/types/ssl_sock.h:240:16: error: field â€˜early_buf’ has incomplete type
  240 |  struct buffer early_buf;      /* buffer to store the early data received */

no backport needed.

Fixes: c0cdaffaa338 ("REORG: ssl: move ssl_sock_ctx and fix
cross-dependencies issues")
Signed-off-by: William Dauchy <w.dauchy@criteo.com>
5 years agoMEDIUM: stats: Enable more accurate moving average calculation for stats
Marcin Deranek [Fri, 15 May 2020 18:02:40 +0000 (20:02 +0200)] 
MEDIUM: stats: Enable more accurate moving average calculation for stats

Enable more accurate generation of moving averages for partially
populated samples window.

5 years agoMINOR: stats: Expose native cum_req metric for a server
Marcin Deranek [Fri, 15 May 2020 16:32:51 +0000 (18:32 +0200)] 
MINOR: stats: Expose native cum_req metric for a server

Expose native cum_req metric for a server: so far it was calculated as a
sum or all responses. Rename it from Cum. HTTP Responses to Cum. HTTP
Requests to be consistent with Frontend and Backend.

5 years agoMINOR: stats: Prepare for more accurate moving averages
Marcin Deranek [Fri, 15 May 2020 16:26:18 +0000 (18:26 +0200)] 
MINOR: stats: Prepare for more accurate moving averages

Add swrate_add_dynamic function which is similar to swrate_add, but more
accurate when calculating moving averages when not enough samples have
been processed yet.

5 years agoCI: travis-ci: switch arm64 builds to use openssl from distro
Martin Tzvetanov Grigorov [Fri, 15 May 2020 18:34:46 +0000 (23:34 +0500)] 
CI: travis-ci: switch arm64 builds to use openssl from distro

there are ongoing arm64 failures in travis-ci. we suspect that
build stucks on scripts/build-ssl.sh which is called during build.
let us try to use openssl from ubuntu distro and not build it
ourselves. to achive that we add "install" section without
build-ssl.sh

5 years agoDOC: ssl: update MAINTAINERS file
William Lallemand [Fri, 15 May 2020 11:29:05 +0000 (13:29 +0200)] 
DOC: ssl: update MAINTAINERS file

Update the MAINTAINERS file with new files and maintainer.

5 years agoREORG: ssl: move utility functions to src/ssl_utils.c
William Lallemand [Fri, 15 May 2020 10:01:17 +0000 (12:01 +0200)] 
REORG: ssl: move utility functions to src/ssl_utils.c

These functions are mainly used to extract information from
certificates.

5 years agoREORG: ssl: move sample fetches to src/ssl_sample.c
William Lallemand [Thu, 14 May 2020 22:25:08 +0000 (00:25 +0200)] 
REORG: ssl: move sample fetches to src/ssl_sample.c

Move all SSL sample fetches to src/ssl_sample.c.

5 years agoREORG: ssl: move ssl_sock_ctx and fix cross-dependencies issues
William Lallemand [Thu, 14 May 2020 22:20:53 +0000 (00:20 +0200)] 
REORG: ssl: move ssl_sock_ctx and fix cross-dependencies issues

In order to move all SSL sample fetches in another file, moving the
ssl_sock_ctx definition in a .h file is required.

Unfortunately it became a cross dependencies hell to solve, because of
the struct wait_event field, so <types/connection.h> is needed which
created other problems.

5 years agoMINOR: ssl: remove static keyword in some SSL utility functions
William Lallemand [Fri, 15 May 2020 07:52:16 +0000 (09:52 +0200)] 
MINOR: ssl: remove static keyword in some SSL utility functions

In order to move the the sample fetches to another file, remove the
static keyword of some utility functions in the SSL fetches.

5 years agoREORG: ssl: move ssl configuration to cfgparse-ssl.c
William Lallemand [Thu, 14 May 2020 15:47:32 +0000 (17:47 +0200)] 
REORG: ssl: move ssl configuration to cfgparse-ssl.c

Move all the configuration parsing of the ssl keywords in cfgparse-ssl.c

5 years agoREORG: ssl: move the CLI 'cert' functions to src/ssl_ckch.c
William Lallemand [Thu, 14 May 2020 08:14:37 +0000 (10:14 +0200)] 
REORG: ssl: move the CLI 'cert' functions to src/ssl_ckch.c

Move the 'ssl cert' CLI functions to src/ssl_ckch.c.

5 years agoREORG: ssl: move the crt-list CLI functions in src/ssl_crtlist.c
William Lallemand [Wed, 13 May 2020 15:23:59 +0000 (17:23 +0200)] 
REORG: ssl: move the crt-list CLI functions in src/ssl_crtlist.c

Move the crtlist functions for the CLI to src/ssl_crtlist.c

5 years agoREORG: ssl: move ckch_inst functions to src/ssl_ckch.c
William Lallemand [Wed, 13 May 2020 13:46:10 +0000 (15:46 +0200)] 
REORG: ssl: move ckch_inst functions to src/ssl_ckch.c

Move ckch_inst_new() and ckch_inst_free() to src/ssl_ckch.c

5 years agoREORG: ssl: move the ckch_store related functions to src/ssl_ckch.c
William Lallemand [Wed, 13 May 2020 08:10:01 +0000 (10:10 +0200)] 
REORG: ssl: move the ckch_store related functions to src/ssl_ckch.c

Move the cert_key_and_chain functions:

int ssl_sock_load_files_into_ckch(const char *path, struct cert_key_and_chain *ckch, char **err);
int ssl_sock_load_pem_into_ckch(const char *path, char *buf, struct cert_key_and_chain *ckch , char **err);
void ssl_sock_free_cert_key_and_chain_contents(struct cert_key_and_chain *ckch);

int ssl_sock_load_key_into_ckch(const char *path, char *buf, struct cert_key_and_chain *ckch , char **err);
int ssl_sock_load_ocsp_response_from_file(const char *ocsp_path, char *buf, struct cert_key_and_chain *ckch, char **err);
int ssl_sock_load_sctl_from_file(const char *sctl_path, char *buf, struct cert_key_and_chain *ckch, char **err);
int ssl_sock_load_issuer_file_into_ckch(const char *path, char *buf, struct cert_key_and_chain *ckch, char **err);

And the utility ckch_store functions:

void ckch_store_free(struct ckch_store *store)
struct ckch_store *ckch_store_new(const char *filename, int nmemb)
struct ckch_store *ckchs_dup(const struct ckch_store *src)
ckch_store *ckchs_lookup(char *path)
ckch_store *ckchs_load_cert_file(char *path, int multi, char **err)

5 years agoCLEANUP: ssl: avoid circular dependencies in ssl_crtlist.h
William Lallemand [Wed, 13 May 2020 06:24:41 +0000 (08:24 +0200)] 
CLEANUP: ssl: avoid circular dependencies in ssl_crtlist.h

Add forward declarations in types/ssl_crtlist.h in order to avoid
circular dependencies. Also remove the listener.h include which is not
needed anymore.

5 years agoREORG: ssl: move crtlist functions to src/ssl_crtlist.c
William Lallemand [Tue, 12 May 2020 15:52:44 +0000 (17:52 +0200)] 
REORG: ssl: move crtlist functions to src/ssl_crtlist.c

Move the crtlist functions to src/ssl_crtlist.c and their definitions to
proto/ssl_crtlist.h.

The following functions were moved:

/* crt-list entry functions */
void ssl_sock_free_ssl_conf(struct ssl_bind_conf *conf);
char **crtlist_dup_filters(char **args, int fcount);
void crtlist_free_filters(char **args);
void crtlist_entry_free(struct crtlist_entry *entry);
struct crtlist_entry *crtlist_entry_new();

/* crt-list functions */
void crtlist_free(struct crtlist *crtlist);
struct crtlist *crtlist_new(const char *filename, int unique);

/* file loading */
int crtlist_parse_line(char *line, char **crt_path, struct crtlist_entry *entry, const char *file, int linenum, char **err);
int crtlist_parse_file(char *file, struct bind_conf *bind_conf, struct proxy *curproxy, struct crtlist **crtlist, char **err);
int crtlist_load_cert_dir(char *path, struct bind_conf *bind_conf, struct crtlist **crtlist, char **err);

5 years agoCLEANUP: ssl: add ckch prototypes in proto/ssl_ckch.h
William Lallemand [Tue, 12 May 2020 15:42:42 +0000 (17:42 +0200)] 
CLEANUP: ssl: add ckch prototypes in proto/ssl_ckch.h

Remove the static definitions of the ckch functions and add them to
ssl_ckch.h in order to use them outside ssl_sock.c.

5 years agoREORG: ssl: move the ckch structures to types/ssl_ckch.h
William Lallemand [Tue, 12 May 2020 12:46:24 +0000 (14:46 +0200)] 
REORG: ssl: move the ckch structures to types/ssl_ckch.h

Move all the structures used for loading the SSL certificates in
ssl_ckch.h

5 years agoREORG: move the crt-list structures in their own .h
William Lallemand [Tue, 12 May 2020 12:17:23 +0000 (14:17 +0200)] 
REORG: move the crt-list structures in their own .h

Move the structure definitions specifics to the crt-list in
types/ssl_crtlist.h.

5 years agoCLEANUP: ssl: remove the shsess_* macros
William Lallemand [Thu, 7 May 2020 13:28:02 +0000 (15:28 +0200)] 
CLEANUP: ssl: remove the shsess_* macros

The shsess_* macros where already defined in proto/ssl_sock.h, remove
them from ssl_sock.c

5 years agoREORG: ssl: move macros and structure definitions to ssl_sock.h
William Lallemand [Thu, 7 May 2020 13:20:43 +0000 (15:20 +0200)] 
REORG: ssl: move macros and structure definitions to ssl_sock.h

The ssl_sock.c file contains a lot of macros and structure definitions
that should be in a .h. Move them to the more appropriate
types/ssl_sock.h file.

5 years agoMEDIUM: ssl: use ssl_sock_get_ssl_object() in fetchers where appropriate
Dragan Dosen [Mon, 11 May 2020 15:25:19 +0000 (17:25 +0200)] 
MEDIUM: ssl: use ssl_sock_get_ssl_object() in fetchers where appropriate

Doing this also makes sure that conn->xprt_ctx is always checked before
using it.

5 years agoMINOR: ssl: add a new function ssl_sock_get_ssl_object()
Dragan Dosen [Mon, 11 May 2020 15:17:06 +0000 (17:17 +0200)] 
MINOR: ssl: add a new function ssl_sock_get_ssl_object()

This one can be used later to get a SSL object from connection. It will
return NULL if connection is not established over SSL.

5 years agoMEDIUM: ssl: split ssl_sock_msgcbk() and use a new callback mechanism
Dragan Dosen [Mon, 11 May 2020 13:51:45 +0000 (15:51 +0200)] 
MEDIUM: ssl: split ssl_sock_msgcbk() and use a new callback mechanism

Make use of ssl_sock_register_msg_callback(). Function ssl_sock_msgcbk()
is now split into two dedicated functions for heartbeat and clienthello.
They are both registered by using a new callback mechanism for SSL/TLS
protocol messages.

5 years agoMEDIUM: ssl: allow to register callbacks for SSL/TLS protocol messages
Dragan Dosen [Fri, 8 May 2020 16:30:00 +0000 (18:30 +0200)] 
MEDIUM: ssl: allow to register callbacks for SSL/TLS protocol messages

This patch adds the ability to register callbacks for SSL/TLS protocol
messages by using the function ssl_sock_register_msg_callback().

All registered callback functions will be called when observing received
or sent SSL/TLS protocol messages.

5 years agoDOC: retry-on can only be used with mode http
Jerome Magnin [Wed, 13 May 2020 18:09:57 +0000 (20:09 +0200)] 
DOC: retry-on can only be used with mode http

The documentation for retry-on hints at it being meant to be used
in conjuction with mode http, but since we've a had bug report
involving mode tcp and retry-on, lets make it explicit in the
documentation that it only works with mode http and will be
ignored otherwise.

5 years agoBUG/MEDIUM: stream: Only allow L7 retries when using HTTP.
Olivier Houchard [Wed, 13 May 2020 17:07:20 +0000 (19:07 +0200)] 
BUG/MEDIUM: stream: Only allow L7 retries when using HTTP.

Only allow L7 retries when using HTTP, it only really makes sense for HTTP,
anyway, and as the L7 retries code assume the message will be HTX, it will
crash when used with mode TCP.
This should fix github issue #627.

This should be backported to 2.1 and 2.0.

5 years agoBUG/MEDIUM: streams: Remove SF_ADDR_SET if we're retrying due to L7 retry.
Olivier Houchard [Tue, 12 May 2020 20:18:14 +0000 (22:18 +0200)] 
BUG/MEDIUM: streams: Remove SF_ADDR_SET if we're retrying due to L7 retry.

In do_l7_retry(), remove the SF_ADDR_SET flag. Otherwise,
assign_server_address() won't be called again, which means for 2.1 or 2.2,
we will always retry to connect to the server that just failed, and for 2.0,
that we will try to use to whatever the address is for the connection,
probably the last server used by that connection before it was pool_free()
and reallocated.

This should be backported to 2.1 and 2.0.

5 years agoBUILD: select: only declare existing local labels to appease clang
Jerome Magnin [Wed, 13 May 2020 13:11:02 +0000 (15:11 +0200)] 
BUILD: select: only declare existing local labels to appease clang

Commit 42a50bd19 ("BUG/MINOR: pollers: remove uneeded free in global
init") removed the 'fail_revt' label from the _do_init() function
in src/ev_select.c but left the local label declaration, which makes
clang unhappy and unable to build.

These labels are only historic and unneeded anyway so let's remove them.

This should be backported where 42a50bd19 is backported.

5 years agoMINOR: soft-stop: let the first stopper only signal other threads
Willy Tarreau [Wed, 13 May 2020 12:30:25 +0000 (14:30 +0200)] 
MINOR: soft-stop: let the first stopper only signal other threads

When the first thread stops and wakes others up, it's possible some of
them will also start to wake others in parallel. Let's make give this
notification task to the very first one instead since it's enough and
can reduce the amount of needless (though harmless) wakeup calls.

5 years agoBUG/MINOR: soft-stop: always wake up waiting threads on stopping
Willy Tarreau [Wed, 13 May 2020 11:51:01 +0000 (13:51 +0200)] 
BUG/MINOR: soft-stop: always wake up waiting threads on stopping

Currently the soft-stop can lead to old processes remaining alive for as
long as two seconds after receiving a soft-stop signal. What happens is
that when receiving SIGUSR1, one thread (usually the first one) wakes up,
handles the signal, sets "stopping", goes into runn_poll_loop(), and
discovers that stopping is set, so its also sets itself in the
stopping_thread_mask bit mask. After this it sees that other threads are
not yet willing to stop, so it continues to wait.

From there, other threads which were waiting in poll() expire after one
second on poll timeout and enter run_poll_loop() in turn. That's already
one second of wait time. They discover each in turn that they're stopping
and see that other threads are not yet stopping, so they go back waiting.

After the end of the first second, all threads know they're stopping and
have set their bit in stopping_thread_mask. It's only now that those who
started to wait first wake up again on timeout to discover that all other
ones are stopping, and can now quit. One second later all threads will
have done it and the process will quit.

This is effectively strictly larger than one second and up to two seconds.

What the current patch does is simple, when the first thread stops, it sets
its own bit into stopping_thread_mask then wakes up all other threads to do
also set theirs. This kills the first second which corresponds to the time
to discover the stopping state. Second, when a thread exists, it wakes all
other ones again because some might have gone back sleeping waiting for
"jobs" to go down to zero (i.e. closing the last connection). This kills
the last second of wait time.

Thanks to this, as SIGUSR1 now acts instantly again if there's no active
connection, or it stops immediately after the last connection has left if
one was still present.

This should be backported as far as 2.0.

5 years agoCLEANUP: select: enhance readability in init
William Dauchy [Mon, 11 May 2020 13:20:05 +0000 (15:20 +0200)] 
CLEANUP: select: enhance readability in init

while reading the code, I thought it was clearer to put one instruction
per line as it is mostly done elsewhere

Signed-off-by: William Dauchy <w.dauchy@criteo.com>
5 years agoBUG/MINOR: pollers: remove uneeded free in global init
William Dauchy [Mon, 11 May 2020 13:20:03 +0000 (15:20 +0200)] 
BUG/MINOR: pollers: remove uneeded free in global init

Since commit d4604adeaa8c ("MAJOR: threads/fd: Make fd stuffs
thread-safe"), we init pollers per thread using a helper. It was still
correct for mono-thread mode until commit cd7879adc2c4 ("BUG/MEDIUM:
threads: Run the poll loop on the main thread too"). We now use a deinit
helper for all threads, making those free uneeded.

Only poll and select are affected by this very minor issue.

it could be backported from v1.8 to v2.1.

Fixes: cd7879adc2c4 ("BUG/MEDIUM: threads: Run the poll loop on the main
thread too")
Signed-off-by: William Dauchy <w.dauchy@criteo.com>
5 years agoBUG/MINOR: pools: use %u not %d to report pool stats in "show pools"
Willy Tarreau [Wed, 6 May 2020 15:10:37 +0000 (17:10 +0200)] 
BUG/MINOR: pools: use %u not %d to report pool stats in "show pools"

In dump_pools_to_trash() we happen to use %d to display unsigned ints!

This has probably been there since "show pools" was introduced so this
fix must be backported to all versions. The impact is negligible since
no pool uses 2 billion entries. It could possibly affect the report of
failed allocation counts but in this case there's a bigger problem to
solved!

5 years agoBUG/MINOR: sample/ssl: Fix digest converter for openssl < 1.1.0
Christopher Faulet [Tue, 12 May 2020 14:19:03 +0000 (16:19 +0200)] 
BUG/MINOR: sample/ssl: Fix digest converter for openssl < 1.1.0

The EVP_MD_CTX_create() and EVP_MD_CTX_destroy() functions were renamed to
EVP_MD_CTX_new() and EVP_MD_CTX_free() in OpenSSL 1.1.0, respectively. These
functions are used by the digest converter, introduced by the commit 8e36651ed
("MINOR: sample: Add digest and hmac converters"). So for prior versions of
openssl, macros are used to fallback on old functions.

This patch must only be backported if the commit 8e36651ed is backported too.

5 years agoBUG/MEDIUM: checks: Subscribe to I/O events only if a mux was installed
Christopher Faulet [Tue, 12 May 2020 13:05:43 +0000 (15:05 +0200)] 
BUG/MEDIUM: checks: Subscribe to I/O events only if a mux was installed

In the commit 2fabd9d53 ("BUG/MEDIUM: checks: Subscribe to I/O events on an
unfinished connect"), we force the subscribtion to I/O events when a new
connection is opened if it is not fully established. But it must only be done if
a mux was immediately installed. If there is no mux, no subscription must be
performed.

No backport needed.

5 years agoMINOR: sample: Add digest and hmac converters
Patrick Gansterer [Wed, 22 Apr 2020 14:47:57 +0000 (16:47 +0200)] 
MINOR: sample: Add digest and hmac converters

Make the digest and HMAC function of OpenSSL accessible to the user via
converters. They can be used to sign and validate content.

Reviewed-by: Tim Duesterhus <tim@bastelstu.be>
5 years agoMINOR: sample: Move aes_gcm_dec implementation into sample.c
Patrick Gansterer [Sun, 17 Jun 2018 09:21:11 +0000 (11:21 +0200)] 
MINOR: sample: Move aes_gcm_dec implementation into sample.c

aes_gcm_dec is independent of the TLS implementation and fits better
in sample.c file with others hash functions.

[Cf: I slightly updated this patch to move aes_gcm_dec converter in sample.c
     instead the new file crypto.c]

Reviewed-by: Tim Duesterhus <tim@bastelstu.be>
5 years agoMINOR: checks: Don't try to send outgoing data if waiting to be able to send
Christopher Faulet [Sat, 9 May 2020 15:37:43 +0000 (17:37 +0200)] 
MINOR: checks: Don't try to send outgoing data if waiting to be able to send

It is useless to try to send outgoing data if the check is still waiting to be
able to send data.

No backport needed.

(cherry picked from commit d94653700437430864c03090d710b95f4e860321)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
5 years agoBUG/MINOR: checks: Rely on next I/O oriented rule when waiting for a connection
Christopher Faulet [Sat, 9 May 2020 15:34:43 +0000 (17:34 +0200)] 
BUG/MINOR: checks: Rely on next I/O oriented rule when waiting for a connection

In tcpcheck_main(), when we are waiting for a connection, we must rely on the
next connect/send/expect rule to subscribe to I/O events, not on the immediate
next rule. Because, if it is a set-var or an unset-var rule, we will not
subscribe to I/O events while it is in fact mandatory because a send or an
expect rule is coming. It is required to wake-up the health check as soon as I/O
are possible, instead of hitting a timeout.

No backport needed.

(cherry picked from commit 758d48f54cc3372c2d8e7c34b926d218089c533a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
5 years agoBUG/MINOR: checks: Don't subscribe to I/O events if it is already done
Christopher Faulet [Sat, 9 May 2020 15:27:43 +0000 (17:27 +0200)] 
BUG/MINOR: checks: Don't subscribe to I/O events if it is already done

Subscription to I/O events should not be performed if the check is already
subscribed.

No backport needed.

(cherry picked from commit 9e0b3e92f73b6715fb2814e3d09b8ba62270b417)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
5 years agoBUG/MEDIUM: checks: Subscribe to I/O events on an unfinished connect
Christopher Faulet [Sat, 9 May 2020 12:46:43 +0000 (14:46 +0200)] 
BUG/MEDIUM: checks: Subscribe to I/O events on an unfinished connect

In tcp-check based health check, when a new connection is opened, we must wait
it is really established before moving to the next rule. But at this stage, we
must also be sure to subscribe to I/O events. Otherwise, depending on the
timing, the health check may remains sleepy till the timeout.

No backport needed. This patch should fix the issue #622.

(cherry picked from commit b2a4c0d473e3c5dcb87f7d16f2ca410bafc62f64)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
5 years agoMAJOR: contrib: porting spoa_server to support python3
Gilchrist Dadaglo [Wed, 6 May 2020 12:25:31 +0000 (12:25 +0000)] 
MAJOR: contrib: porting spoa_server to support python3

Background:
    Python 2 is no longer supported since January, 1st 2020 as per
    https://www.python.org/doc/sunset-python-2/
    The purpose of this change is to make the spoa_server contrib library
    compatible with Python 3 to allow transition to Python 3.

Test Settings:
ps_python.py:
    ...
    spoa.set_var_null("null", spoa.scope_txn)
    spoa.set_var_boolean("boolean", spoa.scope_txn, True)
    spoa.set_var_int32("int32", spoa.scope_txn, 1234)
    spoa.set_var_uint32("uint32", spoa.scope_txn, 1234)
    spoa.set_var_int64("int64", spoa.scope_txn, 1234)
    spoa.set_var_uint64("uint64", spoa.scope_txn, 1234)
    spoa.set_var_ipv4("ipv4", spoa.scope_txn, ipaddress.IPv4Address(u"127.0.0.1"))
    spoa.set_var_ipv6("ipv6", spoa.scope_txn, ipaddress.IPv6Address(u"1::f"))
    spoa.set_var_str("str", spoa.scope_txn, "1::f")
    spoa.set_var_bin("bin", spoa.scope_txn, "1:\x01:\x42f\x63\x63")
    spoa.set_var_str("python_version", spoa.scope_sess, str(sys.version_info))
    ...
haproxy.cfg:
    ...
    http-request capture var(txn.verb.null),debug len 1
    http-request capture var(txn.verb.boolean),debug len 1
    http-request capture var(txn.verb.int32),debug len 4
    http-request capture var(txn.verb.uint32),debug len 4
    http-request capture var(txn.verb.int64),debug len 4
    http-request capture var(txn.verb.uint64),debug len 4
    http-request capture var(txn.verb.ipv4),debug len 16
    http-request capture var(txn.verb.ipv6),debug len 45
    http-request capture var(txn.verb.str),debug len 32
    http-request capture var(txn.verb.bin),debug len 32
    http-request capture var(sess.verb.python_version),debug len 100
    ...

Test result:
    Python 3.8:
        ft_public ft_public/<NOSRV> 0/-1/-1/-1/0 403 212 - - PR-- 1/1/0/0/0 0/0 {|1|1234|1234|1234|1234|127.0.0.1|1::f|1::f|1:#01:Bfcc|sys.version_info(major=3, minor=8, micro=1, releaselevel='final', serial=0)} "POST / HTTP/1.1"
    Python 3.7:
        ft_public ft_public/<NOSRV> 0/-1/-1/-1/0 403 212 - - PR-- 1/1/0/0/0 0/0 {|1|1234|1234|1234|1234|127.0.0.1|1::f|1::f|1:#01:Bfcc|sys.version_info(major=3, minor=7, micro=6, releaselevel='final', serial=0)} "POST / HTTP/1.1"
    Python 3.6:
        ft_public ft_public/<NOSRV> 0/-1/-1/-1/0 403 212 - - PR-- 1/1/0/0/0 0/0 {|1|1234|1234|1234|1234|127.0.0.1|1::f|1::f|1:#01:Bfcc|sys.version_info(major=3, minor=6, micro=10, releaselevel='final', serial=0)} "POST / HTTP/1.1"
    Python 2.7:
        ft_public ft_public/<NOSRV> 0/-1/-1/-1/0 403 212 - - PR-- 1/1/0/0/0 0/0 {|1|1234|1234|1234|1234|127.0.0.1|1::f|1::f|1:#01:Bfcc|sys.version_info(major=2, minor=7, micro=17, releaselevel='final', serial=0)} "POST / HTTP/1.1"

Not tested:
Python <2.7

5 years agoCLEANUP: assorted typo fixes in the code and comments
Ilya Shipitsin [Tue, 5 May 2020 19:53:22 +0000 (00:53 +0500)] 
CLEANUP: assorted typo fixes in the code and comments

This is 9th iteration of typo fixes

5 years agoCI: extend spellchecker whitelist
Ilya Shipitsin [Tue, 5 May 2020 16:20:54 +0000 (21:20 +0500)] 
CI: extend spellchecker whitelist

let us ignore *.fig files as well as "que" and "ans" words

5 years agoDOC: assorted typo fixes in the documentation
Ilya Shipitsin [Tue, 5 May 2020 16:17:10 +0000 (21:17 +0500)] 
DOC: assorted typo fixes in the documentation

This is the 8th round of cleanups in various docs

5 years agoCI: travis-ci: upgrade LibreSSL versions
Ilya Shipitsin [Sat, 9 May 2020 16:36:04 +0000 (21:36 +0500)] 
CI: travis-ci: upgrade LibreSSL versions

3.0.2 --> 3.1.1
2.9.2 --> 3.0.2
2.8.3 --> 2.9.2

5 years agoCLEANUP: remove THREAD_LOCAL from config.h
Willy Tarreau [Sat, 9 May 2020 07:08:09 +0000 (09:08 +0200)] 
CLEANUP: remove THREAD_LOCAL from config.h

This one really ought to be defined in hathreads.h like all other thread
definitions, which is what this patch does. As expected, all files but
one (regex.h) were already including hathreads.h when using THREAD_LOCAL;
regex.h was fixed for this.

This was the last entry in config.h which is now useless.

5 years agoCLENAUP: config: move CONFIG_HAP_LOCKLESS_POOLS out of config.h
Willy Tarreau [Sat, 9 May 2020 07:02:35 +0000 (09:02 +0200)] 
CLENAUP: config: move CONFIG_HAP_LOCKLESS_POOLS out of config.h

The setting of CONFIG_HAP_LOCKLESS_POOLS depending on threads and
compat was done in config.h for use only in memory.h and memory.c
where other settings are dealt with. Further, the default pool cache
size was set there from a fixed value instead of being set from
defaults.h

Let's move the decision to enable lockless pools via
CONFIG_HAP_LOCKLESS_POOLS to memory.h, and set the default pool
cache size in defaults.h like other default settings.

This was the next-to-last setting in config.h.

5 years agoCLEANUP: config: drop unused setting CONFIG_HAP_INLINE_FD_SET
Willy Tarreau [Sat, 9 May 2020 06:57:48 +0000 (08:57 +0200)] 
CLEANUP: config: drop unused setting CONFIG_HAP_INLINE_FD_SET

CONFIG_HAP_INLINE_FD_SET was introduced in 1.3.3 and dropped in 1.3.9
when the pollers were reworked, let's remove it.

5 years agoCLEANUP: config: drop unused setting CONFIG_HAP_MEM_OPTIM
Willy Tarreau [Sat, 9 May 2020 06:53:31 +0000 (08:53 +0200)] 
CLEANUP: config: drop unused setting CONFIG_HAP_MEM_OPTIM

CONFIG_HAP_MEM_OPTIM was introduced with memory pools in 1.3 and dropped
in 1.6 when pools became the only way to allocate memory. Still the
option remained present in config.h. Let's kill it.

5 years agoCI: travis-ci: extend the build time for SSL to 60 minutes
Willy Tarreau [Fri, 8 May 2020 12:18:50 +0000 (14:18 +0200)] 
CI: travis-ci: extend the build time for SSL to 60 minutes

As discussed in the thread below we're still facing build timeouts
on Travis on aarch64 and the truncated logs doesn't help. It's not
PCRE2 so let's try to extend the permitted time to build the SSL
lib.

   https://www.mail-archive.com/haproxy@formilux.org/msg37251.html

5 years agoCI: travis-ci: skip pcre2 on arm64 build
Ilya Shipitsin [Fri, 8 May 2020 10:25:56 +0000 (15:25 +0500)] 
CI: travis-ci: skip pcre2 on arm64 build

currently arm64 stuck with some error related to pcre2. while we beleive
pcre2 is not related to error itself, we can try not to install it

5 years agoMEDIUM: ssl: increase default-dh-param to 2048
Willy Tarreau [Fri, 8 May 2020 07:31:18 +0000 (09:31 +0200)] 
MEDIUM: ssl: increase default-dh-param to 2048

For 6 years now we've been seeing a warning suggesting to set dh-param
beyond 1024 if possible when it was not set. It's about time to do it
and get rid of this warning since most users seem to already use 2048.
It will remain possible to set a lower value of course, so only those
who were experiencing the warning and were relying on the default value
may notice a change (higher CPU usage). For more context, please refer
to this thread :

  https://www.mail-archive.com/haproxy@formilux.org/msg37226.html

This commit removes a big chunk of code which happened to be needed
exclusively to figure if it was required to emit a warning or not :-)

5 years agoCI: travis-ci: enable arm64 builds again
Ilya Shipitsin [Thu, 7 May 2020 15:57:26 +0000 (20:57 +0500)] 
CI: travis-ci: enable arm64 builds again

travis-ci arm64 were temporarily disabled due to travis instability.
let us enable them in "allowed to fail" mode.

5 years agoMINOR: cfgparse: Improve error message for invalid \x sequences
Tim Duesterhus [Thu, 7 May 2020 17:24:20 +0000 (19:24 +0200)] 
MINOR: cfgparse: Improve error message for invalid \x sequences

This patch states the invalid \x sequence within the error message.

5 years agoBUG/MINOR: cfgparse: Abort parsing the current line if an invalid \x sequence is...
Tim Duesterhus [Thu, 7 May 2020 17:21:31 +0000 (19:21 +0200)] 
BUG/MINOR: cfgparse: Abort parsing the current line if an invalid \x sequence is encountered

This fixes OSS Fuzz issue https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=21931.

OSS Fuzz detected a hang on configuration parsing for a 200kB line with a large number of
invalid escape sequences. Most likely due to the amounts of error output generated.

This issue is very minor, because usually generated configurations are to be trusted.

The bug exists since at the very least HAProxy 1.4. The patch may be backported if desired.

5 years agoBUG/MEDIUM: http_ana: make the detection of NTLM variants safer
Willy Tarreau [Thu, 7 May 2020 17:27:02 +0000 (19:27 +0200)] 
BUG/MEDIUM: http_ana: make the detection of NTLM variants safer

In issue #511 a problem was reported regarding NTLM and undesired session
sharing. This was caused by an attempt to limit the protection against
NTLM breakage to just NTLM and not properly working schemes in commit
fd9b68c48 ("BUG/MINOR: only mark connections private if NTLM is detected").

Unfortunately as reported in the issue above, the extent of possible
challenges for NTLM is a bit more complex than just the "NTLM" or
"Negotiate" words. There's also "Nego2" and these words can be followed
by a base64 value, which is not validated here. The list of possible
entries doesn't seem to be officially documented but can be reconstructed
from different public documents:

  https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-ntht/7daaf621-94d9-4942-a70a-532e81ba293e
  https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-n2ht/5c1d2bbc-e1d6-458f-9def-dd258c181310
  https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-n2ht/9201ed70-d245-41ce-accd-e609637583bf
  https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-n2ht/02be79f3-e360-475f-b468-b96c878c70c7

This patch tries to fix all this on top of previous attempts by making
as private any connection that returns a www-authenticate header starting
with "Nego" or "NTLM". We don't need to be too strict, we really just
want to leave the connection shared if really sure it can be.

This must be backported to 1.8 but will require some adaptations. In
1.9 and 2.0 the check appears both for legacy and HTX. The simplest
thing to do is to look for "Negotiate" and fix all relevant places.

5 years agoBUG/MINOR: http-ana: fix NTLM response parsing again
Willy Tarreau [Thu, 7 May 2020 17:10:15 +0000 (19:10 +0200)] 
BUG/MINOR: http-ana: fix NTLM response parsing again

Commit 9df188695f ("BUG/MEDIUM: http-ana: Handle NTLM messages correctly.")
tried to address an HTTP-reuse issue reported in github issue #511 by making
sure we properly detect extended NTLM responses, but made the match case-
sensitive while it's a token so it's case insensitive.

This should be backported to the same versions as the commit above.

5 years agoREGTESTS: make the http-check-send test require version 2.2
Willy Tarreau [Thu, 7 May 2020 16:42:22 +0000 (18:42 +0200)] 
REGTESTS: make the http-check-send test require version 2.2

It causes failures when passing regtests on older releases.

5 years agoBUG/MINOR: config: Make use_backend and use-server post-parsing less obscur
Christopher Faulet [Thu, 7 May 2020 13:59:33 +0000 (15:59 +0200)] 
BUG/MINOR: config: Make use_backend and use-server post-parsing less obscur

During use_backend and use-server post-parsing, if the log-format string used to
specify the backend or the server is just a single string, the log-format string
(a list, internally) is replaced by the string itself. Because the field is an
union, the list is not emptied according to the rules of art. The element, when
released, is not removed from the list. There is no bug, but it is clearly not
obvious and error prone.

This patch should fix #544. The fix for the use_backend post-parsing may be
backported to all stable releases. use-server is static in 2.1 and prior.

5 years agoBUG/MEDIUM: lua: Fix dumping of stick table entries for STD_T_DICT
Adis Nezirovic [Tue, 5 May 2020 11:57:28 +0000 (13:57 +0200)] 
BUG/MEDIUM: lua: Fix dumping of stick table entries for STD_T_DICT

The issue can easily be reproduced with "stick on" statement

backend BE_NAME
    stick-table type ip size 1k
    stick on src

and calling dump() method on BE_NAME stick table from Lua

Before the fix, HAProxy would return 500 and log something like
the following:
  runtime error: attempt to index a string value from [C] method 'dump'

Where one would expect a Lua table like this:

{
    ["IP_ADDR"] = {
        ["server_id"] = 1,
        ["server_name"] = "srv1"
    }
}

This patch needs to backported to 1.9 and later releases.

5 years agoMINOR: checks: Make matching on HTTP headers for expect rules less obscure
Christopher Faulet [Thu, 7 May 2020 13:41:39 +0000 (15:41 +0200)] 
MINOR: checks: Make matching on HTTP headers for expect rules less obscure

A default statement in the switch testing the header name has been added to be
sure it is impossible to eval the value pattern on an uninitialized header
value. It should never happen of course. But this way, it is explicit.

And a comment has been added to make clear that ctx.value is always defined when
it is evaluated.

This patch fixes the issue #619.

5 years agoDOC: Be more explicit about configurable check ok/error/timeout status
Christopher Faulet [Thu, 7 May 2020 05:40:17 +0000 (07:40 +0200)] 
DOC: Be more explicit about configurable check ok/error/timeout status

It is possible to configure the check status on success, on error and on
timeout, for http-check and tcp-check expect rules. But the documentation relies
on internal names. These names are reported on the stats and are describe in the
management guide. But it is probably a good idea to be more explicit too in the
doc describing these options.

5 years agoMINOR: checks: Support log-format string to set the body for HTTP send rules
Christopher Faulet [Wed, 6 May 2020 13:38:58 +0000 (15:38 +0200)] 
MINOR: checks: Support log-format string to set the body for HTTP send rules

For http-check send rules, it is now possible to use a log-format string to set
the request's body. the keyword "body-lf" should be used instead of "body". If the
string eval fails, no body is added.

5 years agoMINOR: checks: Support log-format string to set the URI for HTTP send rules
Christopher Faulet [Wed, 6 May 2020 13:06:34 +0000 (15:06 +0200)] 
MINOR: checks: Support log-format string to set the URI for HTTP send rules

For http-check send rules, it is now possible to use a log-format string to set
the request URI. the keyword "uri-lf" should be used instead of "uri". If the
string eval fails, we fall back on the default uri "/".

5 years agoMINOR: mworker: replace ha_alert by ha_warning when exiting successfuly
William Lallemand [Wed, 6 May 2020 15:27:03 +0000 (17:27 +0200)] 
MINOR: mworker: replace ha_alert by ha_warning when exiting successfuly

Since commit bb86986 ("MINOR: init: report the haproxy version and
executable path once on errors") the master-worker displays its version
and path upon a successful exits of a current worker. Which is kind of
confusing upon a clean exits.

This is due to the fact that that commit displays this upon a ha_alert()
which was used during the exit of the process.

Replace the ha_alert() by an ha_warning() if the process exit correctly
and was supposed to.

It still displays the message upon a SIGINT since the workers are
catching the signal.

5 years agoREGTEST: checks: Adapt SSL error message reported when connection is rejected
Christopher Faulet [Wed, 6 May 2020 09:10:51 +0000 (11:10 +0200)] 
REGTEST: checks: Adapt SSL error message reported when connection is rejected

Depending on the SSL library version, the reported error may differ when the
connection is rejected during the handshake. An empty handshke may be detected
or just an generic handshake error. So tcp-check-ssl.vtc has been adapted to
support both error messages.

5 years agoMINOR: checks/sample: Remove unnecessary tests on the sample session
Christopher Faulet [Wed, 6 May 2020 07:42:04 +0000 (09:42 +0200)] 
MINOR: checks/sample: Remove unnecessary tests on the sample session

A sample must always have a session defined. Otherwise, it is a bug. So it is
unnecessary to test if it is defined when called from a health checks context.

This patch fixes the issue #616.