From: Timo Sirainen Date: Wed, 4 Jun 2003 17:09:56 +0000 (+0300) Subject: mbox with in-memory indexes don't have control_dir and doesn't need it, so X-Git-Tag: 1.1.alpha1~4565 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc6a0f88601083a781d483f70d1baf5dbaac19aa;p=thirdparty%2Fdovecot%2Fcore.git mbox with in-memory indexes don't have control_dir and doesn't need it, so don't crash then. --HG-- branch : HEAD --- diff --git a/src/lib-index/mail-custom-flags.c b/src/lib-index/mail-custom-flags.c index 4a8f1b36d0..a66bf886d1 100644 --- a/src/lib-index/mail-custom-flags.c +++ b/src/lib-index/mail-custom-flags.c @@ -241,25 +241,34 @@ int mail_custom_flags_open_or_create(struct mail_index *index) const char *path; int fd, readonly; - path = t_strconcat(index->control_dir, "/", - CUSTOM_FLAGS_FILE_NAME, NULL); readonly = index->mailbox_readonly; - fd = !index->mailbox_readonly ? - open(path, O_RDWR | O_CREAT, 0660) : open(path, O_RDONLY); - if (fd == -1) { - if (errno == EACCES) { - fd = open(path, O_RDONLY); - readonly = TRUE; - } - if (errno != EACCES && errno != ENOENT && !ENOSPACE(errno)) { - index_file_set_syscall_error(index, path, "open()"); - return FALSE; + + if (index->control_dir != NULL) { + path = t_strconcat(index->control_dir, "/", + CUSTOM_FLAGS_FILE_NAME, NULL); + fd = !readonly ? open(path, O_RDWR | O_CREAT, 0660) : + open(path, O_RDONLY); + if (fd == -1) { + if (errno == EACCES) { + fd = open(path, O_RDONLY); + readonly = TRUE; + } + if (errno != EACCES && errno != ENOENT && + !ENOSPACE(errno)) { + index_file_set_syscall_error(index, path, "open()"); + return FALSE; + } } + } else { + path = NULL; + fd = -1; } mcf = i_new(struct mail_custom_flags, 1); mcf->index = index; - mcf->filepath = i_strdup(path); + mcf->filepath = fd != -1 ? i_strdup(path) : + i_strdup_printf("(in-memory custom flags for %s)", + index->mailbox_path); mcf->fd = fd; mcf->noupdate = mcf->fd == -1 || readonly;