[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-storage.c, 1.89, 1.90

cras at dovecot.org cras at dovecot.org
Sun Jan 30 10:41:17 EET 2005


Update of /var/lib/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv13068/lib-storage/index/maildir

Modified Files:
	maildir-storage.c 
Log Message:
If maildir-shared exists in the Maildir root, copy it for each created
mailbox.



Index: maildir-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- maildir-storage.c	29 Dec 2004 19:10:27 -0000	1.89
+++ maildir-storage.c	30 Jan 2005 08:41:15 -0000	1.90
@@ -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;
 }
 



More information about the dovecot-cvs mailing list