]> git.ipfire.org Git - thirdparty/dovecot/core.git/log
thirdparty/dovecot/core.git
6 years agoauth: Add support for oauth2 password grant
Sergey Kitov [Tue, 5 Feb 2019 07:43:09 +0000 (09:43 +0200)] 
auth: Add support for oauth2 password grant

6 years agolib-oauth2: Implement password grant authentication.
Sergey Kitov [Tue, 5 Feb 2019 07:45:07 +0000 (09:45 +0200)] 
lib-oauth2: Implement password grant authentication.

6 years agolib-oauth2: Take http_client_request_url_str in use for oauth2 requests.
Sergey Kitov [Thu, 31 Jan 2019 08:36:49 +0000 (10:36 +0200)] 
lib-oauth2: Take http_client_request_url_str in use for oauth2 requests.

6 years agolib-http: Expose origin_url of the struct http_client_request
Sergey Kitov [Thu, 31 Jan 2019 08:31:43 +0000 (10:31 +0200)] 
lib-http: Expose origin_url of the struct http_client_request

6 years agosubmission-login: Only overwrite XCLIENT fields in the client when a value is assigned.
Stephan Bosch [Wed, 13 Feb 2019 21:21:21 +0000 (22:21 +0100)] 
submission-login: Only overwrite XCLIENT fields in the client when a value is assigned.

Before, omitted fields in the XCLIENT command would cause the values in the
client to be reset to the equivalent of zero.

6 years agolib-smtp: Mark default as unreached in smtp_client_command_abort
Aki Tuomi [Fri, 8 Feb 2019 18:47:42 +0000 (20:47 +0200)] 
lib-smtp: Mark default as unreached in smtp_client_command_abort

Satisfies static analyzers

6 years agolib-smtp: smtp-client-command - Avoid calling the callback for the DATA command durin...
Stephan Bosch [Thu, 7 Feb 2019 01:37:27 +0000 (02:37 +0100)] 
lib-smtp: smtp-client-command - Avoid calling the callback for the DATA command during submission.

This causes a race condition in which the command object is already freed when
it is returned from smtp_client_command_data_submit(). This scenario occurs when
reading data for the first BDAT command fails.

6 years agolib-smtp: smtp-client - Send correct size value for BDAT command when the data lacks CR.
Stephan Bosch [Wed, 6 Feb 2019 19:54:26 +0000 (20:54 +0100)] 
lib-smtp: smtp-client - Send correct size value for BDAT command when the data lacks CR.

The addition of CR was ignored in the size specification because the original
unaltered stream was used for the size calculations.

6 years agolib: istreams - Don't lose IO pending state when unsetting and setting io
Timo Sirainen [Tue, 22 Jan 2019 20:45:33 +0000 (22:45 +0200)] 
lib: istreams - Don't lose IO pending state when unsetting and setting io

This makes sure that the pending state stays even after io_remove() when
io_add_istream() is again called.

6 years agolib: Fix i_stream_set_input_pending() when IO is set later
Timo Sirainen [Tue, 22 Jan 2019 10:59:57 +0000 (12:59 +0200)] 
lib: Fix i_stream_set_input_pending() when IO is set later

After i_stream_set_io() is called to set the IO, it should already be marked
as pending.

This fixes at least running imaptest with SSL.

6 years agolib: Add io_is_pending()
Timo Sirainen [Tue, 22 Jan 2019 20:43:53 +0000 (22:43 +0200)] 
lib: Add io_is_pending()

6 years agolib-index: Add mail_index_append_finish_uids_full()
Timo Sirainen [Wed, 23 Jan 2019 15:22:27 +0000 (17:22 +0200)] 
lib-index: Add mail_index_append_finish_uids_full()

6 years agolib-index: mail_index_append_finish_uids() cleanup: remove unnecessary if check
Timo Sirainen [Wed, 23 Jan 2019 15:29:22 +0000 (17:29 +0200)] 
lib-index: mail_index_append_finish_uids() cleanup: remove unnecessary if check

It was pretty confusing, and it was always TRUE.

6 years agodoveadm: Use doveadm_get_ssl_settings
Aki Tuomi [Thu, 15 Nov 2018 12:47:32 +0000 (14:47 +0200)] 
doveadm: Use doveadm_get_ssl_settings

6 years agodoveadm: dsync - use mail_storage_settings_init_ssl_client_settings
Aki Tuomi [Thu, 15 Nov 2018 12:46:44 +0000 (14:46 +0200)] 
doveadm: dsync - use mail_storage_settings_init_ssl_client_settings

6 years agolib-storage: mail-user - Use mail_storage_settings_init_ssl_client_settings
Aki Tuomi [Thu, 15 Nov 2018 12:42:28 +0000 (14:42 +0200)] 
lib-storage: mail-user - Use mail_storage_settings_init_ssl_client_settings

6 years agomail-storage: Add mail_storage_settings_init_ssl_client_settings
Aki Tuomi [Thu, 15 Nov 2018 12:40:46 +0000 (14:40 +0200)] 
mail-storage: Add mail_storage_settings_init_ssl_client_settings

Simplifies following commits

6 years agodoveadm: Use master service SSL settings
Aki Tuomi [Thu, 15 Nov 2018 12:35:36 +0000 (14:35 +0200)] 
doveadm: Use master service SSL settings

6 years agolib-smtp: client: Fix dead assignment in smtp_client_command_pipeline_is_open().
Stephan Bosch [Tue, 22 Jan 2019 21:06:38 +0000 (22:06 +0100)] 
lib-smtp: client: Fix dead assignment in smtp_client_command_pipeline_is_open().

Found by scan-build.

6 years agolib-smtp: command: Move main loop from sub-function to smtp_client_command_send_more...
Stephan Bosch [Sun, 9 Dec 2018 11:13:59 +0000 (12:13 +0100)] 
lib-smtp: command: Move main loop from sub-function to smtp_client_command_send_more() itself.

This reduces code indent in smtp_client_command_do_send_more() (the
sub-function) and it turns the inifite for loop into a nice conditional
while loop.

6 years agolib-smtp: test-smtp-client-errors: Test early DATA command success and error replies.
Stephan Bosch [Sun, 11 Nov 2018 22:32:15 +0000 (23:32 +0100)] 
lib-smtp: test-smtp-client-errors: Test early DATA command success and error replies.

Early success for the DATA command is treated as a protocol error, while early
failure is allowed. Both situations are tested in a new scenario for the
test-smtp-client-errors unit test.

6 years agolib-smtp: client: Fix handling of non-blocking command payload stream.
Stephan Bosch [Sun, 11 Nov 2018 22:25:50 +0000 (23:25 +0100)] 
lib-smtp: client: Fix handling of non-blocking command payload stream.

By inference, this fixes the handling of non-blocking transaction payload as
well. No io was created when the payload stream returned no data.

6 years agolib-smtp: test-smtp-client-errors: Add test scenario for premature success replies.
Stephan Bosch [Sun, 11 Nov 2018 19:30:25 +0000 (20:30 +0100)] 
lib-smtp: test-smtp-client-errors: Add test scenario for premature success replies.

Such replies are sent immediately along with the reply of the previous command.
So, the reply is sent before the corresponding command is even submitted. This
tests whether the client handles this erroneous situation correctly.

6 years agolib-smtp: test-smtp-payload: Add option to test payload exchange with small socket...
Stephan Bosch [Thu, 16 Aug 2018 20:34:53 +0000 (22:34 +0200)] 
lib-smtp: test-smtp-payload: Add option to test payload exchange with small socket buffers.

This is not part of the normal `make check` procedure, since using small socket
buffers makes the test extremely slow.

6 years agolib-smtp: client: Allow receiving replies before command data stream is sent completely.
Stephan Bosch [Wed, 15 Aug 2018 16:29:11 +0000 (18:29 +0200)] 
lib-smtp: client: Allow receiving replies before command data stream is sent completely.

This avoids unnecessary problems with servers that reply somewhat early to DATA
and BDAT commands. For one, early failure replies are now handled properly.
Also, race conditions at the client between sending the closing CRLF.CRLF and
receiving the DATA reply are no longer causing problems.

6 years agolib-smtp: client: Put moving a command from the queue to the wait list in a separate...
Stephan Bosch [Sun, 9 Dec 2018 10:34:56 +0000 (11:34 +0100)] 
lib-smtp: client: Put moving a command from the queue to the wait list in a separate function.

6 years agolib-smtp: client: Put determining the status of the command pipeline in a separate...
Stephan Bosch [Thu, 16 Aug 2018 20:15:36 +0000 (22:15 +0200)] 
lib-smtp: client: Put determining the status of the command pipeline in a separate function.

6 years agolib-smtp: client: Put sending the command line in a separate function.
Stephan Bosch [Thu, 16 Aug 2018 20:07:08 +0000 (22:07 +0200)] 
lib-smtp: client: Put sending the command line in a separate function.

6 years agolib-smtp: client: Don't put connection in TRANSACTION state unless there's a transaction.
Stephan Bosch [Mon, 21 Jan 2019 21:21:03 +0000 (22:21 +0100)] 
lib-smtp: client: Don't put connection in TRANSACTION state unless there's a transaction.

Fixes hang occurring when connection is ready before transaction is started.

6 years agoquota: Rename quota_set_resource() error_r to client_error_r
Martti Rannanjärvi [Mon, 21 Jan 2019 08:50:24 +0000 (10:50 +0200)] 
quota: Rename quota_set_resource() error_r to client_error_r

Don't pass on the error from dict_init() to client, though.

6 years agoimap-acl: Rename error_r sent to client as client_error_r
Martti Rannanjärvi [Mon, 21 Jan 2019 11:01:27 +0000 (13:01 +0200)] 
imap-acl: Rename error_r sent to client as client_error_r

6 years agolib-imap-urlauth: Rename error_r sent to clients as client_error_r
Martti Rannanjärvi [Mon, 21 Jan 2019 11:00:09 +0000 (13:00 +0200)] 
lib-imap-urlauth: Rename error_r sent to clients as client_error_r

6 years agolib-imap-storage: Rename error_r sent to clients as client_error_r
Martti Rannanjärvi [Mon, 21 Jan 2019 10:59:45 +0000 (12:59 +0200)] 
lib-imap-storage: Rename error_r sent to clients as client_error_r

6 years agoimap,lib-storage: Rename error_r sent to clients as client_error_r
Martti Rannanjärvi [Mon, 21 Jan 2019 10:41:20 +0000 (12:41 +0200)] 
imap,lib-storage: Rename error_r sent to clients as client_error_r

6 years agosubmission-login: proxy: Fix omission of spaces between XCLIENT command parameters.
Anton Dollmaier [Thu, 27 Sep 2018 21:00:22 +0000 (23:00 +0200)] 
submission-login: proxy: Fix omission of spaces between XCLIENT command parameters.

It would send for example:

> XCLIENT ADDR=10.0.1.2PORT=39074

The other end will obviously not accept this.

--
Commit message modified by Stephan Bosch

6 years agolib-smtp: client: BDAT command: Make sure the message contains CRLF consistently.
Stephan Bosch [Sat, 8 Sep 2018 18:54:54 +0000 (20:54 +0200)] 
lib-smtp: client: BDAT command: Make sure the message contains CRLF consistently.

Before, only messages sent using DATA command guaranteed consistent CRLF,
because these are sent using o_stream_dot(), which does that internally. For the
BDAT command, the message was sent as-is, which is not always accepted by MTAs.

6 years agolib-smtp: client: BDAT command: Ensure data stream max buffer size is appropriate...
Stephan Bosch [Fri, 26 Oct 2018 10:15:45 +0000 (12:15 +0200)] 
lib-smtp: client: BDAT command: Ensure data stream max buffer size is appropriate when stream size is unknown.

When stream size is unknown, the chunk size are determined by what can be
buffered in the data input stream immediately. If it's maximum buffer size is
(much) smaller than the maximum chunk size, the maximum chunk size is never
achieved.

6 years agolib-smtp: server: Fix forwarding a multi-line reply.
Stephan Bosch [Fri, 26 Oct 2018 14:17:06 +0000 (16:17 +0200)] 
lib-smtp: server: Fix forwarding a multi-line reply.

A multi-line reply had the '-' on the first line stripped upon sending, which
makes clients see two separate responses rather than just one. This was caused
by the fact that forwarded replies had the last_line field not set properly,
in which case the '-' was substituted on the first line, rather than the last.
The fix makes a forwarded reply indistinguishable from a normally created reply
by also allowing for amending the reply with additional lines using
smtp_server_reply_add_text().

6 years agolib-smtp: test-smtp-reply: Test whether parsed valid replies can be written back...
Stephan Bosch [Fri, 26 Oct 2018 13:50:17 +0000 (15:50 +0200)] 
lib-smtp: test-smtp-reply: Test whether parsed valid replies can be written back to the original input.

In some cases, the parser mangles the input a little to substitute invalid
characters. In those cases, the expected output is stated explicitly.

6 years agolib-smtp: Rename test-smtp-reply-parser.c to test-smtp-reply.c.
Stephan Bosch [Fri, 26 Oct 2018 13:36:21 +0000 (15:36 +0200)] 
lib-smtp: Rename test-smtp-reply-parser.c to test-smtp-reply.c.

Encoding tests will also be included, making the old name confusing.

6 years agoglobal: hash_table_iterate_deinit(NULL) is a no-op
Josef 'Jeff' Sipek [Mon, 14 Jan 2019 23:28:42 +0000 (18:28 -0500)] 
global: hash_table_iterate_deinit(NULL) is a no-op

@@
expression E;
@@

- if (E != NULL) {
-  hash_table_iterate_deinit(&E);
- }
+ hash_table_iterate_deinit(&E);

6 years agolib: hash_table_iterate_deinit(NULL) should be a no-op
Josef 'Jeff' Sipek [Mon, 14 Jan 2019 23:27:12 +0000 (18:27 -0500)] 
lib: hash_table_iterate_deinit(NULL) should be a no-op

6 years agoglobal: hash_table_destroy(NULL) is a no-op
Josef 'Jeff' Sipek [Thu, 17 Jan 2019 16:09:13 +0000 (11:09 -0500)] 
global: hash_table_destroy(NULL) is a no-op

@@
expression E;
@@

- if (hash_table_is_created(E))
-  hash_table_destroy(&E);
+ hash_table_destroy(&E);

6 years agolib: hash_table_destroy(NULL) should be a no-op
Timo Sirainen [Mon, 14 Jan 2019 15:52:26 +0000 (17:52 +0200)] 
lib: hash_table_destroy(NULL) should be a no-op

6 years agolib-http: client: Fix panic occurring at connection failure.
Stephan Bosch [Fri, 7 Dec 2018 21:38:19 +0000 (22:38 +0100)] 
lib-http: client: Fix panic occurring at connection failure.

In http_client_peer_connection_failed_pool(), all linked queues are notified
about the connection failure through http_client_queue_connection_failure().
That function can internally link and unlink peers to the queue, including the
calling one. This means that the peer->queues array can be modified while it is
iterated in the array_foreach() loop. The problem is fixed by making a local
copy of the peer->queues array.

6 years agolib-http: client: Fix handling of servers with several alternative IP addresses.
Stephan Bosch [Thu, 25 Oct 2018 08:31:07 +0000 (10:31 +0200)] 
lib-http: client: Fix handling of servers with several alternative IP addresses.

This also addresses an assert failure occurring with parallel clients:

Panic: file http-client-queue.c: line 518 (http_client_queue_connection_failure): assertion failed: (queue->cur_peer == peer)

6 years agodriver-mysql: Avoid double-closing MySQL connection
Aki Tuomi [Tue, 4 Dec 2018 12:40:04 +0000 (14:40 +0200)] 
driver-mysql: Avoid double-closing MySQL connection

Fixes double-free

6 years agolib-storage: pop3c - Use mail_user_init_ssl_client_settings
Aki Tuomi [Wed, 14 Nov 2018 13:44:14 +0000 (15:44 +0200)] 
lib-storage: pop3c - Use mail_user_init_ssl_client_settings

6 years agolib-imap-client: Drop unused fields from settings
Aki Tuomi [Wed, 14 Nov 2018 13:43:58 +0000 (15:43 +0200)] 
lib-imap-client: Drop unused fields from settings

6 years agoauth: passdb-imap - Adapt to imap-client API change
Aki Tuomi [Wed, 14 Nov 2018 13:24:41 +0000 (15:24 +0200)] 
auth: passdb-imap - Adapt to imap-client API change

6 years agolib-storage: imapc - Use mail_user_ssl_settings
Aki Tuomi [Wed, 14 Nov 2018 13:24:18 +0000 (15:24 +0200)] 
lib-storage: imapc - Use mail_user_ssl_settings

6 years agolib-imap-client: Use iostream ssl settings directly
Aki Tuomi [Wed, 14 Nov 2018 13:21:36 +0000 (15:21 +0200)] 
lib-imap-client: Use iostream ssl settings directly

Prevents custom SSL CAs and certificate verification disabling
until fixed by subsequent commits.

6 years agoauth: Use master service ssl settings for http client in policy checks
Aki Tuomi [Wed, 14 Nov 2018 12:05:24 +0000 (14:05 +0200)] 
auth: Use master service ssl settings for http client in policy checks

6 years agolib-master: When duplicating SSL settings set empty values NULL
Aki Tuomi [Wed, 14 Nov 2018 12:43:52 +0000 (14:43 +0200)] 
lib-master: When duplicating SSL settings set empty values NULL

Otherwise default CA is not used for client connections.

Broken in 30dca954

6 years agodoc: Update example config about `ssl_client_require_valid_cert`
Aki Tuomi [Fri, 9 Nov 2018 07:54:38 +0000 (09:54 +0200)] 
doc: Update example config about `ssl_client_require_valid_cert`

6 years agolib-storage: Copy all relevant TLS settings
Aki Tuomi [Wed, 31 Oct 2018 12:19:49 +0000 (14:19 +0200)] 
lib-storage: Copy all relevant TLS settings

Not just ca path and dir

6 years agolib-storage: Add all client ssl settings to mail storage settings
Aki Tuomi [Wed, 31 Oct 2018 12:09:30 +0000 (14:09 +0200)] 
lib-storage: Add all client ssl settings to mail storage settings

6 years agolib-master: Add new setting `ssl_client_require_valid_cert`
Aki Tuomi [Wed, 31 Oct 2018 12:20:36 +0000 (14:20 +0200)] 
lib-master: Add new setting `ssl_client_require_valid_cert`

This controls whether TLS certificates are verified
for TLS CLIENT connections.

6 years agolib-ssl-iostream: If certificate check fails, suggest checking ssl ca settings
Aki Tuomi [Tue, 24 Jul 2018 06:51:39 +0000 (09:51 +0300)] 
lib-ssl-iostream: If certificate check fails, suggest checking ssl ca settings

6 years agolib-ssl-iostream: Always fall back to default CAs for client contexts
Aki Tuomi [Mon, 23 Jul 2018 09:40:15 +0000 (12:40 +0300)] 
lib-ssl-iostream: Always fall back to default CAs for client contexts

When creating a client context, we always try to load the default
CA, if no CA settings have been provided. This makes it also possible
to allow invalid certs without specifying ssl_client_ca settings,
and also makes dovecot trust system store by default for outgoing
connections.

6 years agolib-iostream-ssl: Use default CA locations with client context
Aki Tuomi [Tue, 15 Mar 2016 07:21:49 +0000 (09:21 +0200)] 
lib-iostream-ssl: Use default CA locations with client context

If no CA settings are provided, fall back to default CA
settings from openssl library.

6 years agoNEWS: Add v2.3.5
Timo Sirainen [Mon, 4 Mar 2019 16:44:30 +0000 (16:44 +0000)] 
NEWS: Add v2.3.5

(cherry picked from commit 622d67fdf0a51c5c3b0114603f62afc5651642a9)

6 years agofs-posix: fs_read_stream() - Don't close file's fd
Timo Sirainen [Mon, 25 Feb 2019 18:55:03 +0000 (20:55 +0200)] 
fs-posix: fs_read_stream() - Don't close file's fd

This is especially important with newly created files, because they may
still be accessed after reading. The next file access attempt after
fs_read_stream() might cause the file to be recreated and crash.

Fixes:
Panic: file fs-posix.c: line 252 (fs_posix_create): assertion failed: (file->temp_path == NULL)

6 years agolib: test-istream-seekable - Add asserts to make sure blocking state changes at EOF
Timo Sirainen [Tue, 19 Feb 2019 08:49:37 +0000 (10:49 +0200)] 
lib: test-istream-seekable - Add asserts to make sure blocking state changes at EOF

6 years agolib-storage: mail_get_*stream*() - Assert that returned streams are blocking
Timo Sirainen [Tue, 19 Feb 2019 08:22:43 +0000 (10:22 +0200)] 
lib-storage: mail_get_*stream*() - Assert that returned streams are blocking

Several callers already rely on them being blocking. Making these asserts
explicit makes sure that any bugs are caught early.

6 years agolib: istream-seekable - Change stream to be blocking=TRUE after reaching EOF
Timo Sirainen [Tue, 19 Feb 2019 08:17:45 +0000 (10:17 +0200)] 
lib: istream-seekable - Change stream to be blocking=TRUE after reaching EOF

After EOF is reached, the stream is now fully read into file or memory.
read()s can no longer return 0, so blocking=TRUE can be used.

Some callers were reusing the seekable stream in places that required
blocking=TRUE.

Fixes at least with imapsieve vnd.dovecot report extension:
Panic: file ostream.c: line 427 (o_stream_nsend_istream): assertion failed: (instream->blocking)

6 years agolib-ssl-iostream: iostream-ssl-test - Update the test certificate to have very long...
Stephan Bosch [Tue, 19 Feb 2019 10:31:45 +0000 (11:31 +0100)] 
lib-ssl-iostream: iostream-ssl-test - Update the test certificate to have very long expiry period.

The old certificate expired after one year, which causes all kinds of unit test
failures.

6 years agolib-http: Add assert to make sure http_client_init_shared(NULL, NULL) isn't called
Timo Sirainen [Thu, 30 Aug 2018 13:40:16 +0000 (16:40 +0300)] 
lib-http: Add assert to make sure http_client_init_shared(NULL, NULL) isn't called

This should make scan-build happy.

6 years agolib-smtp: client: Move connection to TRANSACTION state immediately when a transaction...
Stephan Bosch [Thu, 27 Dec 2018 13:13:15 +0000 (14:13 +0100)] 
lib-smtp: client: Move connection to TRANSACTION state immediately when a transaction is started.

Before, it waited until the actual start handler was called from timeout, but
that causes a race condition with mtp_client_connection_abort_transaction(),
which in turn causes an assert panic.

Panic was:

Panic: file smtp-client-connection.c: line 2153 (smtp_client_connection_abort_transaction): assertion failed: (conn->state != SMTP_CLIENT_CONNECTION_STATE_READY)

6 years agolib-smtp: client: Properly reset connection state upon reconnect.
Stephan Bosch [Sun, 11 Nov 2018 19:41:18 +0000 (20:41 +0100)] 
lib-smtp: client: Properly reset connection state upon reconnect.

6 years agolib-smtp: client: connection: Prevent timeout leak for transaction start.
Stephan Bosch [Sun, 11 Nov 2018 19:32:09 +0000 (20:32 +0100)] 
lib-smtp: client: connection: Prevent timeout leak for transaction start.

Perform timeout management in a single place. Also, always start the next
transaction only through a timeout.

6 years agom4: Fix moduledir behaviour
Aki Tuomi [Mon, 14 Jan 2019 12:37:03 +0000 (14:37 +0200)] 
m4: Fix moduledir behaviour

This is mainly a fix for plugins that depend on dovecot.m4

6 years agom4/dovecot.m4: rename valgrind output file to hide it from certain tests
Phil Carmody [Tue, 19 Jun 2018 12:30:36 +0000 (15:30 +0300)] 
m4/dovecot.m4: rename valgrind output file to hide it from certain tests

Some lib-http tests use readdir() to create test cases, and sometimes
object to the contents of test.out.$$. However, as lib-http is also
sensitive to certain characters in the filenames of the files it uses,
we can hide the valgrind output by chosing its filename to exclude it
from the lib_http tests. Non-initial '~' is not known to cause any issues
for either the shell or any known operating system, so is the safest of
lib-http's 'dodgy' characters to use as the separator.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
6 years agom4/dovecot.m4 - Apply DRY principle to test output filename
Phil Carmody [Wed, 29 Aug 2018 11:57:45 +0000 (14:57 +0300)] 
m4/dovecot.m4 - Apply DRY principle to test output filename

Define the name we will use for the file once, then just use that variable
instead of using explicit repeatition.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
6 years agom4/dovecot.m4: run-test.sh - disable valgrind for individual tests
Phil Carmody [Mon, 4 Jun 2018 16:58:23 +0000 (19:58 +0300)] 
m4/dovecot.m4: run-test.sh - disable valgrind for individual tests

OpenSSL doesn't like valgrind on my setup, so permit a local instalation
to have a list of excluded binaries that won't use valgrind in make check.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
6 years agolib-http: increase pool sizes in tests
Phil Carmody [Tue, 19 Jun 2018 10:29:46 +0000 (13:29 +0300)] 
lib-http: increase pool sizes in tests

Pool growth messages spam the test output, just dive in with a slightly
larger default to shut them up. Only affects these individual tests,
not any other users of the library.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
6 years agolib-http: change default client/server pool sizes when using SSL
Phil Carmody [Tue, 19 Jun 2018 10:28:12 +0000 (13:28 +0300)] 
lib-http: change default client/server pool sizes when using SSL

SSL carries a lot of state with it, so just start with a bigger
pool if we know we're using it.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
6 years agolib-http: harden payload tests against dodgy filenames
Phil Carmody [Thu, 14 Jun 2018 05:51:37 +0000 (08:51 +0300)] 
lib-http: harden payload tests against dodgy filenames

Tests use files from readdir() as input, but do no sanitation of the
names, and therefore things like editor temp files can cause havoc
with the HTTP request parser.

The solution is to trap dodgy characters in the filenames, and ignore
those files. Initially, trap HTTP's "unsafe" and "reserved" characters.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
6 years agolib-mail: ostream-dot - Add unit test for parent stream buffer being almost full.
Stephan Bosch [Mon, 7 Jan 2019 14:35:07 +0000 (15:35 +0100)] 
lib-mail: ostream-dot - Add unit test for parent stream buffer being almost full.

6 years agolib-mail: ostream-dot - Add asserts to make sure max_bytes doesn't underflow
Timo Sirainen [Sat, 15 Dec 2018 14:32:22 +0000 (16:32 +0200)] 
lib-mail: ostream-dot - Add asserts to make sure max_bytes doesn't underflow

6 years agolib-mail: ostream-dot - Fix potential assert-crash when parent stream buffer gets...
Timo Sirainen [Sat, 15 Dec 2018 14:24:42 +0000 (16:24 +0200)] 
lib-mail: ostream-dot - Fix potential assert-crash when parent stream buffer gets full

If max_bytes=1, the (max_bytes-2) calculation brings it to (size_t)-1. This
causes too much data to be sent to the parent stream, which then returns a
partial write and causes an assert-crash.

The final chunk calculation doesn't need the -2 check, because additional
bytes aren't inserted at that point.

Fixes:
Panic: file ostream-dot.c: line 208 (o_stream_dot_sendv): assertion failed: ((size_t)ret == sent + added)

6 years agolib: Fix buffer code to satisfy static analyzers
Aki Tuomi [Tue, 20 Feb 2018 10:04:13 +0000 (12:04 +0200)] 
lib: Fix buffer code to satisfy static analyzers

6 years agolib: randgen - Init seed to 0
Aki Tuomi [Thu, 8 Feb 2018 09:56:08 +0000 (11:56 +0200)] 
lib: randgen - Init seed to 0

Satisfies static analyzer, the seed is guaranteed to get
filled with random data.

6 years agotrash: Use TRASH_USER_CONTEXT_REQUIRE
Aki Tuomi [Thu, 8 Feb 2018 09:45:20 +0000 (11:45 +0200)] 
trash: Use TRASH_USER_CONTEXT_REQUIRE

Satisfies static analyzer

6 years agolib/randgen - warn when DOVECOT_SRAND is not able to be used
Phil Carmody [Tue, 30 Jan 2018 12:14:42 +0000 (14:14 +0200)] 
lib/randgen - warn when DOVECOT_SRAND is not able to be used

As suggested by Jeff, it's friendly to warn if we're unable to act
upon the request for reproduceable random numbers because we're not
built for that.

Note, this deliberately permits a blank string, so that you can
silence the warning by prefixing a command with an empty
  DOVECOT_SRAND=
which is taken as an explicit attempt to disable use of the feature.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
6 years agolib/lib-test: restore DOVECOT_SRAND feature in DEBUG builds
Phil Carmody [Mon, 11 Dec 2017 12:03:13 +0000 (14:03 +0200)] 
lib/lib-test: restore DOVECOT_SRAND feature in DEBUG builds

Add a deterministic PRNG, an ability to force its use, and an
ability to re-use the same sequence later.

Since proper random numbers have been forced into use, making
reproducable tests isn't quite as easy as it used to be, it's 3 steps
rather than 2. When seeing an intermittent test failure:
 - rerun the tests with environmental variable DOVECOT_SRAND=kiss
 - upon seeing a new failure case, note the seed logged at the failure
 - debug using DOVECOT_SRAND=<that number>

In non-DEBUG builds, there's no trace of this code, and the
randomisation that is an inherent part of many tests remains
non-reproduceable.

Works with all of the RNG preferences, getrandom/urandom/arc4.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
6 years agolib-smtp: client: Make sending the XCLIENT command(s) always implicit and do it only...
Stephan Bosch [Mon, 3 Dec 2018 17:45:43 +0000 (18:45 +0100)] 
lib-smtp: client: Make sending the XCLIENT command(s) always implicit and do it only once.

For most servers, XCLIENT changes the ip:port identity of the client, causing it
to lose privileges to send more XCLIENT commands. For long XCLIENT commands
split in a series of XCLIENT commands, the ip:port parameters were sent last
already, so that did not cause problems even before this change. However, the
old code assumed it could update XCLIENT fields later on, which is often not
possible.

6 years agosubmission: relay backend: Don't bother updating the protocol in proxy data.
Stephan Bosch [Mon, 3 Dec 2018 17:45:43 +0000 (18:45 +0100)] 
submission: relay backend: Don't bother updating the protocol in proxy data.

Old SMTP clients cannot use the submission service, since these cannot perform
the required authentication.

6 years agosubmission: Move client_create_backend_default() after smtp_server_connection_login...
Stephan Bosch [Mon, 3 Dec 2018 17:45:42 +0000 (18:45 +0100)] 
submission: Move client_create_backend_default() after smtp_server_connection_login() in client_create().

This way, the created default backend can use the HELO data provided to smtp_server_connection_login().

6 years agolib-smtp: client: Allow deferring sending the XCLIENT command until authentication...
Stephan Bosch [Mon, 3 Dec 2018 17:45:42 +0000 (18:45 +0100)] 
lib-smtp: client: Allow deferring sending the XCLIENT command until authentication or first mail transaction.

This allows updating the proxy data until the XCLIENT command actually needs to
be sent. For submission, this means that later EHLO domain changes can still be
accounted for. This change makes the simplifications in subsequent changes
easier.

6 years agolib-smtp: client: Merge smtp_client_connection_init_xclient() into smtp_client_connec...
Stephan Bosch [Mon, 3 Dec 2018 17:45:41 +0000 (18:45 +0100)] 
lib-smtp: client: Merge smtp_client_connection_init_xclient() into smtp_client_connection_authenticate().

6 years agolib-smtp: client: Move smtp_client_connection_send_xclient() before smtp_client_conne...
Stephan Bosch [Mon, 3 Dec 2018 17:45:40 +0000 (18:45 +0100)] 
lib-smtp: client: Move smtp_client_connection_send_xclient() before smtp_client_connection_authenticate().

Keeps ordering of functions logical for next changes.

6 years agosubmission: relay backend: Provide data for the HELO and PROTO XCLIENT fields to...
Stephan Bosch [Mon, 3 Dec 2018 17:45:40 +0000 (18:45 +0100)] 
submission: relay backend: Provide data for the HELO and PROTO XCLIENT fields to the relay connection.

6 years agolib-smtp: server: Use the HELO domain provided to smtp_server_connection_login()...
Stephan Bosch [Mon, 3 Dec 2018 17:45:39 +0000 (18:45 +0100)] 
lib-smtp: server: Use the HELO domain provided to smtp_server_connection_login() immediately.

Before, it was only used when no new HELO/EHLO command was issued before MAIL.

6 years agolib-smtp: client: Remove proxy_data parameter from smtp_client_connection_send_xclient().
Stephan Bosch [Mon, 3 Dec 2018 17:45:39 +0000 (18:45 +0100)] 
lib-smtp: client: Remove proxy_data parameter from smtp_client_connection_send_xclient().

Use smtp_client_connection_update_proxy_data() to change fields in the proxy
data recorded in the client.

6 years agolib-smtp: client: Add smtp_client_connection_update_proxy_data().
Stephan Bosch [Mon, 3 Dec 2018 17:45:38 +0000 (18:45 +0100)] 
lib-smtp: client: Add smtp_client_connection_update_proxy_data().

Allows updating the proxy data after creation of the connection.

6 years agolib-smtp: client: Make smtp_client_connection_send_xclient() return void.
Stephan Bosch [Mon, 3 Dec 2018 17:45:38 +0000 (18:45 +0100)] 
lib-smtp: client: Make smtp_client_connection_send_xclient() return void.

6 years agolib-smtp: client: Copy proxy data from settings using the new smtp_proxy_data_merge...
Stephan Bosch [Mon, 3 Dec 2018 17:45:37 +0000 (18:45 +0100)] 
lib-smtp: client: Copy proxy data from settings using the new smtp_proxy_data_merge() functioṅ.

6 years agolib-smtp: common: Add smtp_proxy_data_merge().
Stephan Bosch [Mon, 3 Dec 2018 17:45:36 +0000 (18:45 +0100)] 
lib-smtp: common: Add smtp_proxy_data_merge().

6 years agolib-smtp: client: Drop smtp_client_command_mail_submit_after().
Stephan Bosch [Mon, 3 Dec 2018 17:45:35 +0000 (18:45 +0100)] 
lib-smtp: client: Drop smtp_client_command_mail_submit_after().

It is not used.