[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
tss at dovecot.org
tss at dovecot.org
Thu Jan 18 17:20:48 UTC 2007
- Previous message: [dovecot-cvs] dovecot/src/master mail-process.c, 1.110, 1.111 master-settings-defs.c, 1.3, 1.4 master-settings.c, 1.153, 1.154 master-settings.h, 1.93, 1.94
- Next message: [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
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv23071
Modified Files:
Tag: branch_1_0
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.6.2.5
retrieving revision 1.6.2.6
diff -u -d -r1.6.2.5 -r1.6.2.6
--- maildir-keywords.c 28 Dec 2006 23:19:53 -0000 1.6.2.5
+++ maildir-keywords.c 18 Jan 2007 17:20:45 -0000 1.6.2.6
@@ -270,13 +270,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;
@@ -288,7 +337,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);
@@ -298,44 +346,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;
}
@@ -356,7 +381,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.115.2.20
retrieving revision 1.115.2.21
diff -u -d -r1.115.2.20 -r1.115.2.21
--- maildir-storage.c 16 Jan 2007 16:59:02 -0000 1.115.2.20
+++ maildir-storage.c 18 Jan 2007 17:20:45 -0000 1.115.2.21
@@ -522,10 +522,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.49.2.5
retrieving revision 1.49.2.6
diff -u -d -r1.49.2.5 -r1.49.2.6
--- maildir-storage.h 16 Jan 2007 16:59:02 -0000 1.49.2.5
+++ maildir-storage.h 18 Jan 2007 17:20:45 -0000 1.49.2.6
@@ -74,7 +74,8 @@
time_t last_new_mtime, last_cur_mtime, last_new_sync_time;
time_t dirty_cur_time;
- 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.51.2.4
retrieving revision 1.51.2.5
diff -u -d -r1.51.2.4 -r1.51.2.5
--- maildir-uidlist.c 28 Dec 2006 23:21:03 -0000 1.51.2.4
+++ maildir-uidlist.c 18 Jan 2007 17:20:45 -0000 1.51.2.5
@@ -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.14.2.3
retrieving revision 1.14.2.4
diff -u -d -r1.14.2.3 -r1.14.2.4
--- maildir-util.c 16 Jan 2007 16:59:02 -0000 1.14.2.3
+++ maildir-util.c 18 Jan 2007 17:20:46 -0000 1.14.2.4
@@ -130,6 +130,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/master mail-process.c, 1.110, 1.111 master-settings-defs.c, 1.3, 1.4 master-settings.c, 1.153, 1.154 master-settings.h, 1.93, 1.94
- Next message: [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
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list