]> git.ipfire.org Git - thirdparty/dovecot/core.git/log
thirdparty/dovecot/core.git
8 years agolib-storage: Avoid index refresh with mailbox_list_index_very_dirty_syncs=yes
Timo Sirainen [Thu, 6 Jul 2017 16:00:35 +0000 (19:00 +0300)] 
lib-storage: Avoid index refresh with mailbox_list_index_very_dirty_syncs=yes

8 years agolib-storage: Refresh mailbox list index if mailbox's existence differs from index
Timo Sirainen [Thu, 6 Jul 2017 14:48:19 +0000 (17:48 +0300)] 
lib-storage: Refresh mailbox list index if mailbox's existence differs from index

8 years agolib-storage: Set mailbox list index to be refreshed after changes, not before
Timo Sirainen [Thu, 6 Jul 2017 14:45:02 +0000 (17:45 +0300)] 
lib-storage: Set mailbox list index to be refreshed after changes, not before

Mailbox deletion and rename set the refresh-flag before the change was done.
This was unnecessary if the change didn't happen. Also there was a race
condition that another process could have done the refresh before the
change was even done.

8 years agolib-storage: Add mailbox_list_last_error_push/pop()
Timo Sirainen [Thu, 6 Jul 2017 14:36:28 +0000 (17:36 +0300)] 
lib-storage: Add mailbox_list_last_error_push/pop()

These are similar to mail_storage_last_error_push/pop()

8 years agolib-storage: Try to avoid opening mailbox list index on mailbox access
Timo Sirainen [Mon, 10 Jul 2017 11:37:04 +0000 (14:37 +0300)] 
lib-storage: Try to avoid opening mailbox list index on mailbox access

Perform the STATUS (and other relevant) updates only if syncing or
transaction commits changed anything. This could be optimized further to
check even more strongly whether the seen changes could cause changes to
the list index, but it's probably not worth the effort.

8 years agolib-storage: Storage backend sync_init()s no longer need to check if mailbox is open
Timo Sirainen [Mon, 10 Jul 2017 11:20:50 +0000 (14:20 +0300)] 
lib-storage: Storage backend sync_init()s no longer need to check if mailbox is open

The previous change guarantees it.

8 years agolib-storage: mailbox_sync_init() - open mailbox immediately if it's not open yet
Timo Sirainen [Mon, 10 Jul 2017 11:19:47 +0000 (14:19 +0300)] 
lib-storage: mailbox_sync_init() - open mailbox immediately if it's not open yet

This simplifies the work for plugins that want to hook into
mailbox.sync_init() so they no longer have to handle the "mailbox isn't
opened" case.

8 years agoimap: Don't do autoexpunging when IMAP client is hibernated
Timo Sirainen [Mon, 10 Jul 2017 10:56:49 +0000 (13:56 +0300)] 
imap: Don't do autoexpunging when IMAP client is hibernated

8 years agoglobal: Replaced t_strsplit_tab() calls with t_strsplit_tabescaped()
Timo Sirainen [Thu, 20 Oct 2016 14:45:44 +0000 (17:45 +0300)] 
global: Replaced t_strsplit_tab() calls with t_strsplit_tabescaped()

This is useful especially in auth code to support LFs in extra fields.

Other pieces of code were also tab-escaping strings, but never unescaping
them. Usually it didn't matter, because nobody would use the escaped
characters. Still, the code wasn't exactly behaving correctly.

One downside to this change is that it's now possible to pass through TABs,
CRs and LFs through the various protocols. In theory this shouldn't cause
any problems, but combined with other bugs this could trigger some security
problems.

8 years agofts: Do not attempt to deinitialize backend if it's not set
Aki Tuomi [Wed, 17 May 2017 09:26:42 +0000 (12:26 +0300)] 
fts: Do not attempt to deinitialize backend if it's not set

If FTS backend initialization fails or does not happen,
flist->backend might end up being NULL, and attempt to
deinitialize NULL won't end well.

8 years agoimap: Add more error checking to NOTIFY parameter parsing
Timo Sirainen [Fri, 30 Jun 2017 14:51:34 +0000 (17:51 +0300)] 
imap: Add more error checking to NOTIFY parameter parsing

This should make it clearer to realize when invalid syntax is being used
rather than just ignoring the problem.

8 years agoimap: Fix NOTIFY parameter parsing by reverting earlier change
Timo Sirainen [Fri, 30 Jun 2017 14:33:15 +0000 (17:33 +0300)] 
imap: Fix NOTIFY parameter parsing by reverting earlier change

I misread the RFC and wrote broken tests.
Reverts 64d2efdc4b0bdf92249840e9db89b91c8dc0f3a3

8 years agolib-storage: mail_add_temp_wanted_fields() - delay opening stream
Timo Sirainen [Sun, 25 Jun 2017 06:10:52 +0000 (09:10 +0300)] 
lib-storage: mail_add_temp_wanted_fields() - delay opening stream

Allows plugins to call it in mail.get_stream() without infinite loop.

8 years agolib-storage: Another fix to mail storage initialization.
Timo Sirainen [Mon, 2 May 2016 21:25:43 +0000 (00:25 +0300)] 
lib-storage: Another fix to mail storage initialization.

Allow mail_namespaces_init_location() to add the namespace directly to user,
since that's what the current callers always want. But compared to the
original code we're now calling mail_namespaces_init_finish() rather than
doing the same things ourself.

8 years agolib-storage: Changed mail storage initialization.
Timo Sirainen [Mon, 2 May 2016 14:00:22 +0000 (17:00 +0300)] 
lib-storage: Changed mail storage initialization.

Most importantly require mail_namespaces_init_finish() after
mail_storage_create(). This was needed so that
mail_namespaces_created/added hook would always have the ns->list set, which
is required for several of the hooks to work (e.g. mailbox list index)

8 years agoimapc: Prefech - Initialize cached stream only if needed
Timo Sirainen [Mon, 3 Jul 2017 18:08:02 +0000 (21:08 +0300)] 
imapc: Prefech - Initialize cached stream only if needed

If the mail is immediately accessed for other purposes (e.g. fetching
message flags), there's no need to go through all the trouble of
initializing the mail stream.

8 years agolib-storage: Fix ITERINDEX to leave \NoSelect parents after deleting child mailbox
Timo Sirainen [Fri, 30 Jun 2017 10:46:22 +0000 (13:46 +0300)] 
lib-storage: Fix ITERINDEX to leave \NoSelect parents after deleting child mailbox

For example if "a/b" was created and deleted, "a" should be left behind.
(Or at least it shouldn't have left "a" to mail root directory and kept it
invisible since it didn't exist in index dir.)

8 years agodbox: Check mailbox existence from index directory with ITERINDEX
Timo Sirainen [Mon, 26 Jun 2017 16:06:26 +0000 (19:06 +0300)] 
dbox: Check mailbox existence from index directory with ITERINDEX

8 years agodbox: Use mail_index_header.last_temp_file_scan instead of directory's atime
Timo Sirainen [Wed, 28 Jun 2017 16:46:01 +0000 (19:46 +0300)] 
dbox: Use mail_index_header.last_temp_file_scan instead of directory's atime

This will be required for the following ITERINDEX change.

8 years agolib-index, lib-storage: Add mail_index_header.last_temp_file_scan
Timo Sirainen [Wed, 28 Jun 2017 16:41:21 +0000 (19:41 +0300)] 
lib-index, lib-storage: Add mail_index_header.last_temp_file_scan

Also add index_mailbox_update_last_temp_file_scan() for easily updating it.

This is reusing an old "sync timestamp" field. Because it was a timestamp,
it doesn't matter if the old data still exists in it. This field could have
been added as an extension, but that's more work and this feature is generic
enough that it should be useful for many of the mail storage backends.

8 years agodbox: Cleanup - reorganize old temp file cleanup code
Timo Sirainen [Mon, 26 Jun 2017 15:59:17 +0000 (18:59 +0300)] 
dbox: Cleanup - reorganize old temp file cleanup code

No functional changes. In preparation for the next commits.

8 years agolib-storage: Check for storage existence from index dir with ITERINDEX
Timo Sirainen [Mon, 26 Jun 2017 16:30:11 +0000 (19:30 +0300)] 
lib-storage: Check for storage existence from index dir with ITERINDEX

The root path creation doesn't really even seem to be necessary, because any
mailbox access will automatically mkdir the missing directories anyway.
Although writing other files might not work so well, such as
mail_attribute_dict that points inside the mail directory.

This change simply changes the mailboxes/ directory to be looked up from
index directory instead of the mail root directory. It also mkdirs the
index/mailboxes/ directory afterwards if it didn't exist. So practically
this change shouldn't break anything, since the mailboxes/ directory should
always exist for both root and the indexes.

8 years agolib-storage: mailbox_list_get_permissions() - Use index dir with ITERINDEX
Timo Sirainen [Mon, 26 Jun 2017 15:50:24 +0000 (18:50 +0300)] 
lib-storage: mailbox_list_get_permissions() - Use index dir with ITERINDEX

8 years agolib-storage: mailbox_list_get_permissions() - Use index dir for storage without mails
Timo Sirainen [Mon, 26 Jun 2017 15:46:30 +0000 (18:46 +0300)] 
lib-storage: mailbox_list_get_permissions() - Use index dir for storage without mails

The index dir might still exist.

8 years agolib-storage: Cleanup - move code to mailbox_list_get_permissions_stat()
Timo Sirainen [Mon, 26 Jun 2017 15:41:27 +0000 (18:41 +0300)] 
lib-storage: Cleanup - move code to mailbox_list_get_permissions_stat()

Comments changed also a bit, but no functional changes.

8 years agolib-storage: Cleanup - Use mailbox_permissions_copy() instead of duplicating it
Timo Sirainen [Mon, 26 Jun 2017 15:23:01 +0000 (18:23 +0300)] 
lib-storage: Cleanup - Use mailbox_permissions_copy() instead of duplicating it

8 years agolib-storage: Add mailbox_permissions_copy()
Timo Sirainen [Mon, 26 Jun 2017 15:19:17 +0000 (18:19 +0300)] 
lib-storage: Add mailbox_permissions_copy()

8 years agolib-storage: Add mail_location=..:ITERINDEX
Timo Sirainen [Mon, 26 Jun 2017 17:10:17 +0000 (20:10 +0300)] 
lib-storage: Add mail_location=..:ITERINDEX

This changes mailbox list iteration to work using INDEX directory instead of
the normal mail directory. This can be helpful when the indexes are stored
on a faster storage.

8 years agosdbox: Don't create index directory when trying to open nonexistent mailboxes
Timo Sirainen [Tue, 27 Jun 2017 13:55:34 +0000 (16:55 +0300)] 
sdbox: Don't create index directory when trying to open nonexistent mailboxes

8 years agolib-storage: Fix mailbox delete to not delete childrens' INDEX or CONTROL dirs
Timo Sirainen [Fri, 30 Jun 2017 10:56:54 +0000 (13:56 +0300)] 
lib-storage: Fix mailbox delete to not delete childrens' INDEX or CONTROL dirs

If mail_location had separate INDEX and/or CONTROL set, deleting a mailbox
with children caused the childrens' index and/or control directories to be
deleted (but the mail/ALT directories weren't).

I'm not sure why the _FLAG_MAILBOX_FILES was treated as a special case
earlier. It shouldn't make a difference.

8 years agolib-storage: mailbox_list_delete_mailbox_nonrecursive() - Fix error handling
Timo Sirainen [Tue, 27 Jun 2017 12:39:12 +0000 (15:39 +0300)] 
lib-storage: mailbox_list_delete_mailbox_nonrecursive() - Fix error handling

It should return error on unexpected readdir(), closedir() and unlink()
failures. Also fix handling a race condition with another process deleting
the mailbox at the same time.

8 years agolib-storage: mailbox_list_delete_trash() - Don't ignore errors
Timo Sirainen [Tue, 27 Jun 2017 13:56:08 +0000 (16:56 +0300)] 
lib-storage: mailbox_list_delete_trash() - Don't ignore errors

8 years agolib-storage: Use mailbox_list_delete_finish_ret() for fs & maildir++ layout
Timo Sirainen [Tue, 27 Jun 2017 13:37:16 +0000 (16:37 +0300)] 
lib-storage: Use mailbox_list_delete_finish_ret() for fs & maildir++ layout

Fixes a problem where e.g. index directory existed but mail root didn't,
and the mailbox couldn't be fully deleted. This was especially a problem
with ITERINDEX enabled.

8 years agolib-storage: Add mailbox_list_delete_finish_ret()
Timo Sirainen [Tue, 27 Jun 2017 13:36:56 +0000 (16:36 +0300)] 
lib-storage: Add mailbox_list_delete_finish_ret()

This simplifies deletion logic for mailbox list backends.

8 years agolib-storage: mailbox_list_delete_finish() - Return whether anything was deleted
Timo Sirainen [Tue, 27 Jun 2017 13:13:34 +0000 (16:13 +0300)] 
lib-storage: mailbox_list_delete_finish() - Return whether anything was deleted

8 years agolib-storage: Add mailbox_list_get_last_mail_error()
Timo Sirainen [Tue, 27 Jun 2017 13:16:21 +0000 (16:16 +0300)] 
lib-storage: Add mailbox_list_get_last_mail_error()

8 years agolib-storage: Add comments to mailbox-list-delete.h
Timo Sirainen [Tue, 27 Jun 2017 12:57:10 +0000 (15:57 +0300)] 
lib-storage: Add comments to mailbox-list-delete.h

8 years agolib: Fix file_create_locked() unit test to delete temp file afterwards
Timo Sirainen [Wed, 28 Jun 2017 20:37:22 +0000 (23:37 +0300)] 
lib: Fix file_create_locked() unit test to delete temp file afterwards

Also removed a path string that was never used.

8 years agolib-storage: Add VOLATILEDIR setting to mail_location
Timo Sirainen [Wed, 21 Jun 2017 22:28:57 +0000 (01:28 +0300)] 
lib-storage: Add VOLATILEDIR setting to mail_location

This is useful for creating temporary locks that could exist in tmpfs.
Currently this is used for .vsize.lock and dovecot.autoexpunge.lock.

8 years agolib-storage: Move autoexpunge lock creation to a generic mail_user_lock_file_create()
Timo Sirainen [Wed, 21 Jun 2017 23:44:12 +0000 (02:44 +0300)] 
lib-storage: Move autoexpunge lock creation to a generic mail_user_lock_file_create()

8 years agolib-storage: mailbox_autoexpunge_lock() - Don't hide ENOENT error
Timo Sirainen [Wed, 21 Jun 2017 23:33:03 +0000 (02:33 +0300)] 
lib-storage: mailbox_autoexpunge_lock() - Don't hide ENOENT error

It means that the user's home directory doesn't exist, which is pretty
unexpected. Home directory is supposed to be created when the storage is
initialized.

8 years agolib-storage: mailbox_autoexpunge_lock() - small cleanup
Timo Sirainen [Wed, 21 Jun 2017 23:32:10 +0000 (02:32 +0300)] 
lib-storage: mailbox_autoexpunge_lock() - small cleanup

No functional changes - just reorganizing code and adding comments.

8 years agolib-storage: Use file_lock_set_*_on_free() for dovecot.autoexpunge.lock
Timo Sirainen [Wed, 21 Jun 2017 23:24:08 +0000 (02:24 +0300)] 
lib-storage: Use file_lock_set_*_on_free() for dovecot.autoexpunge.lock

8 years agolib-storage: Move .vsize.lock creation to a generic mailbox_lock_file_create()
Timo Sirainen [Wed, 21 Jun 2017 23:19:18 +0000 (02:19 +0300)] 
lib-storage: Move .vsize.lock creation to a generic mailbox_lock_file_create()

8 years agolib-storage: Move .vsize.lock creation to its own function
Timo Sirainen [Wed, 21 Jun 2017 23:07:16 +0000 (02:07 +0300)] 
lib-storage: Move .vsize.lock creation to its own function

8 years agolib-storage: Use file_lock_set_*_on_free() for .vsize.lock
Timo Sirainen [Wed, 21 Jun 2017 23:05:16 +0000 (02:05 +0300)] 
lib-storage: Use file_lock_set_*_on_free() for .vsize.lock

This avoids storing the lock_path and lock_fd separately.

8 years agolib-storage: Fix error logging for failing to create .vsize.lock
Timo Sirainen [Wed, 21 Jun 2017 22:56:18 +0000 (01:56 +0300)] 
lib-storage: Fix error logging for failing to create .vsize.lock

8 years agolib: file_create_locked() - Add settings to mkdir() missing parent directories
Timo Sirainen [Wed, 28 Jun 2017 14:48:01 +0000 (17:48 +0300)] 
lib: file_create_locked() - Add settings to mkdir() missing parent directories

8 years agolib: Add unit test for file_create_locked()
Timo Sirainen [Wed, 28 Jun 2017 14:40:20 +0000 (17:40 +0300)] 
lib: Add unit test for file_create_locked()

8 years agolib: Add file_lock_set_close_on_free()
Timo Sirainen [Wed, 21 Jun 2017 22:52:29 +0000 (01:52 +0300)] 
lib: Add file_lock_set_close_on_free()

8 years agolib: Add file_lock_set_unlink_on_free()
Timo Sirainen [Wed, 21 Jun 2017 22:47:51 +0000 (01:47 +0300)] 
lib: Add file_lock_set_unlink_on_free()

8 years agolib: file_create_locked() - update lock path after link()
Timo Sirainen [Thu, 22 Jun 2017 07:35:16 +0000 (10:35 +0300)] 
lib: file_create_locked() - update lock path after link()

8 years agolib: Add file_lock_set_path()
Timo Sirainen [Thu, 22 Jun 2017 06:05:06 +0000 (09:05 +0300)] 
lib: Add file_lock_set_path()

8 years agolib: Add file_lock_get_path()
Timo Sirainen [Wed, 21 Jun 2017 22:42:56 +0000 (01:42 +0300)] 
lib: Add file_lock_get_path()

This allows getting the file path from the lock without having to preserve
it separately.

8 years agopop3-migration: Drop lines with only spaces or tabs from comparison
Timo Sirainen [Wed, 28 Jun 2017 12:50:11 +0000 (15:50 +0300)] 
pop3-migration: Drop lines with only spaces or tabs from comparison

Zimbra drops out those lines from IMAP BODY[HEADER] replies.

8 years agodsync: Use header hashing version 3
Timo Sirainen [Fri, 23 Jun 2017 08:15:32 +0000 (11:15 +0300)] 
dsync: Use header hashing version 3

8 years agopop3-migration: Replace trailing whitespace removal with new header hashing version
Timo Sirainen [Fri, 23 Jun 2017 08:02:24 +0000 (11:02 +0300)] 
pop3-migration: Replace trailing whitespace removal with new header hashing version

This is now done by message_header_hash(), which makes it work correctly
also for dsync+imapc.

Reverts 0cf3b30b86e6c39f43b8e13a718cd078187ca86d, except for the unit tests.

8 years agolib-mail: message_header_hash_more() - add v3 that strips spaces
Timo Sirainen [Fri, 23 Jun 2017 08:00:37 +0000 (11:00 +0300)] 
lib-mail: message_header_hash_more() - add v3 that strips spaces

This helps with Zimbra, which strips away trailing whitespaces in
BODY[HEADER].

8 years agolib-mail: test-message-header-hash - add more tests
Timo Sirainen [Fri, 23 Jun 2017 06:24:40 +0000 (09:24 +0300)] 
lib-mail: test-message-header-hash - add more tests

8 years agolib-mail: message_header_hash_more() - refactor to use switch()
Timo Sirainen [Fri, 23 Jun 2017 06:14:40 +0000 (09:14 +0300)] 
lib-mail: message_header_hash_more() - refactor to use switch()

8 years agoquota: Fix failing again if quota setting has invalid parameters
Timo Sirainen [Thu, 22 Jun 2017 08:43:05 +0000 (11:43 +0300)] 
quota: Fix failing again if quota setting has invalid parameters

This was broken by the recent quota parameter parsing changes.

8 years agolib-imap: imap_append_nstring_nolf() - fix crash with datastack_pool strings
Sergey Kitov [Tue, 20 Jun 2017 09:11:37 +0000 (12:11 +0300)] 
lib-imap: imap_append_nstring_nolf() - fix crash with datastack_pool strings

T_BEGIN .. T_END is not used, when string_t is allocated from
datastack pool, unit test updated to verify the fix.

8 years agoacl: Add acl_globals_only setting
Timo Sirainen [Mon, 19 Jun 2017 20:43:17 +0000 (23:43 +0300)] 
acl: Add acl_globals_only setting

The local dovecot-acl files aren't even attempted to be looked up if this is
set. This is mainly useful to avoid unnecessary stat()s to dovecot-acl files
that never exist.

8 years agodirector: Fix logging last input/output time when there was no input/output
Timo Sirainen [Mon, 19 Jun 2017 09:05:30 +0000 (12:05 +0300)] 
director: Fix logging last input/output time when there was no input/output

8 years agodirector: Fix whitespace position in some log messages
Timo Sirainen [Mon, 19 Jun 2017 09:03:13 +0000 (12:03 +0300)] 
director: Fix whitespace position in some log messages

8 years agodirector: Use longer timeout for receiving user list in handshake
Timo Sirainen [Wed, 31 May 2017 11:27:16 +0000 (14:27 +0300)] 
director: Use longer timeout for receiving user list in handshake

The sender also has a send timeout, so this allows the sender to abort
early and give a nicer error message.

8 years agodirector: Log more connection state information on handshaking errors
Timo Sirainen [Wed, 31 May 2017 10:42:31 +0000 (13:42 +0300)] 
director: Log more connection state information on handshaking errors

8 years agodirector: Use more accurate timestamps for handshake timeout logging
Timo Sirainen [Wed, 31 May 2017 10:17:37 +0000 (13:17 +0300)] 
director: Use more accurate timestamps for handshake timeout logging

There could be some time between the create, connect and when ME was
received.

8 years agodirector: Fix "sending handshake timed out" error to be actually logged
Timo Sirainen [Wed, 31 May 2017 10:15:04 +0000 (13:15 +0300)] 
director: Fix "sending handshake timed out" error to be actually logged

io was never NULL here, so it was never logged.

8 years agodirector: Fix handshake timeout lengths
Timo Sirainen [Wed, 31 May 2017 10:11:08 +0000 (13:11 +0300)] 
director: Fix handshake timeout lengths

They weren't too bad, but also they weren't what the #defines described.
Also added a separate connect() timeout.

8 years agoimap: NOTIFY - Fix potential crash when reading invalid parameters
Timo Sirainen [Sat, 17 Jun 2017 11:39:59 +0000 (14:39 +0300)] 
imap: NOTIFY - Fix potential crash when reading invalid parameters

8 years agoimap: Fix NOTIFY to parse more than just the first event-group
Timo Sirainen [Sat, 17 Jun 2017 11:38:22 +0000 (14:38 +0300)] 
imap: Fix NOTIFY to parse more than just the first event-group

8 years agolib-http: Fix memory leak in HTTP connection deinit
Timo Sirainen [Mon, 19 Jun 2017 08:21:14 +0000 (11:21 +0300)] 
lib-http: Fix memory leak in HTTP connection deinit

8 years agoimap: NOTIFY - Cleanup notify watch timeout handling
Timo Sirainen [Sun, 18 Jun 2017 21:01:17 +0000 (00:01 +0300)] 
imap: NOTIFY - Cleanup notify watch timeout handling

It's not useful to set the timeout until all the commands are finished.

8 years agoimap: NOTIFY - Fix crash due to not hooking into commands correctly
Timo Sirainen [Sun, 18 Jun 2017 08:14:05 +0000 (11:14 +0300)] 
imap: NOTIFY - Fix crash due to not hooking into commands correctly

The pre/post hooks aren't always called immediately when commands are
created. They're called only after the command input is being read.
Call notify hooks explicitly now immediately when commands are allocated.

Fixes a panic with for example:

a notify set (selected (Messagenew (uid flags) MessageExpunge FlagChange) personal (MessageNew MessageExpunge FlagChange))
b select inbox
c store 1 +flags \deleted
d expunge
e append inbox {10}

Which crashed with:
Panic: file imap-notify.c: line 397 (imap_notify_callback): assertion failed: (client->command_queue_size == 0)

8 years agoimap: NOTIFY - Fix delayed setting notification callback
Timo Sirainen [Sun, 18 Jun 2017 08:19:28 +0000 (11:19 +0300)] 
imap: NOTIFY - Fix delayed setting notification callback

This was done in command-post hook, but then when command was soon freed the
callback was immediately added.

8 years agolib-lda: Fix memory leak in smtp_client_open()
Timo Sirainen [Mon, 19 Jun 2017 06:22:56 +0000 (09:22 +0300)] 
lib-lda: Fix memory leak in smtp_client_open()

8 years ago*-login: Add client_vfuncs.free() that is called when client refcount=0
Timo Sirainen [Fri, 16 Jun 2017 11:34:24 +0000 (14:34 +0300)] 
*-login: Add client_vfuncs.free() that is called when client refcount=0

This can be useful for plugins that want to run something after proxying
ends.

Use an empty default function so plugins can call super.free() without
having to check if it's NULL.

8 years ago*-login: Add client_vfuncs.input_next_cmd()
Timo Sirainen [Mon, 12 Jun 2017 19:52:56 +0000 (22:52 +0300)] 
*-login: Add client_vfuncs.input_next_cmd()

This allows plugins to hook into all the pre-login commands. For example
with imap-login most of the commands could already be hooked into, except
for ID and AUTHENTICATE because their parameters reading is handled
specially. This allows hooking into them as well.

This is actually internal to all the login binaries, so it wouldn't have to
be in login-common. However, login-common already has all the code to handle
overriding functions nicely and this is a rather useful feature for all the
protocols anyway, so it's easier this way and not too ugly.

8 years agopop3-login: Cleanup - move command handling to pop3_client_input_next_cmd()
Timo Sirainen [Mon, 12 Jun 2017 19:51:12 +0000 (22:51 +0300)] 
pop3-login: Cleanup - move command handling to pop3_client_input_next_cmd()

8 years agoimap: Fix pipelining commands with SEARCH
Timo Sirainen [Mon, 12 Jun 2017 20:20:12 +0000 (23:20 +0300)] 
imap: Fix pipelining commands with SEARCH

If the SEARCH wasn't a long-running one, it ends with going to sync.
The command state shouldn't then be changed to _WAIT_EXTERNAL.

8 years agolib-imap: imap_bodystructure_write is changed to skip CRs and LFs.
Sergey Kitov [Wed, 14 Jun 2017 07:44:36 +0000 (10:44 +0300)] 
lib-imap: imap_bodystructure_write is changed to skip CRs and LFs.

8 years agolib-imap: imap_write_envelope changed to skip CRs and LFs.
Sergey Kitov [Wed, 14 Jun 2017 07:44:01 +0000 (10:44 +0300)] 
lib-imap: imap_write_envelope changed to skip CRs and LFs.

8 years agolib-imap: added imap_append_nstring_nolf(), which skips CRs and LFs.
Sergey Kitov [Wed, 14 Jun 2017 07:41:04 +0000 (10:41 +0300)] 
lib-imap: added imap_append_nstring_nolf(), which skips CRs and LFs.

8 years agolib-imap: escaping and quote/literal tests for imap_append_nstring()
Sergey Kitov [Tue, 13 Jun 2017 07:05:23 +0000 (10:05 +0300)] 
lib-imap: escaping and quote/literal tests for imap_append_nstring()

8 years agoimapc: Fix prefetching specific headers
Timo Sirainen [Mon, 12 Jun 2017 21:57:08 +0000 (00:57 +0300)] 
imapc: Fix prefetching specific headers

FETCH BODY[HEADER.FIELDS ...] shouldn't be used if imapc_features doesn't
include fetch-headers. Also neither this nor BODY[HEADER] should be sent
if we already have header/body stream.

8 years agoimapc: Avoid sending FETCH BODY[HEADER] when BODY[] is already being fetched
Timo Sirainen [Mon, 12 Jun 2017 21:55:36 +0000 (00:55 +0300)] 
imapc: Avoid sending FETCH BODY[HEADER] when BODY[] is already being fetched

This probably only shows up in some special situations with plugins.

8 years agolib-oauth2: Handle non-2xx/4xx results for token validation without crash
Timo Sirainen [Tue, 13 Jun 2017 15:26:26 +0000 (18:26 +0300)] 
lib-oauth2: Handle non-2xx/4xx results for token validation without crash

Fixes:
Panic: file oauth2-token-validate.c: line 33 (oauth2_token_validate_continue): assertion failed: (array_is_created(&req->fields))

8 years agolib-oauth2: Make sure fields are always initialized
Aki Tuomi [Tue, 6 Jun 2017 09:47:53 +0000 (12:47 +0300)] 
lib-oauth2: Make sure fields are always initialized

8 years agolib-oauth2: Accept empty responses
Aki Tuomi [Tue, 6 Jun 2017 09:44:55 +0000 (12:44 +0300)] 
lib-oauth2: Accept empty responses

8 years agoimap-login: Fix storing ID NIL values into client_id
Timo Sirainen [Thu, 15 Jun 2017 09:46:47 +0000 (12:46 +0300)] 
imap-login: Fix storing ID NIL values into client_id

8 years agoimap-login: Remove duplicate spaces between ID x-forward parameters
Timo Sirainen [Wed, 14 Jun 2017 08:47:00 +0000 (11:47 +0300)] 
imap-login: Remove duplicate spaces between ID x-forward parameters

8 years agoimap-login: Fix crash in ID if trusted client sends NIL value to internal field
Timo Sirainen [Wed, 14 Jun 2017 07:50:38 +0000 (10:50 +0300)] 
imap-login: Fix crash in ID if trusted client sends NIL value to internal field

Fixes:
Panic: imap-login: file imap-login-client.c: line 215 (cmd_id_handle_keyvalue): assertion failed: (client_id_str == !client_id_reserved_word(key))

8 years agolib-index: Fix cache lookups from uncommitted transactions with in-memory indexes
Timo Sirainen [Tue, 13 Jun 2017 19:14:11 +0000 (22:14 +0300)] 
lib-index: Fix cache lookups from uncommitted transactions with in-memory indexes

This especially fixes mail_get_header_stream() with imapc and
imapc_features=fetch-headers, because it works by first fetching the
specific headers and putting them to the cache transaction, then later on
relying on index_mail_get_header_stream() to get them from the transaction.
Before this fix they wouldn't be found, which triggered another unnecessary
FETCH BODY.PEEK[HEADER].

8 years agolib-mail: istream-header-filter - Fix HEADER_FILTER_ADD_MISSING_EOH with empty input
Timo Sirainen [Tue, 13 Jun 2017 18:54:00 +0000 (21:54 +0300)] 
lib-mail: istream-header-filter - Fix HEADER_FILTER_ADD_MISSING_EOH with empty input

The result for "" should be "\n", not "\n\n". The second "\n" would belong
to the mail body.

This fixes calculating hashes for incremental dsync when mail didn't have
Date or Message-ID headers, resulting in e.g.:

Warning: Deleting mailbox 'INBOX': UID=1 already exists locally for a different mail: Headers hashes don't match (e1c06d85ae7b8b032bef47e42e4c08f9 vs 68b329da9893e34099c7d8ad5cb9c940)

8 years agolib: istream-seekable - Fix reading when parent stream's content is larger than max_b...
Timo Sirainen [Wed, 14 Jun 2017 00:21:19 +0000 (03:21 +0300)] 
lib: istream-seekable - Fix reading when parent stream's content is larger than max_buffer_size

When writing the parent stream to fd and trying to read it back, it would
try to enforce the max_buffer_size and fail with:

istream-seekable: Couldn't read back in-memory input ...: buffer full

But since the data was already in buffer, istream-seekable shouldn't try to
enforce it at this point anymore.

8 years agopush-notification: Switch to main ioloop while calling drivers' commit callbacks
Timo Sirainen [Mon, 12 Jun 2017 20:45:05 +0000 (23:45 +0300)] 
push-notification: Switch to main ioloop while calling drivers' commit callbacks

There aren't any guarantees what ioloop happens to be active at the time
the commit is called. The active ioloop can also be destroyed early on,
which can cause an I/O leak and crashes later on.

8 years agomail-crypt-acl: Fix assert-crash due to missing namespace initialization
Timo Sirainen [Fri, 9 Jun 2017 15:10:14 +0000 (18:10 +0300)] 
mail-crypt-acl: Fix assert-crash due to missing namespace initialization

This was broken by e031d9aaae59a9f79710dc1138b76b69272615a3.

8 years agopop3: send back auth reply sooner
Josef 'Jeff' Sipek [Tue, 23 May 2017 11:12:49 +0000 (14:12 +0300)] 
pop3: send back auth reply sooner

If possible (i.e., pop3_lock_session=no), we can send back the OK
response earlier.

8 years agopop3: initialize namespaces explicitly
Josef 'Jeff' Sipek [Tue, 23 May 2017 10:01:48 +0000 (13:01 +0300)] 
pop3: initialize namespaces explicitly

(instead of relying on mail user initialization to instantiate them for
us)