Permissions & Attributes /var/vmail recursively with dovecot

Discussion in 'Tips/Tricks/Mods' started by Loveless, Apr 11, 2017.

  1. Loveless

    Loveless Member

    Just wanted to post this little script here, it's very useful if you're migrating users' Maildirs into an ISPConfig system under /var/vmail,
    it also adds the Junk folder subscription if it wasn't already there.
    chown vmail:vmail /var/vmail/ -R
    cd /var/vmail
    find . -type d -name Maildir -exec chmod 700 -R {} \;
    find . -type f \( -name '.sieve' -o -name '.sieve.svbin' \) -exec chmod 644 {} \;
    find . -type f \( -name 'dovecot-uidlist' -o -name 'dovecot-uidvalidity' -o -name 'dovecot.index*' -o -name 'maildirsize'  \) -exec chmod 600 {} \;
    find . -type f \( -name 'dovecot-uidvalidity.*'  \) -exec chmod 444 {} \;
    find . -type f \( -name 'subscriptions' \) -exec chmod 744 {} \;
    find . -type f \( -name 'subscriptions' \) -exec sh -c 'echo "Junk" >> "$1"' -- {} \;
    exit 0
    Save it as and run it.
    Last edited: Apr 18, 2017
    ahrasis, Th0m, snowweb and 1 other person like this.
  2. esmiz

    esmiz Member

    Thanks mate!!
    Just swapped servers and also changed to dovecot from courier.
    Thunderbird could not delete or rename folders, saying something like 'cannot renaming not supported across conflicting directory permissions'.
    Your script fixed it. :)
    I noticed before maildir permissions were drwxrws--- and now drwx--S---
    Is this what dovecot expect to be the maldir? Should I remove the setid setgid bit?
    Best regards, and thanks again!!!!
  3. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Thanks, saw this error when running dsync for a migrated mailbox: "sync: mailbox_rename failed: Renaming not supported across conflicting directory permissions". Needed to fix permissions and this script did it perfectly.
    ahrasis likes this.

Share This Page