libinterimap: use directories relative to $HOME for the XDG defaults.
Previously getpwuid() was called to determine the user's home directory,
while the XDG specification explicitely mentions $HOME.
Conveniently our docs always mentioned ~/, which on POSIX-compliant
systems expands to the value of the variable HOME (and the result is
unspecified when the variable is unset). Cf. Shell and Utilities volume
of POSIX.1-2017, sec. 2.6.1:
Guilhem Moulin [Mon, 3 Jun 2019 01:50:12 +0000 (03:50 +0200)]
long-lived tests: sleep between 1ms and 999ms.
`shuf -n1 -i1-99` produces a number between 1 and 99, hence `sleep
"0.$(shuf -n1 -i1-99)"` pauses for some time between 100ms and 990ms.
Moreover it's not uniformly distributed as multiples of 100ms (0.100,
0.200, …, 0.900) have twice the probability of other numbers.
Guilhem Moulin [Tue, 28 May 2019 14:46:41 +0000 (16:46 +0200)]
tests/run: use the current date as Message-ID in `sample_message`.
A random 128-bit UUID obtained from /proc/sys/kernel/random/uuid works
too but is Linux-specific and requires the proc(5) pseudo-filesystem to
be mounted at /proc.
Guilhem Moulin [Tue, 21 May 2019 12:12:26 +0000 (14:12 +0200)]
New option 'list-reference' to specify a reference name.
This is useful for synchronizing multiple remote servers against
different namespaces belonging to the same local IMAP server (using a
different InterIMAP instance for each local namespace ↔ remote
synchronization, for instance with the newy provided systemd template
unit file).
Guilhem Moulin [Sat, 25 May 2019 13:27:59 +0000 (15:27 +0200)]
libinterimap: use socketpair(2) in tunnel mode.
Rather than two pipe(2). Also, use SOCK_CLOEXEC to save a fcntl() call
when setting the close-on-exec flag on the socket (even though Perl will
likely call fcntl() anyway).
Guilhem Moulin [Wed, 22 May 2019 19:36:21 +0000 (21:36 +0200)]
interimap: fix handling of mod-sequence values greater or equal than 2 << 63.
SQLite processes every INTEGER values as a 8-byte signed integer, so we
need to manually do the conversion from/to uint64_t client-side if we
don't want to overflow or receive floats.
We could also do the same trick for local/remote UIDs, UIDVALITY and
UIDNEXT values to slim the database down at the expense of pre/post-
processing. (Values of SQLite's INTEGER class are 1, 2, 3, 4, 6, or 8
bytes signed integers depending on the manitudes, so we could save some
space for values ≥2³¹.) But that seems a little overkill.
Guilhem Moulin [Wed, 15 May 2019 03:06:07 +0000 (05:06 +0200)]
interimap: avoid caching hierarchy delimiters forever in the database.
Following recommendation from
https://www.imapwiki.org/ClientImplementation/MailboxList#Hierarchy_separators
Instead, use null characters internally, and substitute them with the
local and remote hierarchy delimiters (which thus no longer need to
match) for IMAP commands. This require a database schema upgrade to
alter the mailbox name column type from TEXT to BLOB. We're using
SQLite's user_version PRAGMA to keep track of schema version; beware
that `.dump` doesn't export its value!
In logging messages, local and remote mailbox names are shown as is
(with their respective delimiters) while database mailbox names are
shown by replacing null characters with the *local* hierarchy delimiter.
Moreover for mailbox names specified on the command line or the
configuration file (with the "list-mailbox" option) the *local*
hierarchy delimiter should be used.
Guilhem Moulin [Wed, 15 May 2019 23:13:31 +0000 (01:13 +0200)]
interimap: fail when two non-INBOX LIST replies return different separators.
This never happens for a single LIST command, but may happen if
mailboxes from different namespaces are being listed. The workaround
here is to run a new interimap instance for each namespace.
Guilhem Moulin [Mon, 21 Jan 2019 22:59:55 +0000 (23:59 +0100)]
Net::IMAP::InterIMAP: add support for TLSv1.3 (on recent enough Net::SSLeay).
Also, change "SSL_protocols" default value from "!SSLv2 !SSLv3" to
"!SSLv2 !SSLv3 !TLSv1 !TLSv1.1". I.e., only enable TLSv1.2 and later,
which is the default in Debian's OpenSSL as of 1.1.1-2, cf.
https://tracker.debian.org/news/998835/accepted-openssl-111-2-source-into-unstable/ .