Dovecot 2.1 new imap folder permissions

dovecotimappermissions

I am migrating an old
mail (postfix/dovecot) server to a new one. Everything works much as
expected. I have a small obstacle though.

I use mbox format and the setup is pretty much simple.

Suppose a user's home directory is the following:

~$ ls -ld /home/foo                                                                  
drwxr-xr-x 3 foo    users 4096 Oct  4 13:28 foo

and the respective /var/mail:

~$ ls -ld /var/mail/foo                                                            
-rw------- 1 foo mail 0 Oct  4 23:45 /var/mail/foo

In the old server when the user tried to create a new test imap folder
(from an imap client), then the newly created file would be:

~$ ls -l /home/foo/                                                                
-rw------- 1 foo users  0 Oct  2  02:08 test

This is the desired behavior.

In the new dovecot 2.1 server the following file permissions will apply:

~$ ls -l /home/foo/                                                                    
-rw-r--r-- 1 foo users  0 Oct  2  02:08 test

I finally noticed that if I chmod the /home/foo to 711, then the new
file will have the desired (600) permissions. So, I can make a umask
for the new users (login.defs), but that doesn't sound a pretty solution, because users have ssh access to their homes and they can change the permissions back to 755.

Do you have anything else to suggest in order to have the desired permissions for a newly created imap folder? If you need any .conf file, let
me know.

Thanks in advance!

Best Answer

The Dovecot wiki described how it handles SharedMailboxes and Permissions. You may be able to tune your configuration to get the permissions you want. It appears on initial creation the user's Maildir should have 700 as its permissions. Permissions depend on how the path is specified.

Initial directory creation is always group writable, but after that permissions aren't altered. New files and folders in the mailbox get their permissions from the containing mailbox. Files are created without the executable bit. There are reasons for allowing group write. Dovecot tries to use sensible defaults.

There are examples that include a umask definition in the configuration, but I my copy of the Dovecot documentation indicates the option was removed.