~james-page/ubuntu/raring/dovecot/autopkgtest

« back to all changes in this revision

Viewing changes to src/lib-storage/index/cydir/cydir-storage.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-06-11 11:11:54 UTC
  • mfrom: (1.15.2) (4.1.27 sid)
  • Revision ID: package-import@ubuntu.com-20120611111154-678cwbdj6ktgsv1h
Tags: 1:2.1.7-1ubuntu1
* Merge from Debian unstable, remaining changes:
  + Add mail-stack-delivery package:
    - Update d/rules
    - d/control: convert existing dovecot-postfix package to a dummy
      package and add new mail-stack-delivery package.
    - Update maintainer scripts.
    - Rename d/dovecot-postfix.* to debian/mail-stack-delivery.*
    - d/mail-stack-delivery.preinst: Move previously installed backups and
      config files to a new package namespace.
    - d/mail-stack-delivery.prerm: Added to handle downgrades.
  + Use Snakeoil SSL certificates by default:
    - d/control: Depend on ssl-cert.
    - d/dovecot-core.postinst: Relax grep for SSL_* a bit.
  + Add autopkgtest to debian/tests/*.
  + Add ufw integration:
    - d/dovecot-core.ufw.profile: new ufw profile.
    - d/rules: install profile in dovecot-core.
    - d/control: dovecot-core - suggest ufw.
  + d/{control,rules}: enable PIE hardening.
  + d/dovecot-core.dirs: Added usr/share/doc/dovecot-core
  + Add apport hook:
    - d/rules, d/source_dovecot.py
  + Add upstart job:
    - d/rules, d/dovecot-core.dovecot.upstart, d/control,
      d/dovecot-core.dirs, dovecot-imapd.{postrm, postinst, prerm},
      d/dovecot-pop3d.{postinst, postrm, prerm}.
      d/mail-stack-deliver.postinst: Convert init script to upstart.
  + d/control: Added Pre-Depends: dpkg (>= 1.15.6) to dovecot-dbg to support
    xz compression in Ubuntu.
  + d/control: Demote dovecot-common Recommends: to Suggests: to prevent
    install of extra packages on upgrade.
  + d/patches/dovecot-drac.patch: Updated with version for dovecot >= 2.0.0.
  + d/control: Drop B-D on systemd.
* Dropped changes:
  + d/patches/fix-racey-restart.patch: part of 2.1.x, no longer required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2007-2011 Dovecot authors, see the included COPYING file */
 
1
/* Copyright (c) 2007-2012 Dovecot authors, see the included COPYING file */
2
2
 
3
3
#include "lib.h"
4
4
#include "mail-copy.h"
36
36
 
37
37
static struct mailbox *
38
38
cydir_mailbox_alloc(struct mail_storage *storage, struct mailbox_list *list,
39
 
                    const char *name, enum mailbox_flags flags)
 
39
                    const char *vname, enum mailbox_flags flags)
40
40
{
41
41
        struct cydir_mailbox *mbox;
42
 
        struct index_mailbox_context *ibox;
43
42
        pool_t pool;
44
43
 
45
44
        /* cydir can't work without index files */
53
52
        mbox->box.list = list;
54
53
        mbox->box.mail_vfuncs = &cydir_mail_vfuncs;
55
54
 
56
 
        index_storage_mailbox_alloc(&mbox->box, name, flags,
 
55
        index_storage_mailbox_alloc(&mbox->box, vname, flags,
57
56
                                    CYDIR_INDEX_PREFIX);
58
 
        mail_index_set_fsync_mode(mbox->box.index,
59
 
                                  storage->set->parsed_fsync_mode,
60
 
                                  MAIL_INDEX_SYNC_TYPE_APPEND |
61
 
                                  MAIL_INDEX_SYNC_TYPE_EXPUNGE);
62
 
 
63
 
        ibox = INDEX_STORAGE_CONTEXT(&mbox->box);
64
 
        ibox->save_commit_pre = cydir_transaction_save_commit_pre;
65
 
        ibox->save_commit_post = cydir_transaction_save_commit_post;
66
 
        ibox->save_rollback = cydir_transaction_save_rollback;
67
57
 
68
58
        mbox->storage = (struct cydir_storage *)storage;
69
59
        return &mbox->box;
71
61
 
72
62
static int cydir_mailbox_open(struct mailbox *box)
73
63
{
 
64
        const char *box_path = mailbox_get_path(box);
74
65
        struct stat st;
75
66
 
76
 
        if (stat(box->path, &st) == 0) {
 
67
        if (stat(box_path, &st) == 0) {
77
68
                /* exists, open it */
78
69
        } else if (errno == ENOENT) {
79
70
                mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
81
72
                return -1;
82
73
        } else if (errno == EACCES) {
83
74
                mail_storage_set_critical(box->storage, "%s",
84
 
                        mail_error_eacces_msg("stat", box->path));
 
75
                        mail_error_eacces_msg("stat", box_path));
85
76
                return -1;
86
77
        } else {
87
78
                mail_storage_set_critical(box->storage, "stat(%s) failed: %m",
88
 
                                          box->path);
 
79
                                          box_path);
89
80
                return -1;
90
81
        }
91
 
        return index_storage_mailbox_open(box, FALSE);
 
82
        if (index_storage_mailbox_open(box, FALSE) < 0)
 
83
                return -1;
 
84
        mail_index_set_fsync_mode(box->index,
 
85
                                  box->storage->set->parsed_fsync_mode,
 
86
                                  MAIL_INDEX_SYNC_TYPE_APPEND |
 
87
                                  MAIL_INDEX_SYNC_TYPE_EXPUNGE);
 
88
        return 0;
92
89
}
93
90
 
94
91
static int
105
102
 
106
103
static void cydir_notify_changes(struct mailbox *box)
107
104
{
108
 
        struct cydir_mailbox *mbox = (struct cydir_mailbox *)box;
109
 
 
110
105
        if (box->notify_callback == NULL)
111
 
                index_mailbox_check_remove_all(&mbox->box);
 
106
                index_mailbox_check_remove_all(box);
112
107
        else
113
 
                index_mailbox_check_add(&mbox->box, mbox->box.path);
 
108
                index_mailbox_check_add(box, mailbox_get_path(box));
114
109
}
115
110
 
116
111
struct mail_storage cydir_storage = {
117
112
        .name = CYDIR_STORAGE_NAME,
118
 
        .class_flags = 0,
 
113
        .class_flags = MAIL_STORAGE_CLASS_FLAG_FILE_PER_MSG,
119
114
 
120
115
        .v = {
121
116
                NULL,
133
128
struct mailbox cydir_mailbox = {
134
129
        .v = {
135
130
                index_storage_is_readonly,
136
 
                index_storage_allow_new_keywords,
137
131
                index_storage_mailbox_enable,
 
132
                index_storage_mailbox_exists,
138
133
                cydir_mailbox_open,
139
134
                index_storage_mailbox_close,
140
135
                index_storage_mailbox_free,
144
139
                index_storage_mailbox_rename,
145
140
                index_storage_get_status,
146
141
                NULL,
147
 
                NULL,
148
 
                NULL,
 
142
                index_storage_set_subscribed,
 
143
                index_storage_list_index_has_changed,
 
144
                index_storage_list_index_update_sync,
149
145
                cydir_storage_sync_init,
150
146
                index_mailbox_sync_next,
151
147
                index_mailbox_sync_deinit,
154
150
                index_transaction_begin,
155
151
                index_transaction_commit,
156
152
                index_transaction_rollback,
157
 
                index_transaction_set_max_modseq,
158
 
                index_keywords_create,
159
 
                index_keywords_create_from_indexes,
160
 
                index_keywords_ref,
161
 
                index_keywords_unref,
162
 
                index_keyword_is_valid,
163
 
                index_storage_get_seq_range,
164
 
                index_storage_get_uid_range,
165
 
                index_storage_get_expunges,
166
 
                NULL,
167
 
                NULL,
168
153
                NULL,
169
154
                index_mail_alloc,
170
 
                index_header_lookup_init,
171
 
                index_header_lookup_deinit,
172
155
                index_storage_search_init,
173
156
                index_storage_search_deinit,
174
157
                index_storage_search_next_nonblock,
179
162
                cydir_save_finish,
180
163
                cydir_save_cancel,
181
164
                mail_storage_copy,
182
 
                NULL,
 
165
                cydir_transaction_save_commit_pre,
 
166
                cydir_transaction_save_commit_post,
 
167
                cydir_transaction_save_rollback,
183
168
                index_storage_is_inconsistent
184
169
        }
185
170
};