]> git.ipfire.org Git - thirdparty/dovecot/core.git/log
thirdparty/dovecot/core.git
7 years agolib-smtp: client: Fix assertion panic occurring when DATA dot stream cannot be finish...
Stephan Bosch [Fri, 18 May 2018 08:24:46 +0000 (10:24 +0200)] 
lib-smtp: client: Fix assertion panic occurring when DATA dot stream cannot be finished immediately.

If o_stream_finish() returns 0, o_stream_send_istream() would be called again
later which causes the panic. Instead, it should only call o_stream_finish() or
o_stream_flush() again to finish the last bit of the output.

Panic was:

Panic: file ostream.c: line 394 (o_stream_send_istream): assertion failed: (!_outstream->finished)

7 years agocassandra: Fix consistency=quorum to work
Timo Sirainen [Thu, 17 May 2018 13:29:28 +0000 (16:29 +0300)] 
cassandra: Fix consistency=quorum to work

Previously it could have been used by setting "consistency=", but this was
an accident.

7 years agolib-master: postlogin: Don't unreference already closed login-connection
Timo Sirainen [Thu, 17 May 2018 15:35:04 +0000 (18:35 +0300)] 
lib-master: postlogin: Don't unreference already closed login-connection

If the login-connection was already closed, this caused too many
unreferences.

Fixes:
Panic: file master-login.c: line 544 (master_login_conn_unref): assertion failed: (conn->clients == NULL)

7 years agosystemd: Indicate where changes should be made
Aki Tuomi [Tue, 24 Apr 2018 08:46:21 +0000 (11:46 +0300)] 
systemd: Indicate where changes should be made

7 years agosystemd: Increase file descriptors by default
Aki Tuomi [Tue, 24 Apr 2018 08:45:36 +0000 (11:45 +0300)] 
systemd: Increase file descriptors by default

7 years agosystemd: Allow writing to home by default
Aki Tuomi [Tue, 24 Apr 2018 08:45:07 +0000 (11:45 +0300)] 
systemd: Allow writing to home by default

7 years agosystemd: Remove NoNewPrivileges and CAP_BOUNDING_SET
Aki Tuomi [Tue, 24 Apr 2018 08:44:33 +0000 (11:44 +0300)] 
systemd: Remove NoNewPrivileges and CAP_BOUNDING_SET

These break sieve by preventing SUID binary as
sendmail_path.

7 years agofs-posix: Strip trailing "/" from filenames
Timo Sirainen [Tue, 15 May 2018 14:50:27 +0000 (17:50 +0300)] 
fs-posix: Strip trailing "/" from filenames

This is mainly because "doveadm fs delete -R" adds it to indicate to the
fs-driver that the whole directory is wanted to be deleted. This change
fixes fs-posix to work with NFS, where otherwise unlink("symlink-to-dir/")
fails with ENOTDIR. Without NFS the same call succeeds.

7 years agodoveadm force-resync: Add -f parameter to fsck index while opening it
Timo Sirainen [Mon, 14 May 2018 18:33:53 +0000 (21:33 +0300)] 
doveadm force-resync: Add -f parameter to fsck index while opening it

This probably should be done by default, but for now keep it optional
just in case there are any bugs in the fsck implementation.

7 years agolib-storage: Add MAILBOX_FLAG_FSCK to fsck index immediately after opening it
Timo Sirainen [Mon, 14 May 2018 18:31:59 +0000 (21:31 +0300)] 
lib-storage: Add MAILBOX_FLAG_FSCK to fsck index immediately after opening it

This can be used to fix a broken index that is causing mailbox_open() to
fail.

7 years agodoveadm: fix who/kick out of order response
Bjørnar Ness [Tue, 17 Apr 2018 14:04:02 +0000 (16:04 +0200)] 
doveadm: fix who/kick out of order response

doveadm-who and kick did not properly flush protocol output
after doveadm_print(), this caused out-of-order response to
clients, example:

C: <tab><tab>who<crlf>
S: +<crlf>
S: username<tab>[...]<missing_crlf>

correct response should have been
S: <username><tab>[...]<crlf>
S: +<crlf>

fixed by adding doveadm_print_flush() calls.

7 years agolib-storage: Return correct root path for PATH_TYPE_ALT_MAILBOX
Josef 'Jeff' Sipek [Fri, 11 May 2018 14:50:16 +0000 (10:50 -0400)] 
lib-storage: Return correct root path for PATH_TYPE_ALT_MAILBOX

mailbox_list_set_get_root_path(..., MAILBOX_LIST_PATH_TYPE_ALT_MAILBOX, ...)
must return one of three values:

1. if there is no alt storage, return NULL
2. if there is alt storage and MAILBOXDIR is set,
return ${alt_dir}/${mailbox_dir_name}
3. if there is alt storage but MAILBOXDIR is not set, return ${alt_dir}

Case number 3 was broken, and it mistakenly returned ${root_dir} - in other
words, it behaved as MAILBOX_LIST_PATH_TYPE_MAILBOX.

This correction changes the behavior, but this shouldn't cause
incompatibilities since:

1. it affects only storages that support alternate storage
2. it affects only configurations that use empty MAILBOXDIR

The only storage that supports alternate storage setting is dbox but dbox
defaults to MAILBOXDIR=mailboxes.  Additionally, it appears to be impossible
to override it to an empty string (setting it to an empty strings causes
dbox to override it with the default - "mailboxes").  Therefore, nobody
should be affected by this change.

7 years agosubmission: Perform variable substitution for the submission_relay_rawlog_dir setting.
Stephan Bosch [Sat, 12 May 2018 11:11:59 +0000 (13:11 +0200)] 
submission: Perform variable substitution for the submission_relay_rawlog_dir setting.

7 years agosubmission: Add support for making server rawlogs using the rawlog_dir setting.
Stephan Bosch [Sat, 12 May 2018 10:20:08 +0000 (12:20 +0200)] 
submission: Add support for making server rawlogs using the rawlog_dir setting.

Similar services like pop3 and imap already support this setting, but for
submission this was omitted.

7 years agosubmission: Substitute variables in settings.
Stephan Bosch [Sat, 12 May 2018 11:33:20 +0000 (13:33 +0200)] 
submission: Substitute variables in settings.

7 years agosubmission: Move assignment of verbose_proctitle.
Stephan Bosch [Mon, 14 May 2018 20:41:29 +0000 (22:41 +0200)] 
submission: Move assignment of verbose_proctitle.

Makes it more consistent with other services like imap.

7 years agolmtp: Fix segfault occurring when a user turns out to be over quota at DATA transfer.
Stephan Bosch [Mon, 14 May 2018 21:56:21 +0000 (23:56 +0200)] 
lmtp: Fix segfault occurring when a user turns out to be over quota at DATA transfer.

The LMTP recipient context was not updated with the final recipient address when
the RCPT command was accepted. This left a dangling struct smtp_address pointer
which triggered the segfault when used.

7 years agofs-posix: Fix fs_iter_next() to return any kinds of files.
Timo Sirainen [Mon, 14 May 2018 12:46:01 +0000 (15:46 +0300)] 
fs-posix: Fix fs_iter_next() to return any kinds of files.

Only regular files and symlinks were returned. It should return everything
else as well (fifos, sockets, devices).

7 years agoconfig: Fix crash in doveconf -n when hiding sensitive information
Aki Tuomi [Wed, 9 May 2018 07:19:02 +0000 (10:19 +0300)] 
config: Fix crash in doveconf -n when hiding sensitive information

Broken by fc02343f

7 years agolib: Add str_append_escaped and use it with str_escape
Aki Tuomi [Wed, 9 May 2018 07:18:39 +0000 (10:18 +0300)] 
lib: Add str_append_escaped and use it with str_escape

7 years agolib-storage: Harden check for imapdir list name
Josef 'Jeff' Sipek [Fri, 11 May 2018 14:53:46 +0000 (10:53 -0400)] 
lib-storage: Harden check for imapdir list name

Comparing char pointers to determine string equality is asking for trouble.
Use strcmp() instead.

7 years agolmtp: proxy: Add support for making proxy client rawlogs using the lmtp_proxy_rawlog_...
Stephan Bosch [Sat, 12 May 2018 10:27:37 +0000 (12:27 +0200)] 
lmtp: proxy: Add support for making proxy client rawlogs using the lmtp_proxy_rawlog_dir setting.

7 years agolmtp: Add support for making server rawlogs using the lmtp_rawlog_dir setting.
Stephan Bosch [Sat, 12 May 2018 10:18:27 +0000 (12:18 +0200)] 
lmtp: Add support for making server rawlogs using the lmtp_rawlog_dir setting.

7 years agolmtp: Properly apply the login_greeting setting.
Stephan Bosch [Sat, 12 May 2018 10:15:07 +0000 (12:15 +0200)] 
lmtp: Properly apply the login_greeting setting.

It got ignored during migration of lmtp service to lib-smtp.

7 years agosubmission: Truly enforce a configurable message size limit (default 40 MB).
Stephan Bosch [Fri, 6 Apr 2018 23:09:12 +0000 (01:09 +0200)] 
submission: Truly enforce a configurable message size limit (default 40 MB).

Before, it was only checking a provided SIZE parameter to the MAIL command and
not the size of the actually submitted message.

7 years agolmtp: Explicitly disable message size limit enforcement.
Stephan Bosch [Fri, 6 Apr 2018 23:08:34 +0000 (01:08 +0200)] 
lmtp: Explicitly disable message size limit enforcement.

7 years agosubmission: Actively enforce message size limit while copying message data.
Stephan Bosch [Fri, 6 Apr 2018 23:08:11 +0000 (01:08 +0200)] 
submission: Actively enforce message size limit while copying message data.

7 years agolmtp: Actively enforce message size limit while copying message data.
Stephan Bosch [Fri, 6 Apr 2018 23:06:13 +0000 (01:06 +0200)] 
lmtp: Actively enforce message size limit while copying message data.

This is actually currently not relevant to LMTP, but for future implementation
this code is added here already.

7 years agolib-smtp: server: Implement enforcement of maximum message size.
Stephan Bosch [Fri, 6 Apr 2018 23:05:15 +0000 (01:05 +0200)] 
lib-smtp: server: Implement enforcement of maximum message size.

7 years agolib-smtp: command parser: Provide more details in command data size limit error.
Stephan Bosch [Fri, 6 Apr 2018 23:03:58 +0000 (01:03 +0200)] 
lib-smtp: command parser: Provide more details in command data size limit error.

7 years agoconfigure: Create a definition for UOFF_T_MAX.
Stephan Bosch [Fri, 6 Apr 2018 23:00:46 +0000 (01:00 +0200)] 
configure: Create a definition for UOFF_T_MAX.

7 years agolib-smtp: server: Fix error message logged for errors occurring in data wrapper strea...
Stephan Bosch [Wed, 4 Apr 2018 22:34:49 +0000 (00:34 +0200)] 
lib-smtp: server: Fix error message logged for errors occurring in data wrapper stream during DATA transfer.

Used the connection stream rather than the data stream to obtain the error.
Obviously, there is no error on the low-level connection when there is a data
istream (e.g. message size) error.

7 years agolib-smtp: server: DATA command: Restore input handling upon failure.
Stephan Bosch [Fri, 11 May 2018 17:26:45 +0000 (19:26 +0200)] 
lib-smtp: server: DATA command: Restore input handling upon failure.

Fixes command hanging upon failure during data transfer.

7 years agoauth: Use PRIuUOFF_t to print process VSZ limit
Josef 'Jeff' Sipek [Fri, 11 May 2018 14:41:01 +0000 (10:41 -0400)] 
auth: Use PRIuUOFF_t to print process VSZ limit

This doesn't change the behavior, but it makes it more obviously correct.

7 years agoauth: Avoid comparison of ints of different signs on FreeBSD
Josef 'Jeff' Sipek [Fri, 11 May 2018 14:38:32 +0000 (10:38 -0400)] 
auth: Avoid comparison of ints of different signs on FreeBSD

For legacy reasons, rlim_t on FreeBSD is defined as int64_t.

7 years agoauth: test - make sure memory gets free'd
Aki Tuomi [Tue, 17 Apr 2018 09:11:05 +0000 (12:11 +0300)] 
auth: test - make sure memory gets free'd

7 years agoauth: Add test for lua password verify
Aki Tuomi [Tue, 17 Apr 2018 07:55:53 +0000 (10:55 +0300)] 
auth: Add test for lua password verify

7 years agoauth: db-lua - Add password_verify to auth request
Aki Tuomi [Thu, 12 Apr 2018 10:39:58 +0000 (13:39 +0300)] 
auth: db-lua - Add password_verify to auth request

Allows verifying passwords with dovecot when necessary

7 years agoauth: db-lua - Expose some auth request members
Aki Tuomi [Wed, 11 Apr 2018 09:39:51 +0000 (12:39 +0300)] 
auth: db-lua - Expose some auth request members

These are particularly useful for finding out if user
has already been authenticated.

7 years agoauth: db-lua - Remove extra space from log_error
Aki Tuomi [Wed, 11 Apr 2018 09:29:41 +0000 (12:29 +0300)] 
auth: db-lua - Remove extra space from log_error

This makes it possible to use the log_error method.

Broken in 9698cd24

7 years agoauth: Improve auth-master connections' error logging
Timo Sirainen [Fri, 4 May 2018 12:27:14 +0000 (15:27 +0300)] 
auth: Improve auth-master connections' error logging

Include connect and handshake times in the error message.

7 years agolib-master: Add auth connect & handshake times to master_login_auth_request errors
Timo Sirainen [Fri, 4 May 2018 11:14:35 +0000 (14:14 +0300)] 
lib-master: Add auth connect & handshake times to master_login_auth_request errors

7 years agolib-master: Add request time also for internal failure error messages
Timo Sirainen [Fri, 4 May 2018 11:10:49 +0000 (14:10 +0300)] 
lib-master: Add request time also for internal failure error messages

7 years agolib-master: Use more exact timestamp in master_login_auth_request failures
Timo Sirainen [Fri, 4 May 2018 11:03:46 +0000 (14:03 +0300)] 
lib-master: Use more exact timestamp in master_login_auth_request failures

7 years agolib-master: Improve error logging for master_auth_connection failures
Timo Sirainen [Fri, 4 May 2018 10:56:45 +0000 (13:56 +0300)] 
lib-master: Improve error logging for master_auth_connection failures

7 years agolib-master: Improve error logging for post-login script failures
Timo Sirainen [Fri, 4 May 2018 10:42:23 +0000 (13:42 +0300)] 
lib-master: Improve error logging for post-login script failures

7 years agolib-master: Improve error logging when master_login_connection gets disconnected
Timo Sirainen [Fri, 4 May 2018 10:23:07 +0000 (13:23 +0300)] 
lib-master: Improve error logging when master_login_connection gets disconnected

7 years agolib-master: Keep linked list of master_login_clients per connection
Timo Sirainen [Fri, 4 May 2018 10:07:50 +0000 (13:07 +0300)] 
lib-master: Keep linked list of master_login_clients per connection

This allows improving logging on connection errors.

7 years agofts: When indexing virtual mailbox, index each real mailbox entirely
Timo Sirainen [Thu, 3 May 2018 15:33:25 +0000 (18:33 +0300)] 
fts: When indexing virtual mailbox, index each real mailbox entirely

Index all the unindexed messages in them at once, instead of jumping between
real mailboxes and indexing them in small pieces.

7 years agofts: Indexing virtual mailbox didn't always index the last mails
Timo Sirainen [Thu, 3 May 2018 15:33:00 +0000 (18:33 +0300)] 
fts: Indexing virtual mailbox didn't always index the last mails

7 years agofts: Make sure indexing virtual mailbox doesn't recurse and index mail multiple times
Timo Sirainen [Thu, 3 May 2018 15:30:51 +0000 (18:30 +0300)] 
fts: Make sure indexing virtual mailbox doesn't recurse and index mail multiple times

7 years agocassandra: Use fallback_consistency on more types of errors
Timo Sirainen [Thu, 3 May 2018 14:06:04 +0000 (17:06 +0300)] 
cassandra: Use fallback_consistency on more types of errors

This could allow for example read_consistency=local-quorum with
read_fallback_consistency=quorum, so most of the time the reads are
from local datacenter, but in case it has problems you can switch to
other datacenters.

7 years agocassandra: Cleanup - Move code to query_error_want_fallback()
Timo Sirainen [Thu, 3 May 2018 13:58:21 +0000 (16:58 +0300)] 
cassandra: Cleanup - Move code to query_error_want_fallback()

This allows extending it more easily.

7 years agofs-posix: mkdir missing directory if it's changed by FS_METADATA_WRITE_FNAME
Timo Sirainen [Thu, 3 May 2018 12:22:09 +0000 (15:22 +0300)] 
fs-posix: mkdir missing directory if it's changed by FS_METADATA_WRITE_FNAME

The temp file is created to the initial directory. If the directory is
changed by FS_METADATA_WRITE_FNAME, the new destination directory didn't
necessarily exist. If the link() or rename() fails with ENOENT, try to
mkdir the missing directories.

7 years agolib-index: mail_index_sync_map() - Don't try to-resync extension updates
Timo Sirainen [Sun, 29 Apr 2018 09:31:23 +0000 (12:31 +0300)] 
lib-index: mail_index_sync_map() - Don't try to-resync extension updates

This was done to call extension record sync handlers, but the previous
commit removes them. Fixes a problem where obsolete cache offsets were
used in some situations:

 - Some cache updates are from external transactions and some are from
non-external transactions. This is because cache offset updates are being
added by whatever the parent index transaction is.

 - When mail_index_sync_map() is mapping MAIL_INDEX_SYNC_HANDLER_FILE, it
has already synced the map. But it's calling mail_index_sync_record()
for non-external transactions to call expunge handlers and extension
update handlers. It's calling the regular mail_index_sync_record() to do
this work.

 - But mail_index_sync_record() is actually still updating the map. So now
mail_index_sync_record() is called for all non-external cache updates,
but not for external cache updates! And since these are somewhat
randomly either external or non-external, the end result is that the
cache offset may be obsolete.

7 years agolib-index: Remove extension record sync handlers
Timo Sirainen [Sun, 29 Apr 2018 09:23:49 +0000 (12:23 +0300)] 
lib-index: Remove extension record sync handlers

This is no longer used by anything, and it makes the fix in the following
commit much easier.

This was originally added in 6a19e109ee8c5a6f688da83a86a7f6abeb71abdd to
allow dovecot.index.cache updating to hook into updating cache offsets to
link cache records together. This was reimplemented in a different way in
131b073bdc3650083b00616dc778dd3017c2bbb5

7 years agolib-http: server: Properly handle corrupt payload while finishing a request.
Stephan Bosch [Tue, 20 Mar 2018 17:14:39 +0000 (18:14 +0100)] 
lib-http: server: Properly handle corrupt payload while finishing a request.

The HTTP_REQUEST_PARSE_ERROR_BROKEN_REQUEST was not handled, causing an
assertion panic. This situation occurred when the chunked transfer encoding was
invalid.

7 years agolib-http: server: Properly handle payload stream errors while finishing a request.
Stephan Bosch [Tue, 20 Mar 2018 17:10:42 +0000 (18:10 +0100)] 
lib-http: server: Properly handle payload stream errors while finishing a request.

Errors from the (chunked) payload stream would cause assertion panics at that point.

7 years agolib-http: server: Allow resubmitting a response, as long as it is not sent yet.
Stephan Bosch [Tue, 20 Mar 2018 17:04:36 +0000 (18:04 +0100)] 
lib-http: server: Allow resubmitting a response, as long as it is not sent yet.

7 years agocassandra: Add proper log levels to logged messages
Timo Sirainen [Thu, 26 Apr 2018 18:07:31 +0000 (21:07 +0300)] 
cassandra: Add proper log levels to logged messages

If logging to "internal handler", i.e. to log process, write the log prefix
that includes the log level. This way Cassandra's trace/debug/info messages
won't end up in error log.

7 years agolib: Add i_failure_handler_is_internal()
Timo Sirainen [Thu, 26 Apr 2018 18:07:22 +0000 (21:07 +0300)] 
lib: Add i_failure_handler_is_internal()

7 years agolib-fs: fs-posix - Add accurate-mtime parameter
Timo Sirainen [Thu, 26 Apr 2018 16:38:55 +0000 (19:38 +0300)] 
lib-fs: fs-posix - Add accurate-mtime parameter

This is mainly useful for testing to find out whether one file was created
after another.

7 years agolib-fs: Update FS_METADATA_WRITE_FNAME comment
Timo Sirainen [Thu, 26 Apr 2018 15:23:54 +0000 (18:23 +0300)] 
lib-fs: Update FS_METADATA_WRITE_FNAME comment

7 years agolib-fs: fs-posix - FS_METADATA_WRITE_FNAME replaces the full path
Timo Sirainen [Thu, 26 Apr 2018 15:14:27 +0000 (18:14 +0300)] 
lib-fs: fs-posix - FS_METADATA_WRITE_FNAME replaces the full path

This is how all the other fs drivers work, although the macro name is a bit
confusing.

7 years agolib-fs: fs-metawrap - Pass FS_METADATA_WRITE_FNAME through to parent fs
Timo Sirainen [Thu, 26 Apr 2018 15:14:46 +0000 (18:14 +0300)] 
lib-fs: fs-metawrap - Pass FS_METADATA_WRITE_FNAME through to parent fs

fs-metawrap in the middle pervented the renaming from working.

7 years agolib-storage: Remove mail_attachment_detection_options=add-flags-on-fetch parsing
Timo Sirainen [Thu, 26 Apr 2018 13:42:40 +0000 (16:42 +0300)] 
lib-storage: Remove mail_attachment_detection_options=add-flags-on-fetch parsing

It wasn't actually used yet.

7 years agolib-storage: Fail if mail_attachment_detection_options has invalid options
Timo Sirainen [Thu, 26 Apr 2018 13:41:55 +0000 (16:41 +0300)] 
lib-storage: Fail if mail_attachment_detection_options has invalid options

7 years agolib-storage: Set $Has[No]Attachment earlier among other cached data
Timo Sirainen [Thu, 19 Apr 2018 13:38:22 +0000 (16:38 +0300)] 
lib-storage: Set $Has[No]Attachment earlier among other cached data

7 years agolib: Fix returning error from unlink_directory()
Timo Sirainen [Thu, 26 Apr 2018 23:39:10 +0000 (02:39 +0300)] 
lib: Fix returning error from unlink_directory()

On non-ENOENT errors it was returning 1 instead of -1.

7 years agolib-storage: Fix event leak when failing to create storage
Timo Sirainen [Thu, 26 Apr 2018 20:05:21 +0000 (23:05 +0300)] 
lib-storage: Fix event leak when failing to create storage

7 years agomdbox: Assume that empty uid maps found during sync are harmless
Josef 'Jeff' Sipek [Mon, 23 Apr 2018 22:15:51 +0000 (18:15 -0400)] 
mdbox: Assume that empty uid maps found during sync are harmless

Instead of failing the sync and causing index rebuild, just skip over
the empty uid maps.  Chances are that they these records came from
various plugins that create fake mails.

7 years agoman: Document doveadm mailbox cache commands
Aki Tuomi [Wed, 25 Apr 2018 07:56:04 +0000 (10:56 +0300)] 
man: Document doveadm mailbox cache commands

7 years agoplugins/old-stats: Remove restrict_access_set_dumpable calls from process_io_open().
Sergey Kitov [Thu, 26 Apr 2018 06:48:39 +0000 (09:48 +0300)] 
plugins/old-stats: Remove restrict_access_set_dumpable calls from process_io_open().

proc_io_fd is opened in preinit(), while process have root access, so
restrict_access_set_dumpable() calls are not needed.

7 years ago.gitignore: Ignore doc/man/doveadm-rebuild.1
Martti Rannanjärvi [Thu, 26 Apr 2018 10:18:01 +0000 (13:18 +0300)] 
.gitignore: Ignore doc/man/doveadm-rebuild.1

7 years agoglobal - migrate more complicated strncmp expressions to str_begins
Phil Carmody [Thu, 11 Jan 2018 13:35:42 +0000 (15:35 +0200)] 
global - migrate more complicated strncmp expressions to str_begins

Simplify a bunch of verbose var=strlen(); strncmp(,,var) calls.
Fortunately, all of these examples use the length variable, so no
"unused value" warnings occur.

--- 8< --- strncmp2.cocci ---
@@
expression e1, e2;
identifier i2;
@@

  i2 = strlen(e2)
  ...
- strncmp(e1, e2, i2) == 0
+ str_begins(e1, e2)

@@
expression e1, e2;
identifier i2;
@@

  i2 = strlen(e2)
  ...
- strncmp(e1, e2, i2) != 0
+ !str_begins(e1, e2)

@@
expression e1, e2;
identifier i1;
@@

  i1 = strlen(e1)
  ...
- strncmp(e1, e2, i1) == 0
+ str_begins(e2, e1)

@@
expression e1, e2;
identifier i1;
@@

  i1 = strlen(e1)
  ...
- strncmp(e1, e2, i1) != 0
+ !str_begins(e2, e1)

--- 8< ---------------------

Signed-off-by: Phil Carmody <phil@dovecot.fi>
7 years agoglobal - migrate from strncmp to str_begins
Phil Carmody [Thu, 11 Jan 2018 13:20:09 +0000 (15:20 +0200)] 
global - migrate from strncmp to str_begins

Simplify a bunch of verbose strncmp(,,strlen()) calls.

--- 8< --- strncmp.cocci ---
@@
expression e1, e2;
@@

- strncmp(e1, e2, strlen(e2)) == 0
+ str_begins(e1, e2)

@@
expression e1, e2;
@@

- strncmp(e1, e2, strlen(e2)) != 0
+ !str_begins(e1, e2)

@@
expression e1, e2;
@@

- strncmp(e1, e2, strlen(e1)) == 0
+ str_begins(e2, e1)

@@
expression e1, e2;
@@

- strncmp(e1, e2, strlen(e1)) != 0
+ !str_begins(e2, e1)

--- 8< ---------------------

Signed-off-by: Phil Carmody <phil@dovecot.fi>
7 years agoglobal - migrate strncmp literals to str_begins
Phil Carmody [Thu, 11 Jan 2018 13:03:36 +0000 (15:03 +0200)] 
global - migrate strncmp literals to str_begins

Simplify a bunch of strncmp(,,number) calls.

git ls-files \*.[ch] | xargs perl -p -i -e 's/strncmp\((.*?), ?(\".*?\"), ?(\d+)\) == 0/str_begins($1, $2)/g'
git ls-files \*.[ch] | xargs perl -p -i -e 's/strncmp\((.*?), ?(\".*?\"), ?(\d+)\) != 0/!str_begins($1, $2)/g'

I ran a longer script to verify that all of the string literals and
the length matched. They didn't:

$ git grep strncmp | perl -ne 'print if(m/strncmp\([^,]*,\s*"(.*?)",\s*(\d+)/ and ($s=$1,$t=$2,$s=~s/\\[tn]/#/g,length($s)) != $t)'
src/auth/db-oauth2.c:               if (strncmp(field, "oauth2:", 8) == 0 &&

With the new functions, that kind of typo is impossible.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
7 years agolib: strfuncs - string match length and prefix checking helpers
Phil Carmody [Thu, 2 Feb 2017 12:27:58 +0000 (14:27 +0200)] 
lib: strfuncs - string match length and prefix checking helpers

strncmp(input, "literal", 7) is an idiom used everywhere, but leaves
room for human error in calculating the length.

strncmp(input, "literal", strlen("literal")) is an idiom also used
everywhere, but is both verbose and might be inefficient on some
legacy or ultralightweight compilers.

The old techniques are presumed to be optimal code-wise, but are
verbose (and, containing redundancy, they leave room for human error),
so make the macro fall back onto this operation, simply avoiding the
redundancy/verbosity.

The macro expansion does not multiply evaluate any of its parameters,
so should be safe even in the strangest of situations.

Signed-off-by: Phil Carmody <phil@dovecot.fi>
7 years agolib: uni_utf8_get_valid_data() - Add ATTR_WARN_UNUSED_RESULT
Timo Sirainen [Wed, 25 Apr 2018 12:23:35 +0000 (15:23 +0300)] 
lib: uni_utf8_get_valid_data() - Add ATTR_WARN_UNUSED_RESULT

Ignoring the return value most likely leads to buggy code, so make sure it's
checked.

7 years agolib-storage: Don't ignore uni_utf8_get_valid_data() return value
Timo Sirainen [Wed, 25 Apr 2018 12:22:37 +0000 (15:22 +0300)] 
lib-storage: Don't ignore uni_utf8_get_valid_data() return value

It's not supposed to happen, so call i_unreached()

7 years agolib-fts: Minor fix to randomness test in test-fts-tokenizer
Timo Sirainen [Wed, 25 Apr 2018 12:20:58 +0000 (15:20 +0300)] 
lib-fts: Minor fix to randomness test in test-fts-tokenizer

If the random input was entirely valid UTF-8, the input was truncated to
empty.

7 years agofts: Fix indexing input that contains NULs
Timo Sirainen [Wed, 25 Apr 2018 12:17:53 +0000 (15:17 +0300)] 
fts: Fix indexing input that contains NULs

Any message_block that contained NULs, but otherwise was valid UTF-8, was
simply dropped.

7 years agolast-login: Remove superfluous semicolon
Michael Slusarz [Mon, 16 Apr 2018 16:38:21 +0000 (10:38 -0600)] 
last-login: Remove superfluous semicolon

7 years agolast-login: Username is already output as part of log prefix
Michael Slusarz [Mon, 16 Apr 2018 16:37:32 +0000 (10:37 -0600)] 
last-login: Username is already output as part of log prefix

7 years agolib-http: test-http-client - Only load existing CAs
Aki Tuomi [Wed, 28 Mar 2018 06:11:55 +0000 (09:11 +0300)] 
lib-http: test-http-client - Only load existing CAs

Otherwise the SSL tests do not properly work.

Fixes Error: HTTP Request failed: Couldn't initialize SSL context: Can't load CA certs from directory /etc/ssl/certs: error:02001002:system library:fopen:No such file or directory: fopen('/etc/pki/tls/cert.pem','r'), error:2006D080:BIO routines:BIO_new_file:no such file, error:0B084002:x509 certificate routines:X509_load_cert_crl_file:system lib

7 years agolib-http: test-http-client - Test against missing SAN name
Aki Tuomi [Tue, 27 Mar 2018 07:31:53 +0000 (10:31 +0300)] 
lib-http: test-http-client - Test against missing SAN name

Add test to make sure http client validates and ignores
missing subjectAltName in cert, when not validating names.

7 years agolib-ssl-iostream: Do not skip cert name check if invalid cert is allowed
Aki Tuomi [Tue, 27 Mar 2018 07:20:54 +0000 (10:20 +0300)] 
lib-ssl-iostream: Do not skip cert name check if invalid cert is allowed

Caller should be responsible for ignoring this error, not us.
All the locations calling here are dealing this correctly.

7 years agolib-ssl-iostream: Fix missing altName handling in openssl_cert_match_name
Aki Tuomi [Tue, 27 Mar 2018 07:29:49 +0000 (10:29 +0300)] 
lib-ssl-iostream: Fix missing altName handling in openssl_cert_match_name

If name is not found in subjectAltNames, report it as error.

Fixes Panic: file iostream-openssl-common.c: line 177 (openssl_cert_match_name): assertion failed: (*reason_r != NULL)

7 years agolib-mail: Remove MESSAGE_HEADER_REPLACE_NULS_WITH_0x80 flag
Timo Sirainen [Wed, 25 Apr 2018 11:19:27 +0000 (14:19 +0300)] 
lib-mail: Remove MESSAGE_HEADER_REPLACE_NULS_WITH_0x80 flag

As mentioned in previous commit, 0x80 isn't valid UTF-8 and we shouldn't
encourage using it. This implementation also can't be easily changed to
use unicode replacement character without larger changes to istream-nonuls.

Reverts 95fba2c295bb84639dc64ca5c9f2ccb9edc00ba7.

7 years agolib-mail: Change NUL -> 0x80 replacement to use unicode replacement char instead
Timo Sirainen [Wed, 25 Apr 2018 11:17:34 +0000 (14:17 +0300)] 
lib-mail: Change NUL -> 0x80 replacement to use unicode replacement char instead

Using 0x80 produces invalid UTF-8 output, which we should avoid. Some places
in Dovecot code already requires that input is valid UTF-8, so it's also
safer and easier to use the unicode replacement character.

Fixes: Panic: file fts-tokenizer-generic.c: line 210 (fts_tokenizer_generic_simple_next): assertion failed: (char_size > 0)
7 years agolib-mail: Change rfc822_parser_context.nul_replacement_char to string
Timo Sirainen [Wed, 25 Apr 2018 11:11:43 +0000 (14:11 +0300)] 
lib-mail: Change rfc822_parser_context.nul_replacement_char to string

7 years agolib: Call module's preinit function, when loading
Sergey Kitov [Wed, 18 Apr 2018 10:30:50 +0000 (13:30 +0300)] 
lib: Call module's preinit function, when loading

7 years agoplugins/old-stats: Add old-stats preinit() which opens mail stats io.
Sergey Kitov [Fri, 9 Mar 2018 13:17:29 +0000 (15:17 +0200)] 
plugins/old-stats: Add old-stats preinit() which opens mail stats io.

7 years agodoveadm: Add rebuild attachments command
Aki Tuomi [Thu, 12 Apr 2018 11:09:10 +0000 (14:09 +0300)] 
doveadm: Add rebuild attachments command

Goes thru given mails and resets the attachment indicator.

7 years agolib-storage: Parse mail parts in mail_set_attachment_keywords if not present
Aki Tuomi [Thu, 12 Apr 2018 11:07:54 +0000 (14:07 +0300)] 
lib-storage: Parse mail parts in mail_set_attachment_keywords if not present

7 years agolib-storage: Add error reporting to mail_set_attachment_keywords
Aki Tuomi [Thu, 19 Apr 2018 07:19:15 +0000 (10:19 +0300)] 
lib-storage: Add error reporting to mail_set_attachment_keywords

7 years agodoveadm: mailbox cache decisions - Fatally fail if fields are missing
Aki Tuomi [Wed, 25 Apr 2018 08:04:08 +0000 (11:04 +0300)] 
doveadm: mailbox cache decisions - Fatally fail if fields are missing

7 years agodoveadm stats dump: Add stddev field
Timo Sirainen [Tue, 24 Apr 2018 14:22:00 +0000 (17:22 +0300)] 
doveadm stats dump: Add stddev field

Include it in default output as well.

7 years agodoveadm stats dump: Add -f <fields> parameter
Timo Sirainen [Tue, 24 Apr 2018 13:29:49 +0000 (16:29 +0300)] 
doveadm stats dump: Add -f <fields> parameter

This allows specifying which fields are wanted to be dumped.

7 years agostats: Support dumping any given percentile
Timo Sirainen [Tue, 24 Apr 2018 14:32:21 +0000 (17:32 +0300)] 
stats: Support dumping any given percentile