~ubuntu-branches/ubuntu/utopic/dovecot/utopic-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-08 09:35:49 UTC
  • mfrom: (4.1.35 sid)
  • Revision ID: package-import@ubuntu.com-20140108093549-i72o93pux8p0dlaf
Tags: 1:2.2.9-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/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.
  + Use the autotools-dev dh addon to update config.guess/config.sub for
    arm64.
* Dropped changes, included in Debian:
  - Update Dovecot name to reflect distribution in login greeting.
  - Update Drac plugin for >= 2.0.0 support.
* d/control: Drop dovecot-postfix package as its no longer required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2011-2012 Dovecot authors, see the included COPYING file */
 
1
/* Copyright (c) 2011-2013 Dovecot authors, see the included COPYING file */
2
2
 
3
3
#include "lib.h"
4
4
#include "ioloop.h"
50
50
}
51
51
 
52
52
static struct pop3c_client *
53
 
pop3c_client_create_from_set(struct mail_user *user,
 
53
pop3c_client_create_from_set(struct mail_storage *storage,
54
54
                             const struct pop3c_settings *set)
55
55
{
56
56
        struct pop3c_client_settings client_set;
60
60
        client_set.host = set->pop3c_host;
61
61
        client_set.port = set->pop3c_port;
62
62
        client_set.username = set->pop3c_user;
 
63
        client_set.master_user = set->pop3c_master_user;
63
64
        client_set.password = set->pop3c_password;
64
65
        client_set.dns_client_socket_path =
65
 
                t_strconcat(user->set->base_dir, "/",
 
66
                t_strconcat(storage->user->set->base_dir, "/",
66
67
                            DNS_CLIENT_SOCKET_NAME, NULL);
67
68
        str = t_str_new(128);
68
 
        mail_user_set_get_temp_prefix(str, user->set);
 
69
        mail_user_set_get_temp_prefix(str, storage->user->set);
69
70
        client_set.temp_path_prefix = str_c(str);
70
71
 
71
 
        client_set.debug = user->mail_debug;
 
72
        client_set.debug = storage->user->mail_debug;
72
73
        client_set.rawlog_dir =
73
 
                mail_user_home_expand(user, set->pop3c_rawlog_dir);
 
74
                mail_user_home_expand(storage->user, set->pop3c_rawlog_dir);
74
75
 
75
 
        client_set.ssl_ca_dir = set->pop3c_ssl_ca_dir;
 
76
        client_set.ssl_ca_dir = storage->set->ssl_client_ca_dir;
 
77
        client_set.ssl_ca_file = storage->set->ssl_client_ca_file;
76
78
        client_set.ssl_verify = set->pop3c_ssl_verify;
77
79
        if (strcmp(set->pop3c_ssl, "pop3s") == 0)
78
80
                client_set.ssl_mode = POP3C_CLIENT_SSL_MODE_IMMEDIATE;
80
82
                client_set.ssl_mode = POP3C_CLIENT_SSL_MODE_STARTTLS;
81
83
        else
82
84
                client_set.ssl_mode = POP3C_CLIENT_SSL_MODE_NONE;
83
 
        client_set.ssl_crypto_device = set->ssl_crypto_device;
 
85
        client_set.ssl_crypto_device = storage->set->ssl_crypto_device;
84
86
        return pop3c_client_init(&client_set);
85
87
}
86
88
 
116
118
        mbox->box.mail_vfuncs = &pop3c_mail_vfuncs;
117
119
        mbox->storage = (struct pop3c_storage *)storage;
118
120
 
119
 
        index_storage_mailbox_alloc(&mbox->box, vname, flags,
120
 
                                    POP3C_INDEX_PREFIX);
 
121
        index_storage_mailbox_alloc(&mbox->box, vname, flags, MAIL_INDEX_PREFIX);
121
122
        return &mbox->box;
122
123
}
123
124
 
164
165
 
165
166
        if (strcmp(box->name, "INBOX") != 0) {
166
167
                mail_storage_set_error(box->storage, MAIL_ERROR_NOTFOUND,
167
 
                                       T_MAIL_ERR_MAILBOX_NOT_FOUND(box->name));
 
168
                                       T_MAIL_ERR_MAILBOX_NOT_FOUND(box->vname));
168
169
                return -1;
169
170
        }
170
171
 
171
172
        if (index_storage_mailbox_open(box, FALSE) < 0)
172
173
                return -1;
173
174
 
174
 
        mbox->client = pop3c_client_create_from_set(box->storage->user,
 
175
        mbox->client = pop3c_client_create_from_set(box->storage,
175
176
                                                    mbox->storage->set);
176
177
        pop3c_client_login(mbox->client, pop3c_login_callback, mbox);
177
178
        pop3c_client_run(mbox->client);
203
204
pop3c_mailbox_update(struct mailbox *box,
204
205
                     const struct mailbox_update *update ATTR_UNUSED)
205
206
{
206
 
        mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
207
 
                               "POP3 mailbox update isn't supported");
208
 
        return -1;
 
207
        if (!guid_128_is_empty(update->mailbox_guid) ||
 
208
            update->uid_validity != 0 || update->min_next_uid != 0 ||
 
209
            update->min_first_recent_uid != 0) {
 
210
                mail_storage_set_error(box->storage, MAIL_ERROR_NOTPOSSIBLE,
 
211
                                       "POP3 mailbox update isn't supported");
 
212
        }
 
213
        return index_storage_mailbox_update(box, update);
 
214
}
 
215
 
 
216
static int pop3c_mailbox_get_metadata(struct mailbox *box,
 
217
                                      enum mailbox_metadata_items items,
 
218
                                      struct mailbox_metadata *metadata_r)
 
219
{
 
220
        if ((items & MAILBOX_METADATA_GUID) != 0) {
 
221
                /* a bit ugly way to do this, but better than nothing for now.
 
222
                   FIXME: if indexes are enabled, keep this there. */
 
223
                mail_generate_guid_128_hash(box->name, metadata_r->guid);
 
224
                items &= ~MAILBOX_METADATA_GUID;
 
225
        }
 
226
        if (items != 0) {
 
227
                if (index_mailbox_get_metadata(box, items, metadata_r) < 0)
 
228
                        return -1;
 
229
        }
 
230
        return 0;
209
231
}
210
232
 
211
233
static void pop3c_notify_changes(struct mailbox *box ATTR_UNUSED)
212
234
{
213
235
}
214
236
 
 
237
static struct mail_save_context *
 
238
pop3c_save_alloc(struct mailbox_transaction_context *t)
 
239
{
 
240
        struct mail_save_context *ctx;
 
241
 
 
242
        ctx = i_new(struct mail_save_context, 1);
 
243
        ctx->transaction = t;
 
244
        return ctx;
 
245
}
 
246
 
 
247
static int
 
248
pop3c_save_begin(struct mail_save_context *ctx,
 
249
                 struct istream *input ATTR_UNUSED)
 
250
{
 
251
        mail_storage_set_error(ctx->transaction->box->storage,
 
252
                MAIL_ERROR_NOTPOSSIBLE, "POP3 doesn't support saving mails");
 
253
        return -1;
 
254
}
 
255
 
 
256
static int pop3c_save_continue(struct mail_save_context *ctx ATTR_UNUSED)
 
257
{
 
258
        return -1;
 
259
}
 
260
 
 
261
static int pop3c_save_finish(struct mail_save_context *ctx)
 
262
{
 
263
        index_save_context_free(ctx);
 
264
        return -1;
 
265
}
 
266
 
 
267
static void
 
268
pop3c_save_cancel(struct mail_save_context *ctx)
 
269
{
 
270
        index_save_context_free(ctx);
 
271
}
 
272
 
215
273
static bool pop3c_storage_is_inconsistent(struct mailbox *box)
216
274
{
217
275
        struct pop3c_mailbox *mbox = (struct pop3c_mailbox *)box;
228
286
                pop3c_get_setting_parser_info,
229
287
                pop3c_storage_alloc,
230
288
                pop3c_storage_create,
231
 
                NULL,
 
289
                index_storage_destroy,
232
290
                NULL,
233
291
                pop3c_storage_get_list_settings,
234
292
                NULL,
250
308
                index_storage_mailbox_delete,
251
309
                index_storage_mailbox_rename,
252
310
                index_storage_get_status,
253
 
                index_mailbox_get_metadata,
 
311
                pop3c_mailbox_get_metadata,
254
312
                index_storage_set_subscribed,
 
313
                index_storage_attribute_set,
 
314
                index_storage_attribute_get,
 
315
                index_storage_attribute_iter_init,
 
316
                index_storage_attribute_iter_next,
 
317
                index_storage_attribute_iter_deinit,
255
318
                index_storage_list_index_has_changed,
256
319
                index_storage_list_index_update_sync,
257
320
                pop3c_storage_sync_init,
268
331
                index_storage_search_deinit,
269
332
                index_storage_search_next_nonblock,
270
333
                index_storage_search_next_update_seq,
271
 
                NULL,
272
 
                NULL,
273
 
                NULL,
274
 
                NULL,
275
 
                NULL,
 
334
                pop3c_save_alloc,
 
335
                pop3c_save_begin,
 
336
                pop3c_save_continue,
 
337
                pop3c_save_finish,
 
338
                pop3c_save_cancel,
276
339
                mail_storage_copy,
277
340
                NULL,
278
341
                NULL,