~ubuntu-branches/ubuntu/wily/dovecot/wily

« back to all changes in this revision

Viewing changes to src/imap/cmd-append.c

  • Committer: Bazaar Package Importer
  • Author(s): CHuck Short, Chuck Short
  • Date: 2009-11-06 00:47:29 UTC
  • mfrom: (4.1.9 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091106004729-i39n7v9e7d4h51f6
Tags: 1:1.2.6-1ubuntu1
* Merge from debian testing, remaining changes:
  Add new binary pkg dovecot-postfix that integrates postfix and dovecot
  automatically: (LP: #164837)
  + debian/control:
    - add new binary with short description
    - set Architecture all for dovecot-postfix (LP: #329878)
  + debian/dovecot-postfix.postinst:
    - create initial certificate symlinks to snakeoil.
    - set up postfix with postconf to:
      - use Maildir/ as the default mailbox.
      - use dovecot as the sasl authentication server.
      - use dovecot LDA (deliver).
      - use tls for smtp{d} services.
    - fix certificates paths in postfix' main.cf
    - add reject_unauth_destination to postfix' recipient restrictions
    - add reject_unknown_sender_domain to postfix' sender restrictions
    - rename configuration name on remove, delete on purge
    - restart dovecot after linking certificates
    - handle use case when postfix is unconfigurated
   + debian/dovecot-postfix.dirs: create backup directory for postfix's configuration
   + restart postfix and dovecot.
   + debian/dovecot-postfix.postrm:
     - remove all dovecot related configuration from postfix.
     - restart postfix and dovecot.
   + debian/dovecot-common.init:
     - check if /etc/dovecot/dovecot-postfix.conf exists and use it
       as the configuration file if so.
   + debian/patches/warning-ubuntu-postfix.dpatch
     - add warning about dovecot-postfix.conf in dovecot default 
       configuration file
   + debian/patches/dovecot-postfix.conf.diff:
     - Ubuntu server custom changes to the default dovecot configuration for
       better interfation with postfix
     - enable sieve plugin
   + debian/patches/dovecot-postfix.conf.diff:
     + Ubuntu server custom changes to the default dovecot configuration for
       better integration with postfix:
       - enable imap, pop3, imaps, pop3s and managesieve by default.
       - enable dovecot LDA (deliver).
       - enable SASL auth socket in postfix private directory.
   + debian/rules:
     - copy, patch and install dovecot-postfix.conf in /etc/dovecot/.
     - build architecure independent packages too
   + Use Snakeoil SSL certificates by default.
     - debian/control: Depend on ssl-cert.
     - debian/patches/ssl-cert-snakeoil.dpatch: Change default SSL cert
       paths to snakeoil.
     - debian/dovecot-common.postinst: Relax grep for SSL_* a bit.
   + Add autopkgtest to debian/tests/*.
   + Fast TearDown: Update the lsb init header to not stop in level 6.
   + Add ufw integration:
     - Created debian/dovecot-common.ufw.profile.
     - debian/rules:
       + install profile
     - debian/control:
       + Suggest ufw
   + debian/{control,rules}: enable PIE hardening.
   + dovecot-imapd, dovecot-pop3: Replaces dovecot-common (<< 1:1.1). LP: #254721
   + debian/control:
     - Update Vcs-* headers.
   + debian/rules:
     - Create emtpy stamp.h.in files in dovecot-sieve/ and dovecot-managesieve/
       if they're not there since empty files are not included in the diff.gz 
       file.
   + Add SMTP-AUTH support for Outlook (login auth mechanism)
   + Dropped:
     - debian/patches/security-CVE-2009-3235: Applied upstream.
     - debian/patches/fix-pop3-assertion.dpatch: Applied upstream.
     - dovecot-sieve and dovecot-managesieve: Use the debian patches instead.

  [Chuck Short]
  - Updated dovecot-sieve to 0.1.13.
  - Updated dovecot-managesieve to 0.11.9.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
 
13
13
#include <sys/time.h>
14
14
 
 
15
/* Don't allow internaldates to be too far in the future. At least with Maildir
 
16
   they can cause problems with incremental backups since internaldate is
 
17
   stored in file's mtime. But perhaps there are also some other reasons why
 
18
   it might not be wanted. */
 
19
#define INTERNALDATE_MAX_FUTURE_SECS (2*3600)
 
20
 
15
21
struct cmd_append_context {
16
22
        struct client *client;
17
23
        struct client_command_context *cmd;
38
44
{
39
45
        struct cmd_append_context *ctx = cmd->context;
40
46
        struct client *client = cmd->client;
41
 
        struct ostream *output = client->output;
42
47
        bool finished;
43
48
 
44
49
        i_assert(!client->destroyed);
74
79
                return;
75
80
        }
76
81
 
77
 
        o_stream_ref(output);
78
 
        o_stream_cork(output);
 
82
        o_stream_cork(client->output);
79
83
        finished = cmd->func(cmd);
80
84
        if (!finished && cmd->state != CLIENT_COMMAND_STATE_DONE)
81
85
                (void)client_handle_unfinished_cmd(cmd);
82
86
        else
83
87
                client_command_free(&cmd);
84
88
        (void)cmd_sync_delayed(client);
85
 
        client_continue_pending_input(&client);
86
 
        o_stream_uncork(output);
87
 
        o_stream_unref(&output);
 
89
        o_stream_uncork(client->output);
 
90
 
 
91
        if (client->disconnected)
 
92
                client_destroy(client, NULL);
 
93
        else
 
94
                client_continue_pending_input(client);
88
95
}
89
96
 
90
97
/* Returns -1 = error, 0 = need more data, 1 = successful. flags and
248
255
                        cmd_append_finish(ctx);
249
256
                        return TRUE;
250
257
                }
 
258
                if (ctx->count == 0) {
 
259
                        client_send_tagline(cmd, "BAD Missing message size.");
 
260
                        cmd_append_finish(ctx);
 
261
                        return TRUE;
 
262
                }
251
263
 
252
264
                ret = mailbox_transaction_commit_get_uids(&ctx->t,
253
265
                                                          &uid_validity,
259
271
                }
260
272
                i_assert(ctx->count == uid2 - uid1 + 1);
261
273
 
262
 
                if (uid1 == uid2) {
 
274
                if (uid1 == 0)
 
275
                        msg = "OK Append completed.";
 
276
                else if (uid1 == uid2) {
263
277
                        msg = t_strdup_printf("OK [APPENDUID %u %u] "
264
278
                                              "Append completed.",
265
279
                                              uid_validity, uid1);
319
333
                return cmd_append_cancel(ctx, nonsync);
320
334
        }
321
335
 
 
336
        if (internal_date != (time_t)-1 &&
 
337
            internal_date > ioloop_time + INTERNALDATE_MAX_FUTURE_SECS) {
 
338
                /* the client specified a time in the future, set it to now. */
 
339
                internal_date = (time_t)-1;
 
340
                timezone_offset = 0;
 
341
        }
 
342
 
322
343
        if (ctx->msg_size == 0) {
323
344
                /* no message data, abort */
324
345
                client_send_tagline(cmd, "NO Can't save a zero byte message.");
327
348
 
328
349
        /* save the mail */
329
350
        ctx->input = i_stream_create_limit(client->input, ctx->msg_size);
330
 
        ret = mailbox_save_init(ctx->t, flags, keywords,
331
 
                                internal_date, timezone_offset, NULL,
332
 
                                ctx->input, NULL, &ctx->save_ctx);
 
351
        ctx->save_ctx = mailbox_save_alloc(ctx->t);
 
352
        mailbox_save_set_flags(ctx->save_ctx, flags, keywords);
 
353
        mailbox_save_set_received_date(ctx->save_ctx,
 
354
                                       internal_date, timezone_offset);
 
355
        ret = mailbox_save_begin(&ctx->save_ctx, ctx->input);
333
356
 
334
357
        if (keywords != NULL)
335
358
                mailbox_keywords_free(ctx->box, &keywords);
432
455
        struct mail_storage *storage;
433
456
        struct mailbox *box;
434
457
 
435
 
        if (!client_verify_mailbox_name(cmd, name, TRUE, FALSE))
 
458
        if (!client_verify_mailbox_name(cmd, name,
 
459
                                CLIENT_VERIFY_MAILBOX_SHOULD_EXIST_TRYCREATE))
436
460
                return NULL;
437
461
 
438
462
        storage = client_find_storage(cmd, &name);
443
467
            mailbox_equals(cmd->client->mailbox, storage, name))
444
468
                return cmd->client->mailbox;
445
469
 
446
 
        box = mailbox_open(storage, name, NULL, MAILBOX_OPEN_SAVEONLY |
 
470
        box = mailbox_open(&storage, name, NULL, MAILBOX_OPEN_SAVEONLY |
447
471
                           MAILBOX_OPEN_FAST | MAILBOX_OPEN_KEEP_RECENT);
448
472
        if (box == NULL) {
449
473
                client_send_storage_error(cmd, storage);
450
474
                return NULL;
451
475
        }
 
476
        if (cmd->client->enabled_features != 0)
 
477
                mailbox_enable(box, cmd->client->enabled_features);
452
478
        return box;
453
479
}
454
480