ReviewOS

also looking at this

mail-os/mail

Harden encrypted mail storage, recovery, and forwarding

#8
Merged chris wants to merge codex/mail-storage-hardening into main
50 files +1701 -9001
docs/MAILDIR.mdadded+45-0
Changes to docs/MAILDIR.md
@@ -0,0 +1,45 @@
1# Maildir++ storage
2
3Production mailboxes use Maildir++:
4
5```text
6mail/<mailbox>/
7├── tmp/
8├── new/
9├── cur/
10├── .Junk/
11│ ├── tmp/
12│ ├── new/
13│ └── cur/
14└── Junk -> .Junk/cur
15```
16
17The dot-prefixed directory is the standard Maildir++ representation. The
18visible relative symlink is a compatibility bridge for older server paths and
19is included in IMAP LIST responses. New IMAP folders are created in this form.
20DELETE and RENAME update the canonical directory and compatibility link
21together.
22
23Migrate an existing server with the reusable Buddy operation:
24
25```bash
26buddy mail:storage:maildir:migrate
27```
28
29The migration stops `mail.service`, creates missing `tmp/new/cur` directories,
30moves existing flat-folder messages to `.Folder/cur`, installs relative
31compatibility symlinks, and restarts the service. It is idempotent and refuses
32unexpected symlink targets, filename collisions, and nested legacy folders.
33
34Direct server invocation:
35
36```bash
37/usr/local/sbin/maildir-migrate status
38/usr/local/sbin/maildir-migrate migrate
39```
40
41Backups archive one copy of each folder rather than dereferencing both the
42canonical directory and its compatibility link.
43
44Implementation follow-up is tracked in
45[mail-os/mail#5](https://github.com/mail-os/mail/issues/5).