Skip to content

Commit efd67bd

Browse files
committed
mailserver: fix muchsync permissions with POSIX ACLs
- Enable posixacl on zroot ZFS pool for /var/vmail - Set POSIX ACL default granting lass rwX on mail dir (new files inherit) - Fix /var/vmail permissions after dovecot pre-start resets to 0700 - Fix dovecot-acl-sync to skip cur/new/tmp/.notmuch subdirs - Change recursive tmpfiles rule to non-recursive to avoid setgid on files
1 parent 0a97a97 commit efd67bd

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

2configs/mailserver.nix

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ in
6969
stateVersion = 3;
7070
};
7171

72+
# dovecot pre-start creates /var/vmail with 0700; widen for lass (virtualMail group)
73+
# POSIX ACL default ensures new files inherit lass access (needed for muchsync hardlinks)
74+
systemd.services.dovecot.serviceConfig.ExecStartPost = [
75+
"+${pkgs.coreutils}/bin/chmod 2770 /var/vmail"
76+
"+${pkgs.acl}/bin/setfacl -R -m u:lass:rwX /var/vmail/lassul.us/lass/mail"
77+
"+${pkgs.acl}/bin/setfacl -R -d -m u:lass:rwX /var/vmail/lassul.us/lass/mail"
78+
];
79+
7280
# Password generation for mail accounts
7381
clan.core.vars.generators.mailserver-lass = {
7482
files."lass-mail-password" = { };
@@ -137,10 +145,9 @@ in
137145
users.groups.virtualMail.members = [ "lass" ];
138146
systemd.tmpfiles.rules = [
139147
"L+ /home/lass/Maildir - - - - /var/vmail/lassul.us/lass/mail"
140-
# dovecot pre-start sets /var/vmail to 02770 already; just fix subdirs
141148
"z /var/vmail/lassul.us 2770 virtualMail virtualMail -"
142149
"z /var/vmail/lassul.us/lass 2770 virtualMail virtualMail -"
143-
"Z /var/vmail/lassul.us/lass/mail 2770 virtualMail virtualMail -"
150+
"d /var/vmail/lassul.us/lass/mail 2770 virtualMail virtualMail -"
144151
];
145152

146153
# Thunderbird autoconfig
@@ -226,7 +233,12 @@ in
226233
# l=lookup, r=read, w=write-flags, s=write-seen (no insert/delete/expunge)
227234
script = ''
228235
acl_line="user=bot@lassul.us lrws"
229-
find /var/vmail/lassul.us/lass/mail -type d | while IFS= read -r dir; do
236+
# Only write ACL in mailbox root dirs, skip cur/new/tmp/notmuch subdirs
237+
find /var/vmail/lassul.us/lass/mail -type d \
238+
-not -name cur -not -name new -not -name tmp \
239+
-not -path '*/.notmuch/*' -not -name .notmuch \
240+
-not -path '*/fts-flatcurve/*' -not -name fts-flatcurve \
241+
| while IFS= read -r dir; do
230242
acl_file="$dir/dovecot-acl"
231243
if [ ! -f "$acl_file" ] || [ "$(cat "$acl_file")" != "$acl_line" ]; then
232244
echo "$acl_line" > "$acl_file"

machines/neoprism/disk.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
mode = "mirror";
7171
mountpoint = "/";
7272
rootFsOptions = {
73+
acltype = "posixacl";
74+
xattr = "sa";
7375
};
7476
datasets = {
7577
reserved = {

0 commit comments

Comments
 (0)