Timo Sirainen [Mon, 24 Oct 2016 19:22:28 +0000 (22:22 +0300)]
director: Fix sending up/down state in handshakes.
They were never sent, because HOSTs were sent before director had waited for
the remote to send its version number. So sender thought that the remote's
minor_version was too old and it didn't send the up/down state at all.
This caused errors like:
Warning: director(10.0.0.30:9090/left): Host 10.0.0.30 is being updated before previous update had finished (up -> down) - setting to state=down vhosts=100
Error: director(10.0.0.30:9090/left): Director 10.0.0.30 SYNC request hosts don't match us - resending hosts (seq=6, remote hosts_hash=262126213, my hosts_hash=2458934259)
Timo Sirainen [Mon, 24 Oct 2016 17:16:57 +0000 (20:16 +0300)]
director: Make sure IP address parsing works in DIRECTOR-ADD/REMOVE
We were passing the entire string through to net_addr2ip(). It seems that
inet_aton() stops at whitespace though, so this wasn't actually causing
errors at least on Linux.
Aki Tuomi [Tue, 25 Oct 2016 07:29:50 +0000 (10:29 +0300)]
imap-login: Skip NIL value in ID handler
NIL value can cause hard crash, depending what
the key is. For x-proxy-ttl, NIL will crash
on any system, x-originating-ip will crash on
some nss versions (e.g. centos 6.7).
Migitating factor here is that the NIL value is only
accepted from trusted network.
Timo Sirainen [Mon, 24 Oct 2016 10:08:47 +0000 (13:08 +0300)]
lib-http: Add ioloop and lock wait information to timeout messages.
It'll now log for example:
9007 Request timed out (Request sent 7.087 secs ago, 0.076 in other ioloops, 7.012 in locks, connected 7.087 secs ago)
Which points out that the problem wasn't really with the HTTP, but with
locking. This likely should be fixed in some way also in lib-http so that
it gives a bit of extra time for reading the request, but that's a separate
fix.
Timo Sirainen [Mon, 24 Oct 2016 09:17:44 +0000 (12:17 +0300)]
dict-client: Fix logging how much time was spent in other ioloops in slow lookup warnings.
The warning's idea is to show why the lookup could have been slow. We
differentiate between time spent in dict_wait() waiting only for the
dict result and time spent in other ioloops waiting for potentially other
things as well (and time spent waiting for locks during this time).
The previous code didn't work right when multiple ioloops were used, which
happened sometimes.
Also changed %u to %d just in case some calculation is wrong. It's nicer to
get a slightly negative value rather than a huge positive one.
Aki Tuomi [Thu, 13 Oct 2016 13:11:48 +0000 (16:11 +0300)]
director: Support flush socket
This allows specifying an URI to execute
on user kill. It can be of form
exec:/path/to/bin, unix:/path/to/socket or
tcp:ip:port
The location is sent FLUSH username-hash
per killed user. You can execute some
action there, and you are expected to
return '+\nOK\n' as reply once you are
done.
Timo Sirainen [Mon, 8 Aug 2016 10:12:15 +0000 (13:12 +0300)]
Moved cc-wrapper.sh handling to dovecot.m4
When configuring Dovecot --without-shared-libs and pointing external plugins
to uninstalled sources --with-dovecot, any binaries complied for plugins
weren't using cc-wrapper.sh, which could have caused runtime failures when
they attempted to load plugins dynamically. Now it's possible to add
DC_CC_WRAPPER to plugins' configure.ac to build with the cc-wrapper.sh.
Timo Sirainen [Thu, 20 Oct 2016 07:11:53 +0000 (10:11 +0300)]
login proxy: Hanging outgoing SSL connections caused using already-freed memory
This mainly happened when login proxy closed the connection due to connect
timeout. The ssl-proxy still had a reference and existed for a longer time.
If SSL handshake still succeeded afterwards, it now called
login_proxy_ssl_handshaked(), which accessed the already-freed proxy and
likely crashed.
Fixed the ssl-client proxy code specifically. Alternatively ssl_proxy_free()
could be calling ssl_proxy_destroy() always, but since ssl-server side of
the code seems to have been working fine, I don't want to accidentally
break it.
Aki Tuomi [Wed, 19 Oct 2016 15:44:35 +0000 (18:44 +0300)]
lib: Add drop_setuid_root for restrict_access
drop_setuid_root, when set to true, will detect
and try to drop getuid()==0. This is done by
recovering current effective UID to set->uid
if set->uid == -1, and then doing seteuid(0).
It will also drop out any other extra privileges,
such as extra groups not requested for.
lib-storage: clean up mailbox_list_create to improve readability
There is no reason to use mailbox_list_driver_find() here instead of
mailbox_list_find_class() as (1) we do not need the index into the list
driver array, and (2) dealing with double-pointers is harder than regular
pointers.
Test that you can encrypt a key with password, encrypt a key with the
password protected key, change the password, and still load a key that you
encrypted with the key encrypted using the first password.
1) Only the first Content-Type header is used. (Simpler than using the last.)
2) Invalid Content-Types are parsed as far as we can. This is mainly to make
sure they aren't treated as missing Content-Types, which could cause them to
become text/plain.
file->metadata_changed doesn't need to change in that situation. It's used
by fs-metawrap to find out if it needs to rewrite metadata during a write,
but internal metadata isn't written to its header.