]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mbox with in-memory indexes don't have control_dir and doesn't need it, so
authorTimo Sirainen <tss@iki.fi>
Wed, 4 Jun 2003 17:09:56 +0000 (20:09 +0300)
committerTimo Sirainen <tss@iki.fi>
Wed, 4 Jun 2003 17:09:56 +0000 (20:09 +0300)
don't crash then.

--HG--
branch : HEAD

src/lib-index/mail-custom-flags.c

index 4a8f1b36d0587493868e15993c21f1c2b5bdd870..a66bf886d1d0407c63655c9bc26575e3bb5d1bd8 100644 (file)
@@ -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;