Timo Sirainen [Wed, 24 Jul 2019 12:05:27 +0000 (15:05 +0300)]
imap: Allow SET/GETMETADATA to access validated attributes with imap_metadata=no
Some IMAP extensions use these commands to set/get their internal state.
This should be allowed even if full METADATA isn't enabled.
The initial plan was to restrict this in the lib-imap-storage layer, so it
would apply to everything using the imap-metadata API. This would have
affected for example accessing metadata in Sieve scripts, which could be
either good or bad. It might not be wanted to give users read access to
some metadata either, but admins really should be given the ability to
write Sieve scripts that access the metadata. However there's just no good
way to differentiate between admin-written (or tool-written) Sieve script
and user-written Sieve script.
Another issue is using metadata to configure virtual mailboxes. Currently
they're all admin-written and should be allowed to access metadata, but in
the future we might want to allow user-written virtual mailbox rules as
well.
So the end result at least for now is to just prevent IMAP GETMETADATA and
SETMETADATA specifically from accessing the non-validated attributes. Most
of the time there aren't any secrets in the metadata. In case there is,
users need to be prevented from accessing metadata via Sieve, and in such
systems users rarely have direct Sieve access anyway.
Timo Sirainen [Wed, 24 Jul 2019 11:42:21 +0000 (14:42 +0300)]
lib-storage: Add support for "validated attributes"
If an attribute is marked with MAIL_ATTRIBUTE_INTERNAL_FLAG_VALIDATED, it's
assumed to be "validated". This means that it has a set() callback that
validates the value, which at minimum means that its size isn't excessively
large.
MAIL_ATTRIBUTE_TYPE_FLAG_VALIDATED can be used with set/get/iterate to allow
access only to these validated attributes. Trying to access non-validated
attributes will result in error.
Shaun A. Johnson [Mon, 13 Aug 2018 23:43:04 +0000 (16:43 -0700)]
lib: Changed chown to chmod for Linux NFS Flush
This change switches the chown call to a chmod call in the function
nfs_flush_chown_uid because the chown call was resulting in certain
permission bits being dropped when the nfs attributes were flushed.
Functionality for FreeBSD/Solaris was left unchanged.
Shaun A. Johnson [Mon, 13 Aug 2018 23:35:54 +0000 (16:35 -0700)]
lib: Split up logic in nfs_flush_chown_uid
This splits up the logic of nfs_flush_chown_uid() so that there is an
individual chown call for each platform instead of a single call that is
compiled for both platforms.
This is the first step to adjusting how nfs attributes are flushed on
Linux because of an issue with chown resetting permissions on the files.
As a example for an simple tcp health check the health-check.sh script
is added. It closes the connection after 10 seconds and only answer to
"PING\n" with a "PONG\n". It is installed by default next to the script
executable.
Markus Valentin [Wed, 19 Jun 2019 12:36:12 +0000 (14:36 +0200)]
script: add a parameter -p for passthrough scripts
Adding the passthrough option to script, this allows to configure a
script to be straightly called from a socket connection, without
implementing any specific protocol.
Markus Valentin [Thu, 13 Jun 2019 18:54:39 +0000 (20:54 +0200)]
lmtp-proxy: set real_ variables in auth_user_info struct
Set the real_ variables from connection to the client struct and from
there to the auth_user_info. This allows to pass the real_ variables to
lib-auth and thereby to the auth process.
Markus Valentin [Thu, 13 Jun 2019 18:45:55 +0000 (20:45 +0200)]
lib-auth: add real_[remote|local]_[ip|port] to auth_user_info
This allows the auth_user_info_export function to export all the real_
variables, if available, to the auth request thereby enableing real_
variables for lib-auth.
stats: event export - Increase default http-post timeout to 250ms
50ms just isn't enough. A slightly higher latency link combined with a
handful of storage I/Os can easily use up 50ms.
If each event has approximately 4kB memory footprint, then a 250ms timeout
keeps the memory requirement relatively low (50MB on average / 200MB max at
50k events/sec) but still allows a decent amount of time for the HTTP POST
to get sent to and processed by a server in the same datacenter.
If header with the same key already exists, just replace the value.
HTTP supports having multiple headers with the same key only when they
can be rewritten into a single comma-separated header. So practically
there's no reason for lib-http to need to support adding multiple
headers. Replacing an existing value is more useful generally.
Timo Sirainen [Fri, 18 May 2018 14:29:09 +0000 (17:29 +0300)]
lib: Linux, OSX, etc: Avoid race conditions showing \xAB chars in ps title
With bad luck "ps" reads the process title when it hasn't been fully
written. Since the trailing NULs are written last and the previous code kept
the ps title otherwise filled with \xAB chars, this could have caused ps
to sometimes show the process title filled with \xAB chars (visible as '?')
Timo Sirainen [Fri, 17 May 2019 07:33:53 +0000 (10:33 +0300)]
lib-imap: Make sure str_unescape() won't be writing past allocated memory
The previous commit should already prevent this, but this makes sure it
can't become broken in the future either. It makes the performance a tiny
bit worse, but that's not practically noticeable.
Timo Sirainen [Fri, 10 May 2019 16:24:51 +0000 (19:24 +0300)]
lib-imap: Don't accept strings with NULs
IMAP doesn't allow NULs except in binary literals. We'll still allow them
in regular literals as well, but just not in strings.
This fixes a bug with unescaping a string with NULs: str_unescape() could
have been called for memory that points outside the allocated string,
causing heap corruption. This could cause crashes or theoretically even
result in remote code execution exploit.
Stephan Bosch [Mon, 15 Jul 2019 19:50:11 +0000 (21:50 +0200)]
lib-smtp: smtp-params - Assume all capabilities are supported when adding parameter event fields.
The actual capabilities are not really needed, since any assigned field is
relevent for event processing, whether the remote end will accept it or not.
This also fixes an assert failure occuring for proxied connections. Since the
server and client (proxy) connections can have different capabilities and since
the client connection does not have a proper capability list available in the
beginning of the handshake, the event created for a client transaction would
cause an assert failure when parameters were assigned that did not match the
capabilities (none).
Timo Sirainen [Fri, 12 Jul 2019 07:16:26 +0000 (10:16 +0300)]
config: Fix memory leaks when failing to convert ssl-parameters.dat
If ssl_dh setting isn't set and ssl-parameters.dat isn't found or there's
some error reading it, memory is leaked for every config request. This
eventually results in config process dying due to reaching vsz_limit.