Commit Graph

1089 Commits

Author SHA1 Message Date
Oswald Buddenhagen
ff04e2ae09 add support for single-quoting to our printf implementation
this is for escaping shell commands, which we'll make use of in a
moment.
2025-03-25 18:03:19 +01:00
Oswald Buddenhagen
3f84075715 add unit test for our printf implementation 2025-03-25 18:03:19 +01:00
Oswald Buddenhagen
85d82465c7 make imap_msgs test actually return non-zero on failure 2025-03-25 18:03:19 +01:00
Oswald Buddenhagen
fbcdaf78bd fix conditional on undefined value on some config syntax errors
if the first token on a line was an unterminated escape/quote, we'd
branch based on an uninitialized 'comment' variable.

amends 725a122e.
2025-03-19 15:30:59 +01:00
Oswald Buddenhagen
281a9ba465 prefix deprecation notices with file name
so it's (even) more obvious that these refer to the configuration,
rather than being some internal sloppiness.
2025-03-11 12:44:22 +01:00
Oswald Buddenhagen
61f0810bb1 fix -ls hanging after synchronous error
we need to make a note that we're already done with the Store, as
otherwise we'll wait for a callback that never comes.
2025-01-28 10:30:47 +01:00
Oswald Buddenhagen
1e0b661d09 fix --dry-run without --debug-driver
the stubbing is implemented by the proxy driver, so we need to hook it
in in that case as well. the driver is already prepared for that, as
it's also used to implement -Ta/-TA.
2025-01-28 00:49:17 +01:00
Oswald Buddenhagen
15c7e02e4a accept zero-sized messages from IMAP
while such a thing is rather pointless, completely empty messages are
not forbidden. consequently, we should be able to deal with them, and
above all not crash.
2024-11-25 10:46:44 +01:00
Oswald Buddenhagen
a1be7e9a36 make summary more concise
the verbose summary was actually hard to read due to the numbers getting
lost between the words.

i considered highlighting the numbers using ansi escapes, but the
irregular structure would be still hard to parse, and the escapes would
be unsuitable for log files.

also considered was clustering the numbers at the beginnings of the
lines, but that would result in a messy sentence structure.

a proper tabular format would introduce a lot more spacing, and would be
a lot harder to implement for little tangible benefit.

i tried just using the progress counter format, but with plain numbers
instead of the "x/y", but it looked kinda stupid.

so instead use a slightly expanded, semi-tabular version of that, as
suggested by Akshay Hegde on the list. this format bears a risk of
exceeding 80 columns, and in log files the internal spacing looks kinda
out of place, but these should be minor issues in practice.

amends a1a3313e.

REF: <ZzwSfSZN-lNNK55D@akshay.is>
2024-11-24 11:22:34 +01:00
Oswald Buddenhagen
1e7a75095b fix crash when resuming message propagation with MaxMessages
the problem is triggered by the source-side message disappearing
after a transaction to propagate it was started and then interrupted.

it seems tempting to centralize the null-check, but some of the other
branches are taken in situations where the relevant messages from the
source store have not been requested.

no autotest, as our test suite does not support injecting changes before
resuming.

amends 0089f49.
2024-11-24 11:22:34 +01:00
Oswald Buddenhagen
5f953c5162 fix omissions in making expiration target side configurable
amends 8566283c.
2024-11-24 11:22:34 +01:00
Oswald Buddenhagen
bf34d9fd29 do not let both-sided uidvalidity change deter us
the algorithm is symmetrical, comparing the msgids that belong to the
paired uids. so it doesn't matter for recovering one side if the other
side's uidvalidity also changed. it does however impact our ability to
say on which side the change was genuine.

the pointless limitation was presumably a vestige from an earlier
iteration.

amends 77acc26 and 594e60b.
2024-11-24 11:22:34 +01:00
Ludovico Gerardi
3c4b5f1c83 remove stray closing brace from man page
amends 5d5e07eb.
2024-09-29 14:48:01 +02:00
Oswald Buddenhagen
8c781d4fb5 fix implicit listing of Maildir INBOX under Path
commit acd6b4b0 ("simplify/fix recursive maildir listing") argued that
listing INBOX when it is encountered while listing Path would be
unnecessary, as the caller would list it separately anyway if requested.
however, it is actually documented that Patterns will implicitly match
INBOX nested into Path. so revert that commit.

REFMAIL: 20240818002409.4c918eb4@inari
2024-08-21 12:35:01 +02:00
Oswald Buddenhagen
17c9cc1140 improve reporting of failure to open previously present mailbox
tell explicitly that the box cannot be opened _any more_, so it's clear
that Delete, rather than Create, would apply.

fwiw, it would be preferable to actually differentiate between absent
mailboxes and ones that fail to open for other reasons. but
unfortunately, IMAP doesn't report the difference (gmail has a
non-standard [NONEXISTENT] response code, though).
2024-08-21 12:28:19 +02:00
Oswald Buddenhagen
dd27850e54 fix typos
most found using https://github.com/crate-ci/typos .
2024-08-19 12:33:41 +02:00
Oswald Buddenhagen
76e5f223ee add missing trailing newlines in error() calls 2024-08-06 17:16:09 +02:00
Oswald Buddenhagen
d54c22d20e fix IMAP INBOX case normalization
while is_INBOX() was adjusted to work with not null-terminated strings,
is_inbox() wasn't.

amends 3aead33.
2024-08-06 17:16:09 +02:00
Oswald Buddenhagen
4279aea6a0 generalize AUTHORS section of man page 2024-08-02 12:27:54 +02:00
Oswald Buddenhagen
6fbbcbb2c7 substitute version and date in man pages
this shortens the release checklist and reduces commit churn.

for the date we use configure's timestamp. this should reflect the
package's creation time and be consistent with the version.
2024-08-02 12:27:54 +02:00
Oswald Buddenhagen
ee832951e2 revamp automatic enumeration of power-of-two enumerators
i found a neat trick to do it with the C pre-processor after all.
this makes the enum definitions themselves arguably somewhat less
legible, but on the upside the build system becomes simpler, and IDEs
can build/update their code models without having to (re-)build the
project first.

somewhat as a side effect, this gives bit enums proper names, so we
don't need to refer to them by cryptic prefixes anymore.

amends 6a78e2c5f.
2024-07-31 21:23:58 +02:00
Oswald Buddenhagen
31c504d432 remove redundant argument from BIT_FORMATTER_PROTO()
it doesn't need to know the enum prefix.

amends 17db5de0c & 950ebe833.
2024-07-31 21:23:58 +02:00
Oswald Buddenhagen
43271d8fad eliminate commit_cmds driver callback
no driver implements it, and this isn't likely to change any time soon.
2024-07-31 21:23:58 +02:00
Oswald Buddenhagen
8b8313997c Revert "actually implement imap_commit_cmds()"
the CHECK command doesn't do what i thought; the formulation in the
specs was ambiguous - it really checks for new mail, rather than
committing, and each operation is supposed to be atomic. inefficient,
but safe. IMAP4rev2 eliminates the command altogether, subsuming its
function under NOOP.

consequently, the commit callback doesn't make sense for imap.
in principle, we could use it to coalesce multiple STOREs to counter the
inefficiency, but that won't happen any time soon, and the
implementation would look rather differently anyway.

as a "side effect", this fixes an assertion failure in imap_close_box()
when all flag sets failed (e.g., b/c the box was read-only), as their
callbacks would be short-cut in front of the completion of the CHECK
command, which was not sequenced before the close_box() call.

This reverts commit cfaa4848dd.
2024-07-31 21:23:58 +02:00
Oswald Buddenhagen
84194a7a9f don't try to create already existing boxes
if the SELECT command fails even though the box was LISTed, then the
error cause is obviously not that box is absent, and so we should not
attempt to CREATE it.
2024-07-31 21:23:58 +02:00
Oswald Buddenhagen
ceb0fa9803 don't try to qsort() NULL array
while this actually works due to the array size being zero, it's
undefined behavior which makes gcc eliminate a subsequent null check in
the calling function.
2024-07-31 21:23:58 +02:00
Oswald Buddenhagen
12e30ce560 cap readsz at buffer size
otherwise we may get negative comparison sizes, which the unsigned
arithmetic we use cannot represent. this would prevent buffer content
downshifting, resulting in prepare_read() erroring out.

amends 859b7dd.

REFMAIL: 87h740x2xe.fsf@wavexx.thregr.org
REFMAIL: ec0f6f2a-0151-46ad-865a-a6f77ad8e204@app.fastmail.com
REFMAIL: 87edk45p9o.fsf@b3l.xyz
REFMAIL: CYAWIDDGRHT7.2CH3R3D6Z3F97@ferdinandy.com
2024-07-31 18:38:15 +02:00
Oswald Buddenhagen
e70c300f74 permit leading whitespace in INTERNALDATE strings
the BNF specifies "(SP DIGIT) / 2DIGIT" for the date-day-fixed symbol,
but "*SP 1*DIGIT" matches that closely enough for parsing purposes.

REFMAIL: CYYDEEVZ8CCT.2M1T7XKT45HH8@jonas.vautherin.ch
2024-02-07 11:40:04 +01:00
Oswald Buddenhagen
65cd4429bb document defaults of referenced XDG env vars
so users don't have to google the spec.
2022-07-09 08:28:45 +02:00
Oswald Buddenhagen
ec50c55c36 make DNS lookup asynchronous
true asynchronicity is actually fairly useless, as it's unlikely that
both Stores in a Channel use IMAP, and both host resolutions take
particularly long - the main objective is imposing the Timeout setting.
however, we can't just use setjmp()+alarm(), as longjmp()ing out of
getaddrinfo() is undefined, as it may for example free() just at the
wrong time. so we go for the real thing.

this implementation just fork()s out a process which uses getaddrinfo()
(or gethostbyname()) per lookup. this isn't particularly scalable, but
as we don't expect a lot of lookups, it seems adequate.
2022-07-04 18:28:30 +02:00
Oswald Buddenhagen
ced20ad0d9 fix Tunnel leaving behind zombies
this generally went unnoticed, as the tunnel usually terminates right
before we exit anyway. however, if multiple Channels are synced, it may
become visible.

this is a "shotgun" implementation, where the main loop just reaps all
unclaimed children.
arguably, it would be cleaner if each socket actually tracked its own
process, but getting synchronous kills+waits right is tricky, so we
continue to pretend that there is no process as far as the socket layer
is concerned.

poll()/select() are not restartable, so they need EINTR handling now
that SIGCHLD is actually delivered.
2022-07-04 18:28:30 +02:00
Oswald Buddenhagen
b841374827 fix broken Tunnel potentially causing SIGPIPE
we need to ignore the signal, so the regular error handling can kick in.
2022-07-04 18:28:30 +02:00
Oswald Buddenhagen
b9a4746b54 don't refresh progress counters pointlessly
the mainloop-based refresh timer keeps spinning even if there is no
update. overload stats_steps to signal whether a refresh is needed.

amends 8fbc4323.
2022-07-04 18:28:30 +02:00
Oswald Buddenhagen
460bfbb8ac abort channel sync when a store is fubar
this got lost in d5a5da947.

this also simplifies a nested condition, where the logic has previously
been, but isn't applicable any more.

REFMAIL: 87fsjloz05.fsf@wavexx.thregr.org
2022-07-01 15:13:10 +02:00
Oswald Buddenhagen
92faccc639 improve wording of --ext-exit docu 2022-07-01 14:57:39 +02:00
Oswald Buddenhagen
f6ccf9c4f5 fix lineup of --ext-exit in help output 2022-07-01 14:57:39 +02:00
Oswald Buddenhagen
c9e57161cc autotest: add missing next in cmptrash()
this doesn't really matter, as the branches are mutually exclusive
anyway, but still.

amends 01329bdf.
2022-06-20 17:33:03 +02:00
Oswald Buddenhagen
7619705428 whitespace fixes
consistently surround '|' with spaces.
2022-06-19 16:12:55 +02:00
Oswald Buddenhagen
090ba0caa3 drop unused 'flags' parameter of maildir_list_{recurse,inbox,path}()
amends 416ced25.
2022-06-19 16:12:55 +02:00
Oswald Buddenhagen
46584e5358 add support for Maildir Paths with suffixes
that is, Path not ending with a slash.

pedantically, this is a bugfix, as the manual already suggested that
this is possible (and at least one user got the hint, though he was
disappointed).

the IMAP driver already supports this.
2022-06-19 16:12:55 +02:00
Oswald Buddenhagen
3bfc3c5063 forbid nesting maildir Path under Inbox again
it was never documented, and i can't really think of a case where
someone would actually want it, as the MUA side of things would be just
weird. additionally, the case of Path being Inbox+'/' did not work
anyway. will reconsider and fix the latter case if someone complains.

reverts 98bd2b11.
2022-06-19 16:12:55 +02:00
Oswald Buddenhagen
acd6b4b0b8 simplify/fix recursive maildir listing
there is no need to call maildir_list_{path,inbox}() from
maildir_list_recurse(), as maildir_list_store() will do that anyway -
if it's actually requested, that is. this means that this removes the
implicit listing when Inbox is nested into Path, or vice versa. this is
actually correct, as the Patterns matching would throw away the non-
requested boxes anyway.
2022-06-19 16:12:55 +02:00
Oswald Buddenhagen
32d500ed15 simplify maildir recursion limitation
the isDir argument is effectively already a depth counter, so we don't
need a separate one for that.

amends 79797826.
2022-06-19 16:12:55 +02:00
Oswald Buddenhagen
52c063fd45 add support for UTF-7 mailbox names
this finally makes us compliant with IMAP4rev1. how fitting that the
meanwhile released IMAP4rev2 demoted UTF-7 to legacy status ...

based on a patch by Georgy Kibardin <georgy@kibardin.name>.
2022-06-19 16:12:55 +02:00
Oswald Buddenhagen
efab63fb8e enable UTF-8 on servers with RFC6855 support
note that this is a somewhat sloppy implementation, as it simply
assumes that the local system uses UTF-8 - that seems reasonable
nowadays.
2022-06-19 16:12:55 +02:00
Oswald Buddenhagen
9169ee8fd8 assume Tunnel to be secure more consistently
follows up on 27458133.
2022-06-19 16:12:55 +02:00
Oswald Buddenhagen
8ba4192b23 autotest conversion of even more malformed messages
this follows up on 87065c12.
2022-06-19 16:12:55 +02:00
Oswald Buddenhagen
bfcc2d7d19 default to CRLF output in copy_msg_convert()
if we have nothing to go on, assume canonical line endings.
2022-06-19 16:12:55 +02:00
Oswald Buddenhagen
6dc9312dbc recognize options even if the build does not support them
there were several cases of confused users who failed to notice that
they built without OpenSSL and wondered what is wrong with their
config.
2022-06-19 16:12:55 +02:00
Oswald Buddenhagen
faec30abf4 rename SSLType => TLSType
for consistency with TLSVersions.
the variable names are unchanged to avoid churn.
2022-06-19 16:12:55 +02:00