0

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!

  • What is the umask for the dovecot process? This is the usually way to control default permissions on created files. – BillThor Oct 12 '14 at 17:53
  • 1
    dovecot creates several processes. So, I did strace when creating a new ("test") file and I notice that before the process calls open() with O_CREAT, it calls umask(0) = 077. So, the previous umask value of dovecot is 077 and it sets it to zero. After the open() syscall, the dovecot sets umask to 077 again (umask(077) = 0). – user248713 Oct 12 '14 at 23:13
0

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.

  • Yes, I have read that wiki, but didn't help me. Maybe I am missing something. As I said, in our use case the users have ssh access to their homes, so they can chmod the /home/foo . Also, because of ssh, the use case includes the manual (not by dovecot process) creation of the new user's home dir. So, I can change the permissions of this directory right from the start, but then he/she can ssh and change it back. As for umask in Dovecot, I think too that in version 2, it has been removed. – user248713 Oct 13 '14 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.