[dovecot-cvs] dovecot/src/lib-index/maildir maildir-index.c,1.36,1.37 maildir-index.h,1.25,1.26 maildir-sync.c,1.62,1.63 maildir-update-flags.c,1.9,1.10

cras at procontrol.fi cras at procontrol.fi
Mon Oct 20 10:01:11 EEST 2003


Update of /home/cvs/dovecot/src/lib-index/maildir
In directory danu:/tmp/cvs-serv29749/lib-index/maildir

Modified Files:
	maildir-index.c maildir-index.h maildir-sync.c 
	maildir-update-flags.c 
Log Message:
If maildir contains dovecot-shared file Dovecot does two things differently:
it allows some flags to be private and stored only in index file (currently
hardcoded to \Seen flag only) and new mails are created with dovecot-shared
file's mode & 0666. So if you set filesystem permissions correctly, you
should have fully functioning shared mailboxes.



Index: maildir-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/maildir/maildir-index.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- maildir-index.c	24 Aug 2003 00:50:22 -0000	1.36
+++ maildir-index.c	20 Oct 2003 06:01:08 -0000	1.37
@@ -131,7 +131,7 @@
 	}
 }
 
-int maildir_create_tmp(struct mail_index *index, const char *dir,
+int maildir_create_tmp(struct mail_index *index, const char *dir, mode_t mode,
 		       const char **fname)
 {
 	const char *path, *tmp_fname;
@@ -149,7 +149,9 @@
 		path = p_strconcat(pool, dir, "/", tmp_fname, NULL);
 		if (stat(path, &st) < 0 && errno == ENOENT) {
 			/* doesn't exist */
-			fd = open(path, O_WRONLY | O_CREAT | O_EXCL, 0600);
+			mode_t old_mask = umask(0);
+			fd = open(path, O_WRONLY | O_CREAT | O_EXCL, mode);
+			umask(old_mask);
 			if (fd != -1 || errno != EEXIST)
 				break;
 		}

Index: maildir-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/maildir/maildir-index.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- maildir-index.h	10 Aug 2003 23:56:23 -0000	1.25
+++ maildir-index.h	20 Oct 2003 06:01:08 -0000	1.26
@@ -19,7 +19,7 @@
 
 /* Return new filename base to save into tmp/ */
 const char *maildir_generate_tmp_filename(const struct timeval *tv);
-int maildir_create_tmp(struct mail_index *index, const char *dir,
+int maildir_create_tmp(struct mail_index *index, const char *dir, mode_t mode,
 		       const char **path);
 
 const char *maildir_get_location(struct mail_index *index,

Index: maildir-sync.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/maildir/maildir-sync.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- maildir-sync.c	24 Aug 2003 06:31:35 -0000	1.62
+++ maildir-sync.c	20 Oct 2003 06:01:08 -0000	1.63
@@ -289,6 +289,9 @@
 		return TRUE;
 
 	flags = maildir_filename_get_flags(new_fname, rec->msg_flags);
+	flags &= ~ctx->index->private_flags_mask;
+	flags |= rec->msg_flags & ctx->index->private_flags_mask;
+
 	if (flags != rec->msg_flags) {
 		if (!ctx->index->update_flags(ctx->index, rec,
 					      seq, MODIFY_REPLACE, flags, TRUE))

Index: maildir-update-flags.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/maildir/maildir-update-flags.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- maildir-update-flags.c	11 Aug 2003 01:56:37 -0000	1.9
+++ maildir-update-flags.c	20 Oct 2003 06:01:08 -0000	1.10
@@ -116,7 +116,8 @@
 		new_flags = old_flags & ~ctx->flags;
 		break;
 	case MODIFY_REPLACE:
-		new_flags = ctx->flags;
+		new_flags = ctx->flags |
+			(old_flags & index->private_flags_mask);
 		break;
 	default:
 		new_flags = 0;
@@ -128,14 +129,20 @@
 						    fname+1 : path, new_flags);
 
 	if (old_flags == new_flags) {
-		/* it's what we wanted. verify that the file exists. */
+		/* it's what we wanted. verify that the file exists, but
+		   only if something actually could have changed
+		   (ie. do nothing with private flag changes in shared
+		   mailboxes). */
 		struct stat st;
 
-		if (stat(path, &st) < 0) {
-			if (errno == ENOENT)
-				return 0;
-			index_file_set_syscall_error(index, path, "stat()");
-			return -1;
+		if (ctx->flags != 0) {
+			if (stat(path, &st) < 0) {
+				if (errno == ENOENT)
+					return 0;
+				index_file_set_syscall_error(index, path,
+							     "stat()");
+				return -1;
+			}
 		}
 		ctx->found = TRUE;
 		return 1;
@@ -193,7 +200,7 @@
 
 	memset(&ctx, 0, sizeof(ctx));
 	ctx.modify_type = modify_type;
-	ctx.flags = flags;
+	ctx.flags = flags & ~index->private_flags_mask;
 
 	t_push();
 	if (!maildir_file_do(index, rec, do_rename, &ctx)) {



More information about the dovecot-cvs mailing list