~ubuntu-dev/ubuntu/lucid/dovecot/lucid-201002110912

« back to all changes in this revision

Viewing changes to src/plugins/virtual/virtual-transaction.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:
 
1
/* Copyright (c) 2008-2009 Dovecot authors, see the included COPYING file */
 
2
 
 
3
#include "lib.h"
 
4
#include "array.h"
 
5
#include "virtual-storage.h"
 
6
#include "virtual-transaction.h"
 
7
 
 
8
static void (*next_hook_mail_index_transaction_created)
 
9
        (struct mail_index_transaction *t) = NULL;
 
10
 
 
11
struct mailbox_transaction_context *
 
12
virtual_transaction_get(struct mailbox_transaction_context *trans,
 
13
                        struct mailbox *backend_box)
 
14
{
 
15
        struct virtual_transaction_context *dt =
 
16
                (struct virtual_transaction_context *)trans;
 
17
        struct mailbox_transaction_context *const *bt, *new_bt;
 
18
        unsigned int i, count;
 
19
 
 
20
        bt = array_get(&dt->backend_transactions, &count);
 
21
        for (i = 0; i < count; i++) {
 
22
                if (bt[i]->box == backend_box)
 
23
                        return bt[i];
 
24
        }
 
25
 
 
26
        new_bt = mailbox_transaction_begin(backend_box, trans->flags);
 
27
        array_append(&dt->backend_transactions, &new_bt, 1);
 
28
        return new_bt;
 
29
}
 
30
 
 
31
static int virtual_transaction_commit(struct mail_index_transaction *t,
 
32
                                      uint32_t *log_file_seq_r,
 
33
                                      uoff_t *log_file_offset_r)
 
34
{
 
35
        struct virtual_transaction_context *dt = MAIL_STORAGE_CONTEXT(t);
 
36
        struct mailbox_transaction_context **bt;
 
37
        unsigned int i, count;
 
38
        int ret = 0;
 
39
 
 
40
        if (dt->save_ctx != NULL)
 
41
                virtual_save_free(dt->save_ctx);
 
42
 
 
43
        bt = array_get_modifiable(&dt->backend_transactions, &count);
 
44
        for (i = 0; i < count; i++) {
 
45
                if (mailbox_transaction_commit(&bt[i]) < 0)
 
46
                        ret = -1;
 
47
        }
 
48
        array_free(&dt->backend_transactions);
 
49
 
 
50
        if (index_transaction_finish_commit(&dt->ictx, log_file_seq_r,
 
51
                                            log_file_offset_r) < 0)
 
52
                ret = -1;
 
53
        return ret;
 
54
}
 
55
 
 
56
static void virtual_transaction_rollback(struct mail_index_transaction *t)
 
57
{
 
58
        struct virtual_transaction_context *dt = MAIL_STORAGE_CONTEXT(t);
 
59
        struct mailbox_transaction_context **bt;
 
60
        unsigned int i, count;
 
61
 
 
62
        if (dt->save_ctx != NULL)
 
63
                virtual_save_free(dt->save_ctx);
 
64
 
 
65
        bt = array_get_modifiable(&dt->backend_transactions, &count);
 
66
        for (i = 0; i < count; i++)
 
67
                mailbox_transaction_rollback(&bt[i]);
 
68
        array_free(&dt->backend_transactions);
 
69
 
 
70
        index_transaction_finish_rollback(&dt->ictx);
 
71
}
 
72
 
 
73
static void virtual_transaction_created(struct mail_index_transaction *t)
 
74
{
 
75
        struct mailbox *box = MAIL_STORAGE_CONTEXT(t->view);
 
76
 
 
77
        /* index can be for mailbox list index, in which case box=NULL */
 
78
        if (box != NULL &&
 
79
            strcmp(box->storage->name, VIRTUAL_STORAGE_NAME) == 0) {
 
80
                struct virtual_mailbox *mbox = (struct virtual_mailbox *)box;
 
81
                struct virtual_transaction_context *mt;
 
82
 
 
83
                mt = i_new(struct virtual_transaction_context, 1);
 
84
                mt->ictx.trans = t;
 
85
                mt->ictx.super = t->v;
 
86
 
 
87
                t->v.commit = virtual_transaction_commit;
 
88
                t->v.rollback = virtual_transaction_rollback;
 
89
                MODULE_CONTEXT_SET(t, mail_storage_mail_index_module, mt);
 
90
 
 
91
                i_array_init(&mt->backend_transactions,
 
92
                             array_count(&mbox->backend_boxes));
 
93
                index_transaction_init(&mt->ictx, &mbox->ibox);
 
94
        }
 
95
 
 
96
        if (next_hook_mail_index_transaction_created != NULL)
 
97
                next_hook_mail_index_transaction_created(t);
 
98
}
 
99
 
 
100
void virtual_transaction_class_init(void)
 
101
{
 
102
        next_hook_mail_index_transaction_created =
 
103
                hook_mail_index_transaction_created;
 
104
        hook_mail_index_transaction_created = virtual_transaction_created;
 
105
}
 
106
 
 
107
void virtual_transaction_class_deinit(void)
 
108
{
 
109
        i_assert(hook_mail_index_transaction_created ==
 
110
                 virtual_transaction_created);
 
111
        hook_mail_index_transaction_created =
 
112
                next_hook_mail_index_transaction_created;
 
113
}