~ubuntu-dev/ubuntu/lucid/dovecot/lucid-201002101901

« back to all changes in this revision

Viewing changes to libsieve/src/lib-sieve/plugins/mailbox/tag-mailbox-create.c

  • Committer: Chuck Short
  • Date: 2010-01-21 20:21:25 UTC
  • mfrom: (4.1.11 squeeze)
  • Revision ID: zulcss@ubuntu.com-20100121202125-pme73o491kfwj5nc
* 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 restriction
    - 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 config
    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.
    - 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.
   + Add SMTP-AUTH support for Outlook (login auth mechanism)
* New upstream release.
* debian/patches/gold-fix.patch: Removed. Fixed upstream.
* Moved libexec to lib corrections in dovecot-managesieve.patch and
  dovecot-managesieve-dist.patch to dovecot-example.patch
* debian/patches/dovecot-mboxlocking.patch: Regenerated to avoid FTBFS
  when quilt isn't installed.
* debian/patches/quota-mountpoint.patch: Removed. Not needed anymore.
* debian/patches/dovecot-quota.patch: Removed. Quotas aren't properly
  enabled unless mail_plugins = quota imap_quota.
* debian/patches/gold-fix.patch: Fixed configure script to build even
  with binutils-gold or --no-add-needed linker flag (Closes: #554306)
* debian/dovecot-common.init: fixed LSB headers. Thanks to Pascal Volk.
  (Closes: #558040)
* debian/changelog: added CVE references to previous changelog entry.
* debian/rules: checked up the build system. It's not fragile anymore.
  (Closes: 493803)
* debian/dovecot-common.postinst: Now invoking dpkg-reconfigure
  on dovecot-common is enough to generate new certificates
  if the previous ones were removed. (Closes: #545582)
* debian/rules: No longer install convert-tool in /usr/bin.
  It isn't an user utility and it should stay in /usr/lib/dovecot
  like all other similar tool.
* New upstream release. (Closes: #557601)
* [SECURITY] Fixes local information disclosure and denial of service.
  (see: http://www.dovecot.org/list/dovecot-news/2009-November/000143.html
  and CVE-2009-3897)
* Added myself to uploaders.
* Switched to the new source format "3.0 (quilt)":
  - removed dpatch from build-depends
  - removed debian/README.source because now we use only standard
    dpkg features
  - regenerated all patches
* Prepared to switch to multi-origin source:
  - recreated dovecot-libsieve.patch and dovecot-managesieve-dist.patch
    starting from the upstream tarball
  - removed all autotools related build-depends and build-conflict
  - renamed dovecot-libsieve and dovecot-managesieve directories
    to libsieve and managesieve.
* debian/rules: Moved the configuration of libsieve and managesieve from
  the build phase to the configuration phase
* Added dovecot-dbg package  with debugging symbols.  Thanks Stephan Bosch.
  (Closes: #554710)
* Fixed some stray libexec'isms in the default configuration.
* New upstream release.
* debian/dovecot-common.init:
  - use $CONF when starting the daemon. (Closes: #549944)
  - always output start/stop messages. (Closes: #523810)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2002-2009 Dovecot Sieve authors, see the included COPYING file
 
2
 */
 
3
 
 
4
#include "lib.h"
 
5
#include "mail-storage.h"
 
6
#include "mail-namespace.h"
 
7
 
 
8
#include "sieve-common.h"
 
9
#include "sieve-commands.h"
 
10
#include "sieve-code.h"
 
11
#include "sieve-actions.h"
 
12
#include "sieve-result.h"
 
13
#include "sieve-generator.h"
 
14
 
 
15
#include "ext-mailbox-common.h"
 
16
 
 
17
/* 
 
18
 * Tagged argument 
 
19
 */
 
20
 
 
21
static bool tag_mailbox_create_validate
 
22
        (struct sieve_validator *validator, struct sieve_ast_argument **arg, 
 
23
                struct sieve_command_context *cmd);
 
24
static bool tag_mailbox_create_generate
 
25
        (const struct sieve_codegen_env *cgenv, struct sieve_ast_argument *arg,
 
26
    struct sieve_command_context *context);
 
27
 
 
28
const struct sieve_argument mailbox_create_tag = { 
 
29
        "create", 
 
30
        NULL, NULL,
 
31
        tag_mailbox_create_validate, 
 
32
        NULL,
 
33
        tag_mailbox_create_generate
 
34
};
 
35
 
 
36
/*
 
37
 * Side effect 
 
38
 */
 
39
 
 
40
static void seff_mailbox_create_print
 
41
        (const struct sieve_side_effect *seffect, const struct sieve_action *action, 
 
42
                const struct sieve_result_print_env *rpenv, void *se_context, bool *keep);
 
43
static bool seff_mailbox_create_pre_execute
 
44
        (const struct sieve_side_effect *seffect, const struct sieve_action *action, 
 
45
                const struct sieve_action_exec_env *aenv, void **se_context, 
 
46
                void *tr_context);;
 
47
 
 
48
const struct sieve_side_effect mailbox_create_side_effect = {
 
49
        SIEVE_OBJECT("create", &mailbox_create_operand, 0),
 
50
        &act_store,
 
51
        NULL, NULL, NULL,
 
52
        seff_mailbox_create_print,
 
53
        seff_mailbox_create_pre_execute, 
 
54
        NULL, NULL, NULL
 
55
};
 
56
 
 
57
/*
 
58
 * Operand
 
59
 */
 
60
 
 
61
static const struct sieve_extension_objects ext_side_effects =
 
62
        SIEVE_EXT_DEFINE_SIDE_EFFECT(mailbox_create_side_effect);
 
63
 
 
64
const struct sieve_operand mailbox_create_operand = {
 
65
        "create operand",
 
66
        &mailbox_extension,
 
67
        0,
 
68
        &sieve_side_effect_operand_class,
 
69
        &ext_side_effects
 
70
};
 
71
 
 
72
/* 
 
73
 * Tag validation 
 
74
 */
 
75
 
 
76
static bool tag_mailbox_create_validate
 
77
        (struct sieve_validator *validator ATTR_UNUSED, 
 
78
        struct sieve_ast_argument **arg ATTR_UNUSED, 
 
79
        struct sieve_command_context *cmd ATTR_UNUSED)
 
80
{
 
81
        *arg = sieve_ast_argument_next(*arg);
 
82
 
 
83
        return TRUE;
 
84
}
 
85
 
 
86
/*
 
87
 * Code generation 
 
88
 */
 
89
 
 
90
static bool tag_mailbox_create_generate
 
91
(const struct sieve_codegen_env *cgenv, struct sieve_ast_argument *arg,
 
92
    struct sieve_command_context *context ATTR_UNUSED)
 
93
{
 
94
        if ( sieve_ast_argument_type(arg) != SAAT_TAG ) {
 
95
                return FALSE;
 
96
        }
 
97
 
 
98
        sieve_opr_side_effect_emit(cgenv->sbin, &mailbox_create_side_effect);
 
99
 
 
100
        return TRUE;
 
101
}
 
102
 
 
103
/* 
 
104
 * Side effect implementation
 
105
 */
 
106
 
 
107
static void seff_mailbox_create_print
 
108
(const struct sieve_side_effect *seffect ATTR_UNUSED, 
 
109
        const struct sieve_action *action ATTR_UNUSED, 
 
110
        const struct sieve_result_print_env *rpenv,
 
111
        void *se_context ATTR_UNUSED, bool *keep ATTR_UNUSED)
 
112
{
 
113
        sieve_result_seffect_printf(rpenv, "create mailbox if it does not exist");
 
114
}
 
115
 
 
116
static bool seff_mailbox_create_pre_execute
 
117
(const struct sieve_side_effect *seffect ATTR_UNUSED, 
 
118
        const struct sieve_action *action ATTR_UNUSED, 
 
119
        const struct sieve_action_exec_env *aenv ATTR_UNUSED,
 
120
        void **se_context ATTR_UNUSED, void *tr_context ATTR_UNUSED)
 
121
{       
 
122
        struct act_store_transaction *trans = 
 
123
                (struct act_store_transaction *) tr_context;
 
124
        struct mail_storage **storage = &(aenv->exec_status->last_storage);
 
125
        enum mailbox_open_flags open_flags = 
 
126
                MAILBOX_OPEN_FAST | MAILBOX_OPEN_KEEP_RECENT | 
 
127
                MAILBOX_OPEN_SAVEONLY | MAILBOX_OPEN_POST_SESSION;
 
128
        struct mailbox *box = NULL;
 
129
        
 
130
        /* Check whether creation is necessary */
 
131
        if ( trans->box != NULL || trans->redundant || trans->disabled ) 
 
132
                return TRUE;
 
133
 
 
134
        /* Check availability of namespace and folder name */
 
135
        if ( trans->namespace == NULL || trans->folder == NULL )
 
136
                return FALSE;
 
137
 
 
138
        /* Check whether creation has a chance of working */
 
139
        if ( trans->error_code != MAIL_ERROR_NONE 
 
140
                && trans->error_code != MAIL_ERROR_NOTFOUND )
 
141
                return FALSE;
 
142
 
 
143
        *storage = trans->namespace->storage; 
 
144
 
 
145
        /* Create mailbox */
 
146
        if ( mail_storage_mailbox_create(*storage, trans->folder, FALSE) < 0 ) {
 
147
                box = NULL;
 
148
 
 
149
        } else {
 
150
                /* Subscribe to it if necessary */
 
151
                if ( aenv->scriptenv->mailbox_autosubscribe ) {
 
152
                        (void)mailbox_list_set_subscribed
 
153
                                (trans->namespace->list, trans->folder, TRUE);
 
154
                }
 
155
 
 
156
                /* Open it */
 
157
                box = mailbox_open(storage, trans->folder, NULL, open_flags);
 
158
    
 
159
                if ( box != NULL && mailbox_sync(box, 0, 0, NULL) < 0 ) {
 
160
                        mailbox_close(&box);
 
161
                        box = NULL;
 
162
                }
 
163
        } 
 
164
 
 
165
        /* Fetch error */
 
166
        if ( box == NULL )
 
167
                sieve_act_store_get_storage_error(aenv, trans); 
 
168
 
 
169
        trans->box = box;
 
170
        
 
171
        return ( box != NULL );
 
172
}
 
173
 
 
174
 
 
175