[Dovecot] Problem with incorrect permissions with shared folders
Hi,
I'm seeing strange permissions when using an email client to create a new sub folder in a shared folder.
This is dovecot-1.0test61
I have a directory /data/mail/shared owner=root group=shared permissions=2770 I have a file /data/mail/shared/dovecot-shared owner=root group-shared permissions=2660
User fred in in group shared (in /etc/group)
My understanding is that now in my client I can create a folder called test and so I should have
Folder /data/mail/shared/.test owner=fred group-shared permissions=2770
What I actually get is
Folder /data/mail/shared/.test owner=fred group-shared permissions=2700
So dovecot doesn't appear to be honouring the permissions on dovecot-shared when creating folders.
Also, when creating a folder in a shared folder should the create process automatically copy the dovecot-shared file down to the new folder to allow this to be shared as well?
Thanks
Daveh
On 24.1.2005, at 14:30, Dave Hatton wrote:
So dovecot doesn't appear to be honouring the permissions on dovecot-shared when creating folders.
Right. It was supposed to be used only for mails within a mailbox.
Also, when creating a folder in a shared folder should the create process automatically copy the dovecot-shared file down to the new folder to allow this to be shared as well?
I guess: Index: lib-storage/index/maildir/maildir-storage.c =================================================================== RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.c,v retrieving revision 1.89 diff -u -r1.89 maildir-storage.c --- lib-storage/index/maildir/maildir-storage.c 29 Dec 2004 19:10:27 -0000 1.89 +++ lib-storage/index/maildir/maildir-storage.c 30 Jan 2005 08:39:14 -0000 @@ -482,12 +482,36 @@ } } +static int maildir_create_shared(struct mail_storage *storage, + const char *path, mode_t mode, gid_t gid) +{ + mode_t old_mask = umask(0); + int fd; + + fd = open(path, O_WRONLY | O_CREAT, mode); + umask(old_mask); + + if (fd == -1) { + mail_storage_set_critical(storage, + "open(%s) failed: %m", path); + return -1; + } + + if (fchown(fd, (uid_t)-1, gid) < 0) { + mail_storage_set_critical(storage, + "fchown(%s) failed: %m", path); + } + (void)close(fd); + return 0; +} + static int maildir_mailbox_create(struct mail_storage *_storage, const char *name, int directory __attr_unused__) { struct index_storage *storage = (struct index_storage *)_storage; - const char *path; + struct stat st; + const char *path, *shared_path; mail_storage_clear_error(_storage); @@ -505,6 +529,15 @@ return -1; } + /* if dovecot-shared exists in the root dir, copy it to the + created mailbox */ + shared_path = t_strconcat(storage->dir, "/dovecot-shared", NULL); + if (stat(shared_path, &st) == 0) { + path = t_strconcat(path, "/dovecot-shared", NULL); + (void)maildir_create_shared(_storage, path, + st.st_mode & 0666, st.st_gid); + } + return 0; }
Hi Timo,
The patch is working fine for creating the dovecot-shared file ... but when creating a shared folder the group permissions are still not set on the folder or on the cur, new, tmp directories below.
I'm confused because mkdir_verify calls mkdir_parents with a CREATE_MODE of 0770 ... am I looking in the wrong place?
Any thoughts?
Thanks
Daveh
The patch is working fine for creating the dovecot-shared file ... but when creating a shared folder the group permissions are still not set on the folder or on the cur, new, tmp directories below.
Please ignore this ... I needed to adjust the umask parameter in dovecot.conf -> umask = 0007 Now seems to be working really well
Daveh
participants (2)
-
Dave Hatton
-
Timo Sirainen