[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-keywords.c, 1.13, 1.14 maildir-storage.c, 1.145, 1.146 maildir-storage.h, 1.61, 1.62 maildir-uidlist.c, 1.57, 1.58 maildir-util.c, 1.20, 1.21
tss at dovecot.org
tss at dovecot.org
Thu Jan 18 17:20:52 UTC 2007
- Previous message: [dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-keywords.c, 1.6.2.5, 1.6.2.6 maildir-storage.c, 1.115.2.20, 1.115.2.21 maildir-storage.h, 1.49.2.5, 1.49.2.6 maildir-uidlist.c, 1.51.2.4, 1.51.2.5 maildir-util.c, 1.14.2.3, 1.14.2.4
- Next message: [dovecot-cvs] dovecot-sieve configure.in,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv23087
Modified Files:
maildir-keywords.c maildir-storage.c maildir-storage.h
maildir-uidlist.c maildir-util.c
Log Message:
Saved mails and dovecot-keywords file didn't set the group from
dovecot-shared file.
Index: maildir-keywords.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-keywords.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- maildir-keywords.c 28 Dec 2006 23:19:54 -0000 1.13
+++ maildir-keywords.c 18 Jan 2007 17:20:49 -0000 1.14
@@ -254,13 +254,62 @@
return idx >= count ? NULL : keywords[idx];
}
-static int maildir_keywords_commit(struct maildir_keywords *mk)
+static int maildir_keywords_write_fd(struct maildir_keywords *mk,
+ const char *path, int fd)
{
- struct dotlock *dotlock;
- const char *lock_path, *const *keywords;
+ struct maildir_mailbox *mbox = mk->mbox;
+ const char *const *keywords;
unsigned int i, count;
- struct utimbuf ut;
string_t *str;
+ struct stat st;
+
+ str = t_str_new(256);
+ keywords = array_get(&mk->list, &count);
+ for (i = 0; i < count; i++) {
+ if (keywords[i] != NULL)
+ str_printfa(str, "%u %s\n", i, keywords[i]);
+ }
+ if (write_full(fd, str_data(str), str_len(str)) < 0) {
+ mail_storage_set_critical(STORAGE(mbox->storage),
+ "write_full(%s) failed: %m", path);
+ return -1;
+ }
+
+ if (fstat(fd, &st) < 0) {
+ mail_storage_set_critical(STORAGE(mbox->storage),
+ "fstat(%s) failed: %m", path);
+ return -1;
+ }
+
+ if (st.st_gid != mbox->mail_create_gid &&
+ mbox->mail_create_gid != (gid_t)-1) {
+ if (fchown(fd, (uid_t)-1, mbox->mail_create_gid) < 0) {
+ mail_storage_set_critical(STORAGE(mbox->storage),
+ "fchown(%s) failed: %m", path);
+ }
+ }
+
+ /* mtime must grow every time */
+ if (st.st_mtime <= mk->synced_mtime) {
+ struct utimbuf ut;
+
+ mk->synced_mtime = ioloop_time <= mk->synced_mtime ?
+ mk->synced_mtime + 1 : ioloop_time;
+ ut.actime = ioloop_time;
+ ut.modtime = mk->synced_mtime;
+ if (utime(path, &ut) < 0) {
+ mail_storage_set_critical(STORAGE(mbox->storage),
+ "utime(%s) failed: %m", path);
+ return -1;
+ }
+ }
+ return 0;
+}
+
+static int maildir_keywords_commit(struct maildir_keywords *mk)
+{
+ struct dotlock *dotlock;
+ const char *lock_path;
mode_t old_mask;
int fd;
@@ -272,7 +321,6 @@
/* we could just create the temp file directly, but doing it this
ways avoids potential problems with overwriting contents in
malicious symlinks */
- t_push();
lock_path = t_strconcat(mk->path, ".lock", NULL);
(void)unlink(lock_path);
old_mask = umask(0777 & ~mk->mbox->mail_create_mode);
@@ -282,44 +330,21 @@
if (fd == -1) {
mail_storage_set_critical(STORAGE(mk->mbox->storage),
"file_dotlock_open(%s) failed: %m", mk->path);
- t_pop();
return -1;
}
- str = t_str_new(256);
- keywords = array_get(&mk->list, &count);
- for (i = 0; i < count; i++) {
- if (keywords[i] != NULL)
- str_printfa(str, "%u %s\n", i, keywords[i]);
- }
- if (write_full(fd, str_data(str), str_len(str)) < 0) {
- mail_storage_set_critical(STORAGE(mk->mbox->storage),
- "write_full(%s) failed: %m", mk->path);
- (void)file_dotlock_delete(&dotlock);
- t_pop();
- return -1;
- }
-
- /* mtime must grow every time */
- mk->synced_mtime = ioloop_time <= mk->synced_mtime ?
- mk->synced_mtime + 1 : ioloop_time;
- ut.actime = ioloop_time;
- ut.modtime = mk->synced_mtime;
- if (utime(lock_path, &ut) < 0) {
- mail_storage_set_critical(STORAGE(mk->mbox->storage),
- "utime(%s) failed: %m", lock_path);
+ if (maildir_keywords_write_fd(mk, lock_path, fd) < 0) {
+ file_dotlock_delete(&dotlock);
return -1;
}
if (file_dotlock_replace(&dotlock, 0) < 0) {
mail_storage_set_critical(STORAGE(mk->mbox->storage),
"file_dotlock_replace(%s) failed: %m", mk->path);
- t_pop();
return -1;
}
mk->changed = FALSE;
- t_pop();
return 0;
}
@@ -339,7 +364,10 @@
void maildir_keywords_sync_deinit(struct maildir_keywords_sync_ctx *ctx)
{
- maildir_keywords_commit(ctx->mk);
+ t_push();
+ (void)maildir_keywords_commit(ctx->mk);
+ t_pop();
+
array_free(&ctx->idx_to_chr);
i_free(ctx);
}
Index: maildir-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.c,v
retrieving revision 1.145
retrieving revision 1.146
diff -u -d -r1.145 -r1.146
--- maildir-storage.c 18 Jan 2007 14:34:44 -0000 1.145
+++ maildir-storage.c 18 Jan 2007 17:20:49 -0000 1.146
@@ -432,10 +432,12 @@
mbox->uidlist = maildir_uidlist_init(mbox);
mbox->keywords = maildir_keywords_init(mbox);
- if (!shared)
+ if (!shared) {
mbox->mail_create_mode = 0600;
- else {
+ mbox->mail_create_gid = (gid_t)-1;
+ } else {
mbox->mail_create_mode = st.st_mode & 0666;
+ mbox->mail_create_gid = st.st_gid;
mbox->private_flags_mask = MAIL_SEEN;
}
Index: maildir-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.h,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -d -r1.61 -r1.62
--- maildir-storage.h 16 Jan 2007 16:59:06 -0000 1.61
+++ maildir-storage.h 18 Jan 2007 17:20:49 -0000 1.62
@@ -77,7 +77,8 @@
time_t dirty_cur_time;
enum maildir_dirty_flags last_dirty_flags;
- mode_t mail_create_mode;
+ mode_t mail_create_mode;
+ gid_t mail_create_gid;
unsigned int private_flags_mask;
unsigned int syncing_commit:1;
Index: maildir-uidlist.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-uidlist.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- maildir-uidlist.c 28 Dec 2006 23:21:06 -0000 1.57
+++ maildir-uidlist.c 18 Jan 2007 17:20:49 -0000 1.58
@@ -82,6 +82,7 @@
static int maildir_uidlist_lock_timeout(struct maildir_uidlist *uidlist,
bool nonblock)
{
+ struct maildir_mailbox *mbox = uidlist->mbox;
const char *path;
mode_t old_mask;
int fd;
@@ -91,26 +92,32 @@
return 1;
}
- path = t_strconcat(uidlist->mbox->control_dir,
- "/" MAILDIR_UIDLIST_NAME, NULL);
- old_mask = umask(0777 & ~uidlist->mbox->mail_create_mode);
+ path = t_strconcat(mbox->control_dir, "/" MAILDIR_UIDLIST_NAME, NULL);
+ old_mask = umask(0777 & ~mbox->mail_create_mode);
fd = file_dotlock_open(&uidlist->dotlock_settings, path,
nonblock ? DOTLOCK_CREATE_FLAG_NONBLOCK : 0,
&uidlist->dotlock);
umask(old_mask);
if (fd == -1) {
if (errno == EAGAIN) {
- mail_storage_set_error(STORAGE(uidlist->mbox->storage),
+ mail_storage_set_error(STORAGE(mbox->storage),
"Timeout while waiting for lock");
- STORAGE(uidlist->mbox->storage)->temporary_error = TRUE;
+ STORAGE(mbox->storage)->temporary_error = TRUE;
return 0;
}
- mail_storage_set_critical(STORAGE(uidlist->mbox->storage),
+ mail_storage_set_critical(STORAGE(mbox->storage),
"file_dotlock_open(%s) failed: %m", path);
return -1;
}
uidlist->lock_fd = fd;
+ if (mbox->mail_create_gid != (gid_t)-1) {
+ if (fchown(fd, (uid_t)-1, mbox->mail_create_gid) < 0) {
+ mail_storage_set_critical(STORAGE(mbox->storage),
+ "fchown(%s) failed: %m", path);
+ }
+ }
+
/* our view of uidlist must be up-to-date if we plan on changing it */
if (maildir_uidlist_update(uidlist) < 0)
return -1;
Index: maildir-util.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-util.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- maildir-util.c 16 Jan 2007 16:59:06 -0000 1.20
+++ maildir-util.c 18 Jan 2007 17:20:50 -0000 1.21
@@ -132,6 +132,12 @@
mail_storage_set_critical(STORAGE(mbox->storage),
"open(%s) failed: %m", path);
}
+ } else if (st.st_gid != mbox->mail_create_gid &&
+ mbox->mail_create_gid != (gid_t)-1) {
+ if (fchown(fd, (uid_t)-1, mbox->mail_create_gid) < 0) {
+ mail_storage_set_critical(STORAGE(mbox->storage),
+ "fchown(%s) failed: %m", path);
+ }
}
pool_unref(pool);
- Previous message: [dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-keywords.c, 1.6.2.5, 1.6.2.6 maildir-storage.c, 1.115.2.20, 1.115.2.21 maildir-storage.h, 1.49.2.5, 1.49.2.6 maildir-uidlist.c, 1.51.2.4, 1.51.2.5 maildir-util.c, 1.14.2.3, 1.14.2.4
- Next message: [dovecot-cvs] dovecot-sieve configure.in,1.2,1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list