~ubuntu-branches/ubuntu/quantal/dovecot/quantal

« back to all changes in this revision

Viewing changes to sieve/src/testsuite/cmd-test-mailbox.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-06-29 09:21:32 UTC
  • mfrom: (4.1.14 sid)
  • Revision ID: james.westby@ubuntu.com-20100629092132-q4pr5lfuvmjqou19
Tags: 1:1.2.12-1ubuntu1
* Merge from Debian Unstable, remaining changes:
  + Add mail-stack-delivery as per server-maverick-mail-integration spec:
   - Update debian/rules
   - Convert existing package to a dummy package and add new binary in debian/control
   - Update maintainer scripts.
   - Move previously installed backups and config files to new package name
     space in preinst
   - Add new debian/mail-stack-delivery.prerm to handle downgrades
   - Rename debian/dovecot-postfix.* to debian/mail-stack-delivery.*
  + 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/*.
  + Add ufw integration:
    - Created debian/dovecot-common.ufw.profile.
    - debian/rules: install profile.
    - debian/control: suggest ufw.
  + debian/{control,rules}: enable PIE hardening.
  + debian/control: Update Vcs-* headers.
  + Add SMTP-AUTH support for Outlook (login auth mechanism) 
  + debian/dovecot-common.dirs: Added usr/share/doc/dovecot-common
  + debian/patches/fix-dovecot-config-parser.patch: Fix ordering of external config 
    files. (LP: #597818)

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
/*
17
17
 * Test_mailbox command
18
18
 *
19
 
 * Syntax:   
 
19
 * Syntax:
20
20
 *   test_mailbox ( :create / :delete ) <mailbox: string>
21
21
 */
22
22
 
23
23
static bool cmd_test_mailbox_registered
24
 
        (struct sieve_validator *valdtr, const struct sieve_extension *ext, 
 
24
        (struct sieve_validator *valdtr, const struct sieve_extension *ext,
25
25
                struct sieve_command_registration *cmd_reg);
26
26
static bool cmd_test_mailbox_validate
27
27
        (struct sieve_validator *valdtr, struct sieve_command *cmd);
28
28
static bool cmd_test_mailbox_generate
29
29
        (const struct sieve_codegen_env *cgenv, struct sieve_command *ctx);
30
30
 
31
 
const struct sieve_command_def cmd_test_mailbox = { 
32
 
        "test_mailbox", 
33
 
        SCT_COMMAND, 
 
31
const struct sieve_command_def cmd_test_mailbox = {
 
32
        "test_mailbox",
 
33
        SCT_COMMAND,
34
34
        1, 0, FALSE, FALSE,
35
 
        cmd_test_mailbox_registered, 
 
35
        cmd_test_mailbox_registered,
36
36
        NULL,
37
 
        cmd_test_mailbox_validate, 
38
 
        cmd_test_mailbox_generate, 
39
 
        NULL 
 
37
        cmd_test_mailbox_validate,
 
38
        cmd_test_mailbox_generate,
 
39
        NULL
40
40
};
41
41
 
42
 
/* 
 
42
/*
43
43
 * Operations
44
 
 */ 
 
44
 */
45
45
 
46
46
static bool cmd_test_mailbox_operation_dump
47
47
        (const struct sieve_dumptime_env *denv, sieve_size_t *address);
48
48
static int cmd_test_mailbox_operation_execute
49
49
        (const struct sieve_runtime_env *renv, sieve_size_t *address);
50
 
 
 
50
 
51
51
/* Test_mailbox_create operation */
52
52
 
53
 
const struct sieve_operation_def test_mailbox_create_operation = { 
 
53
const struct sieve_operation_def test_mailbox_create_operation = {
54
54
        "TEST_MAILBOX_CREATE",
55
 
        &testsuite_extension, 
 
55
        &testsuite_extension,
56
56
        TESTSUITE_OPERATION_TEST_MAILBOX_CREATE,
57
 
        cmd_test_mailbox_operation_dump, 
58
 
        cmd_test_mailbox_operation_execute 
 
57
        cmd_test_mailbox_operation_dump,
 
58
        cmd_test_mailbox_operation_execute
59
59
};
60
60
 
61
61
/* Test_mailbox_delete operation */
62
62
 
63
 
const struct sieve_operation_def test_mailbox_delete_operation = { 
 
63
const struct sieve_operation_def test_mailbox_delete_operation = {
64
64
        "TEST_MAILBOX_DELETE",
65
 
        &testsuite_extension, 
 
65
        &testsuite_extension,
66
66
        TESTSUITE_OPERATION_TEST_MAILBOX_DELETE,
67
 
        cmd_test_mailbox_operation_dump, 
68
 
        cmd_test_mailbox_operation_execute 
 
67
        cmd_test_mailbox_operation_dump,
 
68
        cmd_test_mailbox_operation_execute
69
69
};
70
70
 
71
71
/*
72
72
 * Compiler context data
73
73
 */
74
 
 
 
74
 
75
75
enum test_mailbox_operation {
76
 
        MAILBOX_OP_CREATE, 
 
76
        MAILBOX_OP_CREATE,
77
77
        MAILBOX_OP_DELETE,
78
78
        MAILBOX_OP_LAST
79
79
};
88
88
        const char *folder;
89
89
};
90
90
 
91
 
/* 
92
 
 * Command tags 
 
91
/*
 
92
 * Command tags
93
93
 */
94
 
 
 
94
 
95
95
static bool cmd_test_mailbox_validate_tag
96
 
        (struct sieve_validator *valdtr, struct sieve_ast_argument **arg, 
 
96
        (struct sieve_validator *valdtr, struct sieve_ast_argument **arg,
97
97
                struct sieve_command *cmd);
98
98
 
99
 
static const struct sieve_argument_def test_mailbox_create_tag = { 
100
 
        "create", 
 
99
static const struct sieve_argument_def test_mailbox_create_tag = {
 
100
        "create",
101
101
        NULL,
102
102
        cmd_test_mailbox_validate_tag,
103
 
        NULL, NULL, NULL 
 
103
        NULL, NULL, NULL
104
104
};
105
105
 
106
 
static const struct sieve_argument_def test_mailbox_delete_tag = { 
107
 
        "delete", 
 
106
static const struct sieve_argument_def test_mailbox_delete_tag = {
 
107
        "delete",
108
108
        NULL,
109
109
        cmd_test_mailbox_validate_tag,
110
 
        NULL, NULL, NULL 
 
110
        NULL, NULL, NULL
111
111
};
112
112
 
113
113
static bool cmd_test_mailbox_registered
114
114
(struct sieve_validator *valdtr, const struct sieve_extension *ext,
115
 
        struct sieve_command_registration *cmd_reg) 
 
115
        struct sieve_command_registration *cmd_reg)
116
116
{
117
117
        /* Register our tags */
118
118
        sieve_validator_register_tag
119
 
                (valdtr, cmd_reg, ext, &test_mailbox_create_tag, 0);    
 
119
                (valdtr, cmd_reg, ext, &test_mailbox_create_tag, 0);
120
120
        sieve_validator_register_tag
121
 
                (valdtr, cmd_reg, ext, &test_mailbox_delete_tag, 0);    
 
121
                (valdtr, cmd_reg, ext, &test_mailbox_delete_tag, 0);
122
122
 
123
123
        return TRUE;
124
124
}
125
125
 
126
126
static bool cmd_test_mailbox_validate_tag
127
 
(struct sieve_validator *valdtr, struct sieve_ast_argument **arg, 
 
127
(struct sieve_validator *valdtr, struct sieve_ast_argument **arg,
128
128
        struct sieve_command *cmd)
129
129
{
130
 
        struct cmd_test_mailbox_context_data *ctx_data = 
131
 
                (struct cmd_test_mailbox_context_data *) cmd->data;     
132
 
        
 
130
        struct cmd_test_mailbox_context_data *ctx_data =
 
131
                (struct cmd_test_mailbox_context_data *) cmd->data;
 
132
 
133
133
        if ( ctx_data != NULL ) {
134
134
                sieve_argument_validate_error
135
135
                        (valdtr, *arg, "exactly one of the ':create' or ':delete' tags must be "
136
136
                                "specified for the test_mailbox command, but more were found");
137
 
                return NULL;            
 
137
                return NULL;
138
138
        }
139
 
        
 
139
 
140
140
        ctx_data = p_new
141
141
                (sieve_command_pool(cmd), struct cmd_test_mailbox_context_data, 1);
142
142
        cmd->data = ctx_data;
143
 
        
144
 
        if ( sieve_argument_is(*arg, test_mailbox_create_tag) ) 
 
143
 
 
144
        if ( sieve_argument_is(*arg, test_mailbox_create_tag) )
145
145
                ctx_data->mailbox_op = MAILBOX_OP_CREATE;
146
146
        else
147
147
                ctx_data->mailbox_op = MAILBOX_OP_DELETE;
152
152
        return TRUE;
153
153
}
154
154
 
155
 
/* 
156
 
 * Validation 
 
155
/*
 
156
 * Validation
157
157
 */
158
158
 
159
159
static bool cmd_test_mailbox_validate
160
 
(struct sieve_validator *valdtr, struct sieve_command *cmd) 
 
160
(struct sieve_validator *valdtr, struct sieve_command *cmd)
161
161
{
162
162
        struct sieve_ast_argument *arg = cmd->first_positional;
163
 
        
 
163
 
164
164
        if ( cmd->data == NULL ) {
165
 
                sieve_command_validate_error(valdtr, cmd, 
 
165
                sieve_command_validate_error(valdtr, cmd,
166
166
                        "the test_mailbox command requires either the :create or the :delete tag "
167
167
                        "to be specified");
168
 
                return FALSE;           
 
168
                return FALSE;
169
169
        }
170
 
                
 
170
 
171
171
        if ( !sieve_validate_positional_argument
172
172
                (valdtr, cmd, arg, "mailbox", 1, SAAT_STRING) ) {
173
173
                return FALSE;
174
174
        }
175
 
        
 
175
 
176
176
        return sieve_validator_argument_activate(valdtr, cmd, arg, FALSE);
177
177
}
178
178
 
179
 
/* 
180
 
 * Code generation 
 
179
/*
 
180
 * Code generation
181
181
 */
182
182
 
183
183
static bool cmd_test_mailbox_generate
184
184
(const struct sieve_codegen_env *cgenv, struct sieve_command *cmd)
185
185
{
186
186
        struct cmd_test_mailbox_context_data *ctx_data =
187
 
                (struct cmd_test_mailbox_context_data *) cmd->data; 
 
187
                (struct cmd_test_mailbox_context_data *) cmd->data;
188
188
 
189
189
        i_assert( ctx_data->mailbox_op < MAILBOX_OP_LAST );
190
 
        
 
190
 
191
191
        /* Emit operation */
192
192
        sieve_operation_emit(cgenv->sbin, cmd->ext,
193
193
                test_mailbox_operations[ctx_data->mailbox_op]);
194
 
                
 
194
 
195
195
        /* Generate arguments */
196
196
        if ( !sieve_generate_arguments(cgenv, cmd, NULL) )
197
197
                return FALSE;
199
199
        return TRUE;
200
200
}
201
201
 
202
 
/* 
 
202
/*
203
203
 * Code dump
204
204
 */
205
 
 
 
205
 
206
206
static bool cmd_test_mailbox_operation_dump
207
207
(const struct sieve_dumptime_env *denv, sieve_size_t *address)
208
208
{
209
209
        const struct sieve_operation *op = &denv->oprtn;
210
 
        
 
210
 
211
211
        sieve_code_dumpf(denv, "%s:", sieve_operation_mnemonic(op));
212
 
        
 
212
 
213
213
        sieve_code_descend(denv);
214
 
        
 
214
 
215
215
        return sieve_opr_string_dump(denv, address, "mailbox");
216
216
}
217
217
 
219
219
/*
220
220
 * Intepretation
221
221
 */
222
 
 
 
222
 
223
223
static int cmd_test_mailbox_operation_execute
224
224
(const struct sieve_runtime_env *renv, sieve_size_t *address)
225
225
{
226
226
        const struct sieve_operation *op = &renv->oprtn;
227
227
        string_t *mailbox = NULL;
228
228
 
229
 
        /* 
230
 
         * Read operands 
 
229
        /*
 
230
         * Read operands
231
231
         */
232
232
 
233
233
        /* Index */
240
240
        /*
241
241
         * Perform operation
242
242
         */
243
 
                
 
243
 
244
244
        sieve_runtime_trace
245
245
                (renv, "%s %s:", sieve_operation_mnemonic(op), str_c(mailbox));
246
246