]> git.ipfire.org Git - thirdparty/dovecot/core.git/log
thirdparty/dovecot/core.git
11 years agolib-http server: Use io_add_istream() to wait for the payload istream.
Timo Sirainen [Fri, 15 Aug 2014 13:00:07 +0000 (16:00 +0300)] 
lib-http server: Use io_add_istream() to wait for the payload istream.
This way the stream doesn't necessarily have to have a fd.

11 years agolib-http: Added asserts to make sure CR or LF can't be added accidentally to HTTP...
Timo Sirainen [Fri, 15 Aug 2014 12:59:17 +0000 (15:59 +0300)] 
lib-http: Added asserts to make sure CR or LF can't be added accidentally to HTTP headers.

11 years agoistream-chain: Support using io_add_istream() for the chain stream.
Timo Sirainen [Fri, 15 Aug 2014 12:22:46 +0000 (15:22 +0300)] 
istream-chain: Support using io_add_istream() for the chain stream.
The callback is notified whenever new streams are added to the chain.

It's currently not possible to have nonblocking istreams added to the chain
and the callback being called when they have new data, but it would be
possible to implement as well if needed at some point.

11 years agoio_add_istream(): Allow the istream to be added even if it doesn't have fd.
Timo Sirainen [Fri, 15 Aug 2014 12:19:24 +0000 (15:19 +0300)] 
io_add_istream(): Allow the istream to be added even if it doesn't have fd.

11 years agopop3: satisfy some strict parsing rules in RFC 1939
Phil Carmody [Fri, 15 Aug 2014 12:02:59 +0000 (15:02 +0300)] 
pop3: satisfy some strict parsing rules in RFC 1939
"Commands in the POP3 consist of a case-insensitive keyword, possibly
 followed by one or more arguments.  All commands are terminated by a
 CRLF pair.  Keywords and arguments consist of printable ASCII
 characters.  Keywords and arguments are each separated by a single
 SPACE character."

"A server MUST respond to an unrecognized, unimplemented, or
 syntactically invalid command by responding with a negative status
 indicator."

Therefore the following commands must be rejected:
LIST 2600Hz
LIST 99 red balloons
TOP 1 2 buckle-my-shoe

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agopop3: fix msgnum/size parsers
Phil Carmody [Fri, 15 Aug 2014 12:02:59 +0000 (15:02 +0300)] 
pop3: fix msgnum/size parsers
The outer if()s are completely unnecessary, and permit `num'
to remain uninitialised. Spotted by clang's static analysis.

Bug introduced in changeset: 17563:2ed2ab04b63d

Note that the lack of a parameter from a broken client is no longer
treated as "0". Before the bug was introduced:
  DELE
  -ERR There's no message 0.
After this patch:
  DELE
  -ERR Invalid message number:

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agoCompiling fix for previous change..
Timo Sirainen [Fri, 15 Aug 2014 11:48:08 +0000 (14:48 +0300)] 
Compiling fix for previous change..

11 years agoHandle "out of disk space" and "out of user quota" as separate cases.
Timo Sirainen [Fri, 15 Aug 2014 11:41:03 +0000 (14:41 +0300)] 
Handle "out of disk space" and "out of user quota" as separate cases.
"Out of disk space" is a temporary error that should be logged as error and
the failure should be sent to user as "Internal server error".

Obsolete the use of MAIL_ERROR_NOSPACE and MAIL_ERRSTR_NO_SPACE. Use the
clearer MAIL_ERROR_NOQUOTA and MAIL_ERRSTR_NO_QUOTA instead.

11 years agoldap: Treat "No such object" errors to search the same as if no results were returned.
Timo Sirainen [Fri, 15 Aug 2014 11:05:21 +0000 (14:05 +0300)] 
ldap: Treat "No such object" errors to search the same as if no results were returned.
Trying to look up a nonexistent base returns this error.

11 years agoauth: Internal passdb failures were always failing the request even if another passdb...
Timo Sirainen [Fri, 15 Aug 2014 10:58:47 +0000 (13:58 +0300)] 
auth: Internal passdb failures were always failing the request even if another passdb succeeded later.

11 years agolib-http: server_request/connection - improve encapsulation
Phil Carmody [Wed, 13 Aug 2014 10:34:22 +0000 (13:34 +0300)] 
lib-http: server_request/connection - improve encapsulation
It just feels a bit dirty having the request mess around with the
connection's internals, have the connection manage its linked lists
itself. No functional changes.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agovirtual plugin: Optimized memory allocation.
Timo Sirainen [Wed, 13 Aug 2014 09:51:41 +0000 (12:51 +0300)] 
virtual plugin: Optimized memory allocation.
Patch by Teemu Huovila.

11 years agoCompiler warning fix
Timo Sirainen [Tue, 12 Aug 2014 16:30:37 +0000 (19:30 +0300)] 
Compiler warning fix

11 years agovirtual plugin: Handle physical mailbox deletion while virtual mailbox is open.
Timo Sirainen [Tue, 12 Aug 2014 16:24:10 +0000 (19:24 +0300)] 
virtual plugin: Handle physical mailbox deletion while virtual mailbox is open.

11 years agomailbox_list_index=yes: Make sure storage error doesn't change when updating STATUS...
Timo Sirainen [Tue, 12 Aug 2014 16:12:04 +0000 (19:12 +0300)] 
mailbox_list_index=yes: Make sure storage error doesn't change when updating STATUS info.

11 years agolib-storage: Added mail_storage_last_error_push/pop()
Timo Sirainen [Tue, 12 Aug 2014 16:05:14 +0000 (19:05 +0300)] 
lib-storage: Added mail_storage_last_error_push/pop()

11 years agovirtual plugin: Optimized syncing a large number of physical mailboxes.
Timo Sirainen [Tue, 12 Aug 2014 15:48:03 +0000 (18:48 +0300)] 
virtual plugin: Optimized syncing a large number of physical mailboxes.
Especially when the number of mails was large the old code took a lot of CPU
time. Based on patch by Teemu Huovila.

11 years agostats: Added num_connected_sessions for domains and IPs.
Timo Sirainen [Tue, 12 Aug 2014 11:44:11 +0000 (14:44 +0300)] 
stats: Added num_connected_sessions for domains and IPs.

11 years agolib-http server: Delay calling the request's destroy callback until handle_request...
Timo Sirainen [Tue, 12 Aug 2014 10:12:01 +0000 (13:12 +0300)] 
lib-http server: Delay calling the request's destroy callback until handle_request() callback is finished.
This simplifies the code in the handle_request() so it doesn't need to keep
track of whether the response is already submitted or not.

11 years agofts-lucene: If lucene-indexes dir is unexpectedly lost, rescan when expunge log updat...
Timo Sirainen [Tue, 12 Aug 2014 09:39:46 +0000 (12:39 +0300)] 
fts-lucene: If lucene-indexes dir is unexpectedly lost, rescan when expunge log update fails.
This mainly fixes a repeating error about failing to open the expunge log.
It should happen only if dovecot.index thinks that the mailbox is indexed
while in reality the entire lucene-indexes directory doesn't exist.

11 years agoostream-buffer: Allow modifying the buffer outside ostream, unless o_stream_seek...
Timo Sirainen [Mon, 11 Aug 2014 16:30:15 +0000 (19:30 +0300)] 
ostream-buffer: Allow modifying the buffer outside ostream, unless o_stream_seek() is used.
Now we'll just append to the end of the buffer instead of forcibly trying to
write at the offset where the last ostream write ended.

11 years agoistream-callback: Added i_stream_callback_get_buffer().
Timo Sirainen [Mon, 11 Aug 2014 16:19:45 +0000 (19:19 +0300)] 
istream-callback: Added i_stream_callback_get_buffer().

11 years agolib: Added istream-callback API
Timo Sirainen [Mon, 11 Aug 2014 14:43:25 +0000 (17:43 +0300)] 
lib: Added istream-callback API

11 years agoCompiler warning fix
Timo Sirainen [Mon, 11 Aug 2014 13:08:44 +0000 (16:08 +0300)] 
Compiler warning fix

11 years agolib-http server: Comment updates
Timo Sirainen [Mon, 11 Aug 2014 12:55:03 +0000 (15:55 +0300)] 
lib-http server: Comment updates

11 years agolib: io_stream_copy() no longer attempts to read full block sizes from input.
Timo Sirainen [Mon, 11 Aug 2014 12:54:43 +0000 (15:54 +0300)] 
lib: io_stream_copy() no longer attempts to read full block sizes from input.
Although that may be more efficient for writing (to files), it causes
unnecessary work for the input stream. The writing part should also be
optimized anyway if the caller corks the output stream.

11 years agolib-http server: Added http_server_request_is_finished()
Timo Sirainen [Mon, 11 Aug 2014 12:47:57 +0000 (15:47 +0300)] 
lib-http server: Added http_server_request_is_finished()
This is intended mainly to be used in asserts and such checks.

11 years agolib-http: Call the destroy callback also when request is aborted.
Timo Sirainen [Mon, 11 Aug 2014 12:46:29 +0000 (15:46 +0300)] 
lib-http: Call the destroy callback also when request is aborted.

11 years agolib-http: Don't leak memory if HTTP client disconnects unexpectedly.
Timo Sirainen [Mon, 11 Aug 2014 12:45:21 +0000 (15:45 +0300)] 
lib-http: Don't leak memory if HTTP client disconnects unexpectedly.
http_server_connection_disconnect() has several cleanup calls, which weren't
done because closed=TRUE was set explicitly and that skipped the cleanup.

11 years agolib-http server: Call request destroy callback immediately after response is finished...
Timo Sirainen [Mon, 11 Aug 2014 11:18:53 +0000 (14:18 +0300)] 
lib-http server: Call request destroy callback immediately after response is finished sending.
Regardless of any other references to the request.

11 years agolib-mail: Added comments to message-parser.h
Timo Sirainen [Mon, 11 Aug 2014 10:32:06 +0000 (13:32 +0300)] 
lib-mail: Added comments to message-parser.h

11 years agolib-mail: Message parser now always returns block->data=NULL when it's not supposed...
Timo Sirainen [Mon, 11 Aug 2014 10:30:25 +0000 (13:30 +0300)] 
lib-mail: Message parser now always returns block->data=NULL when it's not supposed to be used.

11 years agodoveadm fs put: Added -h <hash> parameter to specify the file's hash.
Timo Sirainen [Sat, 9 Aug 2014 07:10:34 +0000 (10:10 +0300)] 
doveadm fs put: Added -h <hash> parameter to specify the file's hash.
The hash (in hex) is automatically detected to be either MD5 or SHA256 based
on its size. If the fs backend doesn't support the hash it'll fail.
Otherwise it'll make sure that the written file matches the given hash.

11 years agofts: fts_no_autofuzzy shouldn't disable fuzzying when FUZZY search parameter is set.
Timo Sirainen [Fri, 8 Aug 2014 13:27:40 +0000 (16:27 +0300)] 
fts: fts_no_autofuzzy shouldn't disable fuzzying when FUZZY search parameter is set.

11 years agofts: Added fts_no_autofuzzy setting to require exact matches for found results.
Timo Sirainen [Fri, 8 Aug 2014 13:20:31 +0000 (16:20 +0300)] 
fts: Added fts_no_autofuzzy setting to require exact matches for found results.
This is done by using the FTS search results as only filters on which the
regular non-FTS search is done.

11 years agodoveadm search: If mailbox GUID lookup fails, print an error.
Timo Sirainen [Fri, 8 Aug 2014 12:15:03 +0000 (15:15 +0300)] 
doveadm search: If mailbox GUID lookup fails, print an error.

11 years agovirtual: Allow "*" to match inbox=yes namespace if there's otherwise no prefix="...
Timo Sirainen [Fri, 8 Aug 2014 11:54:46 +0000 (14:54 +0300)] 
virtual: Allow "*" to match inbox=yes namespace if there's otherwise no prefix="" namespace.

11 years agovirtual: Make sure virtual mailbox doesn't try to access itself as a backend mailbox.
Timo Sirainen [Fri, 8 Aug 2014 11:54:20 +0000 (14:54 +0300)] 
virtual: Make sure virtual mailbox doesn't try to access itself as a backend mailbox.

11 years agolib-storage: mailbox_get_*status(STATUS_HIGHESTMODSEQ) now enables CONDSTORE feature.
Timo Sirainen [Fri, 8 Aug 2014 10:46:05 +0000 (13:46 +0300)] 
lib-storage: mailbox_get_*status(STATUS_HIGHESTMODSEQ) now enables CONDSTORE feature.
This makes sure that the highestmodseq is added to the mailbox list index if
not already there.

11 years agovirtual: Make sure modseqs are always enabled for backend mailboxes.
Timo Sirainen [Fri, 8 Aug 2014 10:32:08 +0000 (13:32 +0300)] 
virtual: Make sure modseqs are always enabled for backend mailboxes.
mailbox_get_status() wasn't adding a missing highestmodseq otherwise to the
mailbox list index.

11 years agoauth: passdb static assumed that missing "password" field meant empty password
Timo Sirainen [Wed, 6 Aug 2014 13:39:27 +0000 (16:39 +0300)] 
auth: passdb static assumed that missing "password" field meant empty password
Missing password should be an error unless nopassword is set. If an empty
password is wanted then "password=" can be used.

11 years agolib-http: server: Fixed server waiting for payload of already failed request.
Stephan Bosch [Tue, 5 Aug 2014 18:23:32 +0000 (20:23 +0200)] 
lib-http: server: Fixed server waiting for payload of already failed request.

11 years agolib-http server: Require handle_request() to either send a response or reference...
Timo Sirainen [Tue, 5 Aug 2014 15:43:31 +0000 (17:43 +0200)] 
lib-http server: Require handle_request() to either send a response or reference the request.
This should make it more difficult to accidentally forget to send a
response and cause a hang.

Currently this assert-crashes, although it would have been possible to make
it return some internal error instead also.

11 years agolib-http server: Made http_server_request_[un]ref() public.
Timo Sirainen [Tue, 5 Aug 2014 15:37:25 +0000 (17:37 +0200)] 
lib-http server: Made http_server_request_[un]ref() public.
Also http_server_request_unref() now returns if this was the last reference
or not.

11 years agolib-http server: Create a new data stack frame for all the callbacks.
Timo Sirainen [Tue, 5 Aug 2014 14:28:15 +0000 (16:28 +0200)] 
lib-http server: Create a new data stack frame for all the callbacks.

11 years agolib-http server: Added http_server_request_get_response()
Timo Sirainen [Tue, 5 Aug 2014 14:22:43 +0000 (16:22 +0200)] 
lib-http server: Added http_server_request_get_response()
Also make sure that only a single response can be created for a request.

11 years agolib-http server: Removed extra "return;" that was never called.
Timo Sirainen [Tue, 5 Aug 2014 14:09:44 +0000 (16:09 +0200)] 
lib-http server: Removed extra "return;" that was never called.

11 years agolib-http server: Removed "bool close" parameters in favor of _close() functions.
Timo Sirainen [Tue, 5 Aug 2014 14:07:25 +0000 (16:07 +0200)] 
lib-http server: Removed "bool close" parameters in favor of _close() functions.
Most callers don't want to close the connection so it's an extra parameter
usually. Also it's difficult to remember what the TRUE/FALSE means so it's
easy to cause bugs by copy&pasting the code.

http_server_request_fail() will also now forcibly close the connection if
conn->input_broken is set.

11 years agoexpire plugin: Fixed crash at deinit if expire_dict initialization failed.
Timo Sirainen [Mon, 4 Aug 2014 12:05:51 +0000 (14:05 +0200)] 
expire plugin: Fixed crash at deinit if expire_dict initialization failed.

11 years agoimap-urlauth: Error message typofix.
Timo Sirainen [Fri, 1 Aug 2014 14:17:53 +0000 (17:17 +0300)] 
imap-urlauth: Error message typofix.
Patch by Jelmer Vernooij

11 years agolib-mail: rfc822_parse_dot_atom() didn't return error if "." wasn't followed by ATEXT
Timo Sirainen [Thu, 31 Jul 2014 12:58:18 +0000 (15:58 +0300)] 
lib-mail: rfc822_parse_dot_atom() didn't return error if "." wasn't followed by ATEXT
It simply skipped over the invalid character and continued.

11 years agolib: test-data-stack - add some fatal tests.
Phil Carmody [Wed, 30 Jul 2014 12:01:29 +0000 (15:01 +0300)] 
lib: test-data-stack - add some fatal tests.
Extra caution is necessary as data-stack is such a fundamental component.
All of the brokenness that we add must be undone as soon as possible, or
there will be an endless loop of catastrophic errors. In order to avoid
that, at least try to detect some issues, and abort as quickly as possible.

Alas, due to the reliance of these tests on DEBUG code, if that's not set,
this test is a no-op.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: test fatal cases for printf_format_fix
Phil Carmody [Wed, 30 Jul 2014 12:01:29 +0000 (15:01 +0300)] 
lib: test fatal cases for printf_format_fix
Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: test-lib - add a real fatal test for mempool-alloconly
Phil Carmody [Wed, 30 Jul 2014 12:01:29 +0000 (15:01 +0300)] 
lib: test-lib - add a real fatal test for mempool-alloconly
Crazily huge memory allocation must fail.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-test: permit tests of fatal conditions
Phil Carmody [Wed, 30 Jul 2014 12:01:29 +0000 (15:01 +0300)] 
lib-test: permit tests of fatal conditions
Some functions have no mechanism of reporting an error, and mustn't continue,
so fatality is the only way out. (E.g. memory allocation failures.)

This addition is for those situations. Semantics of failure tests are very
different from normal tests:

- The test function must have the following prototype:
   enum fatal_test_state test_fatal_things(int index);
- The index it will be called with starts at 0, and increments each time.
- It must call test_start() at the start of its first call.
- Apart from its final call, it must call a function it expects to trap the
   fatal error handler. If that fails to trap, it must return FATAL_TEST_FAILURE
- After returning FATAL_TEST_FAILURE, it will continue to be called as normal.
- When there are no more tests to perform, it must clean up, call test_end()
   and return FATAL_TEST_FINISHED. It will not be called again.
- If it detects errors in this protocol, it must not i_assert(), as that will
   be treated as an expected fatal, it must return FATAL_TEST_ABORT. It will
   then not be called again. It must not call test_end() in this case.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agoquota: Avoid assert-crash in Maildir++ quota if backend doesn't support control dirs.
Timo Sirainen [Tue, 29 Jul 2014 14:27:24 +0000 (17:27 +0300)] 
quota: Avoid assert-crash in Maildir++ quota if backend doesn't support control dirs.
We'll delay looking up the control dir until we've checked that the storage
is Maildir.

11 years agolibressl fix: Fixed compiling with SSL compression disabled.
Timo Sirainen [Tue, 29 Jul 2014 11:27:49 +0000 (14:27 +0300)] 
libressl fix: Fixed compiling with SSL compression disabled.
Patch by Pascal Stumpf

11 years agolibressl fix: Check for SSL_CTRL_SET_ECDH_AUTO macro instead of OpenSSL version number
Timo Sirainen [Tue, 29 Jul 2014 11:25:13 +0000 (14:25 +0300)] 
libressl fix: Check for SSL_CTRL_SET_ECDH_AUTO macro instead of OpenSSL version number
Patch by Hanno Böck

11 years agombox: Fixed infinite looping and other incorrectness in istream-raw-mbox.
Timo Sirainen [Tue, 29 Jul 2014 10:58:10 +0000 (13:58 +0300)] 
mbox: Fixed infinite looping and other incorrectness in istream-raw-mbox.
This was caused by the recent istream invalidation checks in
i_stream_get_data().

11 years agolast-login plugin: Added missing configure and Makefile entries.
Timo Sirainen [Tue, 29 Jul 2014 09:47:47 +0000 (12:47 +0300)] 
last-login plugin: Added missing configure and Makefile entries.

11 years agolib-http: http-server-connection - don't resume closed connections
Phil Carmody [Mon, 28 Jul 2014 13:50:47 +0000 (16:50 +0300)] 
lib-http: http-server-connection - don't resume closed connections
Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-imap: imap-utf7 - only encode in-range 7-bit values
Phil Carmody [Mon, 28 Jul 2014 13:49:47 +0000 (16:49 +0300)] 
lib-imap: imap-utf7 - only encode in-range 7-bit values
0x01-0x1F and 0x7f-... must be mBASE64 encoded.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-imap: imap-utf7 - reject encoded simple ASCII
Phil Carmody [Mon, 28 Jul 2014 13:49:47 +0000 (16:49 +0300)] 
lib-imap: imap-utf7 - reject encoded simple ASCII
"Modified BASE64 MUST NOT be used to represent any printing US-ASCII
character which can represent itself."

"The character "&" (0x26) is represented by the two-octet sequence "&-""

Therefore any mBASE64 sequence containing any character between 0x20 and
0x7e is invalid.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-imap: imap-utf7 - reject bogus characters in the mUTF7
Phil Carmody [Mon, 28 Jul 2014 13:49:47 +0000 (16:49 +0300)] 
lib-imap: imap-utf7 - reject bogus characters in the mUTF7
Only 0x20..0x7e are permitted, as "All other characters (octet values
0x00-0x1f and 0x7f-0xff) are represented in modified BASE64, ...".

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-imap: test-imap-utf7 - comprehensive test suite
Phil Carmody [Mon, 28 Jul 2014 13:49:47 +0000 (16:49 +0300)] 
lib-imap: test-imap-utf7 - comprehensive test suite
Several MUST NOTs or other standards violations were not being
trapped.

test_imap_utf7_unnecessary() tests:
  Modified BASE64 MUST NOT be used to represent any printing US-ASCII
  character which can represent itself.

test_imap_utf7_bad_ascii() tests:
  All other characters (octet values 0x00-0x1f and 0x7f-0xff) are
  represented in modified BASE64, ...

test_imap_utf7_non_utf16() tests that data containing a single straggling
octet is trapped.

test_imap_utf7_by_example() and test_imap_utf7_ucs4_cases() are just
the previous test suite split into 2 smaller tests.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-imap: test-imap-utf7 - migrate to test_assert_idx
Phil Carmody [Mon, 28 Jul 2014 13:49:47 +0000 (16:49 +0300)] 
lib-imap: test-imap-utf7 - migrate to test_assert_idx
Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: test-str-sanitize - tighten tests
Phil Carmody [Mon, 28 Jul 2014 13:49:47 +0000 (16:49 +0300)] 
lib: test-str-sanitize - tighten tests
Check that the identical string is returned in the no-change case, not
just a copy.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-test: make internal helpers static
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib-test: make internal helpers static
These functions should only be called from within test_run(), as some of the
test-suite sanity checks can be subvirted if these are exposed.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib-test: quieten the random seed printfs
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib-test: quieten the random seed printfs
We only need to know the seed once.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: compile time checks for buffer creation
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: compile time checks for buffer creation
Ensure the data buffer has as much space as the size parameter claims.
This uses the strictest test GCC provides - the smallest containing object,
and returning 0 for unknown size.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: data-stack - start sentry checks immediately after the reserved buffer
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: data-stack - start sentry checks immediately after the reserved buffer
Our sentries are written with byte-precision, no need to round up before
doing the checks.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: data-stack - add DEBUG size and sentry updating to t_try_realloc
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: data-stack - add DEBUG size and sentry updating to t_try_realloc
Without this, t_pop() will report errors.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: test-data-stack - add realloc tests
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: test-data-stack - add realloc tests
These will fail noisily with a DEBUG build until the realloc/DEBUG
bug is fixed.

11 years agolib: data-stack - fix incorrect pointer comparison in t_try_realloc in DEBUG builds
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: data-stack - fix incorrect pointer comparison in t_try_realloc in DEBUG builds
When trying to work out if it's a valid realloc, we need to remember
that in DEBUG builds, we have hidden a size value (in a MEM_ALIGNED
space) before the pointer we return.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: data-stack - fix realloc/lowwater bug
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: data-stack - fix realloc/lowwater bug
If DEBUG is enabled, then it can try to look past the low-water mark
as the low-water mark wasn't moved during successful reallocs. This
condition is detected, and causes a panic.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: data-stack - t_try_realloc get alloc size right in DEBUG builds
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: data-stack - t_try_realloc get alloc size right in DEBUG builds
Also introduce a helper variable for the common expression for readability.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: data-stack - helper for last alloc ends at block.data+(size-left)
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: data-stack - helper for last alloc ends at block.data+(size-left)
Less to read, and less noisy.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: data-stack - add vital sanity-preserving assert to t_pop
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: data-stack - add vital sanity-preserving assert to t_pop
If something has re-ordered those two offsets, the following memset
will explode.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: data-stack - pull common code out of if/else branches in t_malloc_real
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: data-stack - pull common code out of if/else branches in t_malloc_real
Once the new block is set up nicely empty for use, it can be used exactly
like an old block that has enough space - so just merge the code paths.
(This changeset best viewed ignoring whitespace.)

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: data-stack - reorder full current block code
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: data-stack - reorder full current block code
Make the "enough space" and "block is full" branches in t_malloc_real
have the same code structure for parallelism. The 'block' variable is only
needed very locally, so shrink its scope, and avoid its use once it is
assigned to current_block, use that instead. Compacter readable expressions
have been favoured at the expense of longer lines (which will soon shrink).

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: data-stack - helper macro for requested/allocated size
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: data-stack - helper macro for requested/allocated size
Rather than #if/#else/#endif around such calculations, or even
having the possibility to mistype such expressions, just extract
the calculation into a helper macro defined appropriately for
the DEBUG mode.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: data-stack - disambiguate sizes in t_pop_verify
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: data-stack - disambiguate sizes in t_pop_verify
In DEBUG mode, the allocated size is bigger than the requested size, so
rename the variable to reflect its real meaning, and move it into a
tighter scope in the process.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: test-data-stack - too important a library not to be thrashed hard
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: test-data-stack - too important a library not to be thrashed hard
OK, it's thrashed a bit by other tests such as aqueue, str, etc., but these
tests attempt to probe all corner cases given detailed knowledge of the
limits of the block/frame implementation.

At the moment, no realloc functionality is tested, as with DEBUG builds
they would fail very noisily.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: data-stack - simplify expressions in data_stack_last_buffer_reset
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: data-stack - simplify expressions in data_stack_last_buffer_reset
Noisy expression used more than once, give it a meaningful name.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: data-stack - enable tighter sanity checks on stack_block allocations
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: data-stack - enable tighter sanity checks on stack_block allocations
The canary doesn't have to be NULL. That's only effective if it will be read
and dereferenced as a pointer. If used as an integer, it's a perfectly boring
one, and not likely to draw attention to itself.

Once the canary is in place, at least in debug mode, we can check it in
every function as a sanity check.

Make our poison stand out from other poison used elsewhere in the code.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: cosmetic - whitespace cleanup in allocator/memory-related code
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: cosmetic - whitespace cleanup in allocator/memory-related code
Indentation used spaces. Some trailing whitespace found.

$ git diff -w
$

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: add rudementary statistics gathering to data-stack debugging
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: add rudementary statistics gathering to data-stack debugging
These currently just enhance the overly-large alloc_size warning
message in t_malloc_real() to show what the history of allocations
is. New warnings look like this:
 Warning: Growing data stack by 32768 as 'test_run_funcs' reaches 16416 bytes from 202 allocations.

Future possible directions:
t_malloc_real() could be further modified to identify badly-behaved
regions of code that allocate lots of smaller blocks as it happens
(which might be noisy). t_pop() could be modified to detect such code
after it exits its block (so just one warning per instance of
misbehaviour).

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agolib: add markers to data-stack debug prints
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: add markers to data-stack debug prints
Only the DEBUG code will have access to the frame's marker.

11 years agolib: add identifying markers to data-stack frames
Phil Carmody [Mon, 28 Jul 2014 13:45:33 +0000 (16:45 +0300)] 
lib: add identifying markers to data-stack frames
Add a string parameter to t_push() so that in DEBUG mode,
misbehaviour inside a stack level can be blamed on someone.

Default the T_BEGIN macro to automatigally use __FUNCTION__ or
__FILE__:__LINE__ as that identifier, therefore no clients of
those macros need to change.

ioloop used t_push() directly as it wanted customised diagnostic
strings. To preserve this friendliness, also introduce a t_push_named()
which takes a format string with paramters.

Apart from the unused paramter, a non-DEBUG build should see no
changes.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
11 years agodoveadm: Added dict commands to access lib-dict via command line.
Timo Sirainen [Mon, 28 Jul 2014 13:40:25 +0000 (16:40 +0300)] 
doveadm: Added dict commands to access lib-dict via command line.
For debugging and data dumping purposes.

11 years agolib-storage: Don't allow '/' for filesystem based mailbox list backends if their...
Timo Sirainen [Mon, 28 Jul 2014 12:14:17 +0000 (15:14 +0300)] 
lib-storage: Don't allow '/' for filesystem based mailbox list backends if their internal separator isn't '/'.
Basically this means that Maildir++ shouldn't be allowed to create mailboxes
with '/' in the name.

11 years agolast-login plugin added. It updates user's login timestamp to configured dict.
Timo Sirainen [Fri, 25 Jul 2014 11:10:04 +0000 (14:10 +0300)] 
last-login plugin added. It updates user's login timestamp to configured dict.
Example config:

plugin {
  last_login_dict = redis:host=127.0.0.1:port=6379
  #last_login_key = last-login/%u # default
}

11 years agolib-storage: Set mail_user->session_id before calling mail_user_init()
Timo Sirainen [Fri, 25 Jul 2014 10:35:57 +0000 (13:35 +0300)] 
lib-storage: Set mail_user->session_id before calling mail_user_init()

11 years agolib-http: Fixed linking test programs.
Timo Sirainen [Mon, 21 Jul 2014 08:00:59 +0000 (11:00 +0300)] 
lib-http: Fixed linking test programs.

11 years agolib-http: Added initial support for server-side HTTP API.
Stephan Bosch [Mon, 21 Jul 2014 07:54:05 +0000 (10:54 +0300)] 
lib-http: Added initial support for server-side HTTP API.

11 years agorawlog: Added -i parameter to include the remote IP address in the filename.
Timo Sirainen [Mon, 21 Jul 2014 07:53:19 +0000 (10:53 +0300)] 
rawlog: Added -i parameter to include the remote IP address in the filename.

11 years agomailbox_list_index=yes: Don't update INBOX's STATUS information to index.
Timo Sirainen [Fri, 11 Jul 2014 13:49:35 +0000 (16:49 +0300)] 
mailbox_list_index=yes: Don't update INBOX's STATUS information to index.
This should reduce disk I/O

11 years agoauth: If userdb prefetch is configured wrong, return temporary failure instead of...
Timo Sirainen [Fri, 11 Jul 2014 11:27:52 +0000 (14:27 +0300)] 
auth: If userdb prefetch is configured wrong, return temporary failure instead of "user not known"

11 years agolib-http: Debug log now includes where HTTP requests spent their time on.
Timo Sirainen [Fri, 11 Jul 2014 11:17:17 +0000 (14:17 +0300)] 
lib-http: Debug log now includes where HTTP requests spent their time on.

11 years agolib: Added fd=-1 assert to i_close_fd() macro.
Timo Sirainen [Fri, 11 Jul 2014 09:10:02 +0000 (12:10 +0300)] 
lib: Added fd=-1 assert to i_close_fd() macro.
This way we'll see clearly where it fails, instead of just seeing assert in
close_keep_errno() without an easy way to see where it crashed.