1
From: Jaldhar H. Vyas <jaldhar@debian.org>
2
Date: Tue, 02 Oct 2012 22:49:18 -0400
3
Subject: Backport of fix for failure to autocreate mailboxes
4
Description: Allows creation of index directory even when it can't be chgrp'ed
5
which in turn permits mailboxes to be autocreated. See also:
6
default-mail_location.patch which is also needed to fix bug #623440
8
This patch is an amalgamation of the following HG changesets:
11
# User Timo Sirainen <tss@iki.fi>
12
# Date 1349209450 -10800
13
# Node ID 3ce50c0bb782e0989e807f32831d6823f6be64cf
14
# Parent e29b627219b3b5d51aecdfbbecd75bb6332bb105
15
lib-storage: When index mkdir() fails with EPERM, create the dir anyway with 0700 mode.
16
This avoids failing entirely when /var/mail/user has 0660 permissions and we
17
don't have access to the group. The error message is still logged.
19
Origin: http://hg.dovecot.org/dovecot-2.1
21
src/lib-storage/mailbox-list.c | 9 ++++++++-
22
1 file changed, 8 insertions(+), 1 deletion(-)
24
diff --git a/src/lib-storage/mailbox-list.c b/src/lib-storage/mailbox-list.c
25
index c65e70b..9bab19e 100644
26
--- a/src/lib-storage/mailbox-list.c
27
+++ b/src/lib-storage/mailbox-list.c
28
@@ -1406,7 +1406,14 @@ int mailbox_list_create_missing_index_dir(struct mailbox_list *list,
29
if (errno != ENOENT || p == NULL || ++n == 2) {
30
mailbox_list_set_critical(list,
31
"mkdir(%s) failed: %m", index_dir);
33
+ if (p == NULL || errno != EPERM ||
34
+ perm.dir_create_mode == 0700)
36
+ /* we can't use the GID. allow it anyway with more
37
+ restricted permissions. */
38
+ perm.file_create_gid = (gid_t)-1;
39
+ perm.dir_create_mode = 0700;
42
/* create the parent directory first */
43
parent_dir = t_strdup_until(index_dir, p);