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

« back to all changes in this revision

Viewing changes to pigeonhole/src/lib-sieve/plugins/mailbox/tag-mailbox-create.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) 2002-2012 Pigeonhole authors, see the included COPYING file
 
1
/* Copyright (c) 2002-2013 Pigeonhole authors, see the included COPYING file
2
2
 */
3
3
 
4
4
#include "lib.h"
15
15
 
16
16
#include "ext-mailbox-common.h"
17
17
 
18
 
/* 
19
 
 * Tagged argument 
 
18
/*
 
19
 * Tagged argument
20
20
 */
21
21
 
22
22
static bool tag_mailbox_create_validate
23
 
        (struct sieve_validator *valdtr, struct sieve_ast_argument **arg, 
 
23
        (struct sieve_validator *valdtr, struct sieve_ast_argument **arg,
24
24
                struct sieve_command *cmd);
25
25
static bool tag_mailbox_create_generate
26
26
        (const struct sieve_codegen_env *cgenv, struct sieve_ast_argument *arg,
27
27
    struct sieve_command *context);
28
28
 
29
 
const struct sieve_argument_def mailbox_create_tag = { 
30
 
        "create", 
 
29
const struct sieve_argument_def mailbox_create_tag = {
 
30
        "create",
31
31
        NULL,
32
 
        tag_mailbox_create_validate, 
 
32
        tag_mailbox_create_validate,
33
33
        NULL, NULL,
34
34
        tag_mailbox_create_generate
35
35
};
36
36
 
37
37
/*
38
 
 * Side effect 
 
38
 * Side effect
39
39
 */
40
40
 
41
41
static void seff_mailbox_create_print
42
 
        (const struct sieve_side_effect *seffect, const struct sieve_action *action, 
 
42
        (const struct sieve_side_effect *seffect, const struct sieve_action *action,
43
43
                const struct sieve_result_print_env *rpenv, bool *keep);
44
 
static bool seff_mailbox_create_pre_execute
45
 
        (const struct sieve_side_effect *seffect, const struct sieve_action *action, 
46
 
                const struct sieve_action_exec_env *aenv, void **se_context, 
 
44
static int seff_mailbox_create_pre_execute
 
45
        (const struct sieve_side_effect *seffect, const struct sieve_action *action,
 
46
                const struct sieve_action_exec_env *aenv, void **se_context,
47
47
                void *tr_context);
48
48
 
49
49
const struct sieve_side_effect_def mailbox_create_side_effect = {
51
51
        &act_store,
52
52
        NULL, NULL, NULL,
53
53
        seff_mailbox_create_print,
54
 
        seff_mailbox_create_pre_execute, 
 
54
        seff_mailbox_create_pre_execute,
55
55
        NULL, NULL, NULL
56
56
};
57
57
 
70
70
        &ext_side_effects
71
71
};
72
72
 
73
 
/* 
74
 
 * Tag validation 
 
73
/*
 
74
 * Tag validation
75
75
 */
76
76
 
77
77
static bool tag_mailbox_create_validate
78
 
(struct sieve_validator *valdtr ATTR_UNUSED, 
 
78
(struct sieve_validator *valdtr ATTR_UNUSED,
79
79
        struct sieve_ast_argument **arg, struct sieve_command *cmd ATTR_UNUSED)
80
80
{
81
81
        *arg = sieve_ast_argument_next(*arg);
84
84
}
85
85
 
86
86
/*
87
 
 * Code generation 
 
87
 * Code generation
88
88
 */
89
89
 
90
90
static bool tag_mailbox_create_generate
101
101
        return TRUE;
102
102
}
103
103
 
104
 
/* 
 
104
/*
105
105
 * Side effect implementation
106
106
 */
107
107
 
108
108
static void seff_mailbox_create_print
109
 
(const struct sieve_side_effect *seffect ATTR_UNUSED, 
110
 
        const struct sieve_action *action ATTR_UNUSED, 
 
109
(const struct sieve_side_effect *seffect ATTR_UNUSED,
 
110
        const struct sieve_action *action ATTR_UNUSED,
111
111
        const struct sieve_result_print_env *rpenv, bool *keep ATTR_UNUSED)
112
112
{
113
113
        sieve_result_seffect_printf(rpenv, "create mailbox if it does not exist");
114
114
}
115
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, 
 
116
static int seff_mailbox_create_pre_execute
 
117
(const struct sieve_side_effect *seffect ATTR_UNUSED,
 
118
        const struct sieve_action *action ATTR_UNUSED,
119
119
        const struct sieve_action_exec_env *aenv ATTR_UNUSED,
120
120
        void **se_context ATTR_UNUSED, void *tr_context ATTR_UNUSED)
121
 
{       
122
 
        struct act_store_transaction *trans = 
 
121
{
 
122
        struct act_store_transaction *trans =
123
123
                (struct act_store_transaction *) tr_context;
124
124
        struct mail_storage **storage = &(aenv->exec_status->last_storage);
125
125
        enum mail_error error;
126
 
        
 
126
 
127
127
        /* Check whether creation is necessary */
128
128
        if ( trans->box == NULL || trans->disabled )
129
 
                return TRUE;
 
129
                return SIEVE_EXEC_OK;
130
130
 
131
131
        /* Check whether creation has a chance of working */
132
 
        if ( trans->error_code != MAIL_ERROR_NONE && 
133
 
                trans->error_code != MAIL_ERROR_NOTFOUND )
134
 
                return FALSE;
 
132
        switch ( trans->error_code ) {
 
133
        case MAIL_ERROR_NONE:
 
134
        case MAIL_ERROR_NOTFOUND:
 
135
                break;
 
136
        case MAIL_ERROR_TEMP:
 
137
                return SIEVE_EXEC_TEMP_FAILURE;
 
138
        default:
 
139
                return SIEVE_EXEC_FAILURE;
 
140
        }
135
141
 
136
142
        trans->error = NULL;
137
143
        trans->error_code = MAIL_ERROR_NONE;
138
 
        
139
144
 
140
145
        *storage = mailbox_get_storage(trans->box);
141
146
 
144
149
                (void)mail_storage_get_last_error(*storage, &error);
145
150
                if ( error != MAIL_ERROR_EXISTS ) {
146
151
                        sieve_act_store_get_storage_error(aenv, trans);
147
 
                        return FALSE;
 
152
                        return ( trans->error_code == MAIL_ERROR_TEMP ?
 
153
                                SIEVE_EXEC_TEMP_FAILURE : SIEVE_EXEC_FAILURE );
148
154
                }
149
155
        }
150
156
 
156
162
        }
157
163
 
158
164
        /* Try opening again */
159
 
        if ( mailbox_sync(trans->box, 0) < 0 ) {
 
165
        if ( mailbox_open(trans->box) < 0 ) {
160
166
                /* Failed definitively */
161
167
                sieve_act_store_get_storage_error(aenv, trans);
162
 
                return FALSE;
 
168
                return ( trans->error_code == MAIL_ERROR_TEMP ?
 
169
                        SIEVE_EXEC_TEMP_FAILURE : SIEVE_EXEC_FAILURE );
163
170
        }
164
171
 
165
 
        return TRUE;
 
172
        return SIEVE_EXEC_OK;
166
173
}
167
174
 
168
175