~ubuntu-branches/ubuntu/trusty/dovecot/trusty-updates

« back to all changes in this revision

Viewing changes to pigeonhole/src/lib-sieve/plugins/include/ext-include-variables.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-01-08 09:35:49 UTC
  • mfrom: (1.15.3) (96.1.1 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20140108093549-814nkqdcxfbvgktg
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"
21
21
#include "ext-include-binary.h"
22
22
#include "ext-include-variables.h"
23
23
 
24
 
/* 
 
24
/*
25
25
 * Variable import-export
26
26
 */
27
 
 
 
27
 
28
28
struct sieve_variable *ext_include_variable_import_global
29
 
(struct sieve_validator *valdtr, struct sieve_command *cmd, 
 
29
(struct sieve_validator *valdtr, struct sieve_command *cmd,
30
30
        const char *variable)
31
31
{
32
32
        const struct sieve_extension *this_ext = cmd->ext;
33
33
        struct sieve_ast *ast = cmd->ast_node->ast;
34
 
        struct ext_include_ast_context *ctx = 
 
34
        struct ext_include_ast_context *ctx =
35
35
                ext_include_get_ast_context(this_ext, ast);
36
36
        struct ext_include_context *ectx = ext_include_get_context(this_ext);
37
37
        struct sieve_variable_scope *local_scope;
38
38
        struct sieve_variable_scope *global_scope = ctx->global_vars;
39
39
        struct sieve_variable *global_var = NULL, *local_var;
40
40
 
41
 
        /* Sanity safeguard */  
 
41
        /* Sanity safeguard */
42
42
        i_assert ( ctx->global_vars != NULL );
43
43
 
44
44
        if ( !sieve_variable_identifier_is_valid(variable) ) {
54
54
        if ( global_var == NULL ) {
55
55
                sieve_command_validate_error(valdtr, cmd,
56
56
                        "declaration of new global variable '%s' exceeds the limit "
57
 
                        "(max variables: %u)", 
 
57
                        "(max variables: %u)",
58
58
                        variable, sieve_variables_get_max_scope_size());
59
59
                return NULL;
60
60
        }
61
 
        
 
61
 
62
62
        /* Import the global variable into the local script scope */
63
63
        local_scope = sieve_ext_variables_get_local_scope(ectx->var_ext, valdtr);
64
64
 
77
77
/*
78
78
 * Binary symbol table
79
79
 */
80
 
 
 
80
 
81
81
bool ext_include_variables_save
82
 
(struct sieve_binary_block *sblock, 
 
82
(struct sieve_binary_block *sblock,
83
83
        struct sieve_variable_scope_binary *global_vars)
84
84
{
85
85
        struct sieve_variable_scope *global_scope =
93
93
 
94
94
        if ( count > 0 ) {
95
95
                unsigned int size, i;
96
 
                struct sieve_variable *const *vars = 
 
96
                struct sieve_variable *const *vars =
97
97
                        sieve_variable_scope_get_variables(global_scope, &size);
98
98
 
99
99
                for ( i = 0; i < size; i++ ) {
107
107
}
108
108
 
109
109
bool ext_include_variables_load
110
 
(const struct sieve_extension *this_ext, struct sieve_binary_block *sblock, 
 
110
(const struct sieve_extension *this_ext, struct sieve_binary_block *sblock,
111
111
        sieve_size_t *offset, struct sieve_variable_scope_binary **global_vars_r)
112
112
{
113
113
        /* Sanity assert */
136
136
                unsigned int i;
137
137
 
138
138
                sieve_binary_dump_sectionf(denv, "Global variables");
139
 
        
 
139
 
140
140
                for ( i = 0; i < size; i++ ) {
141
141
                        sieve_binary_dumpf(denv, "%3d: '%s' \n", i, vars[i]->identifier);
142
 
                }       
 
142
                }
143
143
        }
144
144
 
145
145
        return TRUE;
151
151
 
152
152
bool vnspc_global_variables_validate
153
153
        (struct sieve_validator *valdtr, const struct sieve_variables_namespace *nspc,
154
 
                struct sieve_ast_argument *arg, struct sieve_command *cmd, 
155
 
                ARRAY_TYPE(sieve_variable_name) *var_name, void **var_data, 
 
154
                struct sieve_ast_argument *arg, struct sieve_command *cmd,
 
155
                ARRAY_TYPE(sieve_variable_name) *var_name, void **var_data,
156
156
                bool assignment);
157
157
bool vnspc_global_variables_generate
158
 
        (const struct sieve_codegen_env *cgenv, 
 
158
        (const struct sieve_codegen_env *cgenv,
159
159
                const struct sieve_variables_namespace *nspc,
160
160
                struct sieve_ast_argument *arg, struct sieve_command *cmd, void *var_data);
161
161
 
162
162
static const struct sieve_variables_namespace_def global_variables_namespace = {
163
163
        SIEVE_OBJECT("global", NULL, 0),
164
 
        vnspc_global_variables_validate,  
 
164
        vnspc_global_variables_validate,
165
165
        vnspc_global_variables_generate,
166
166
        NULL, NULL
167
167
};
168
168
 
169
169
 
170
170
bool vnspc_global_variables_validate
171
 
(struct sieve_validator *valdtr, 
 
171
(struct sieve_validator *valdtr,
172
172
        const struct sieve_variables_namespace *nspc, struct sieve_ast_argument *arg,
173
 
        struct sieve_command *cmd ATTR_UNUSED, 
174
 
        ARRAY_TYPE(sieve_variable_name) *var_name, void **var_data, 
 
173
        struct sieve_command *cmd ATTR_UNUSED,
 
174
        ARRAY_TYPE(sieve_variable_name) *var_name, void **var_data,
175
175
        bool assignment ATTR_UNUSED)
176
176
{
177
177
        const struct sieve_extension *this_ext = SIEVE_OBJECT_EXTENSION(nspc);
178
178
        struct sieve_ast *ast = arg->ast;
179
 
        struct ext_include_ast_context *ctx = 
 
179
        struct ext_include_ast_context *ctx =
180
180
                ext_include_get_ast_context(this_ext, ast);
181
181
        struct sieve_variable *var = NULL;
182
182
        const struct sieve_variable_name *name_element;
183
183
        const char *variable;
184
184
 
185
 
        /* Sanity safeguard */  
 
185
        /* Sanity safeguard */
186
186
        i_assert ( ctx->global_vars != NULL );
187
187
 
188
188
        /* Check variable name */
189
189
 
190
190
        if ( array_count(var_name) != 2 ) {
191
 
                sieve_argument_validate_error(valdtr, arg, 
 
191
                sieve_argument_validate_error(valdtr, arg,
192
192
                        "invalid variable name within global namespace: "
193
193
                        "encountered sub-namespace");
194
194
                return FALSE;
196
196
 
197
197
        name_element = array_idx(var_name, 1);
198
198
        if ( name_element->num_variable >= 0 ) {
199
 
                sieve_argument_validate_error(valdtr, arg, 
 
199
                sieve_argument_validate_error(valdtr, arg,
200
200
                        "invalid variable name within global namespace: "
201
201
                        "encountered numeric variable name");
202
202
                return FALSE;
203
203
        }
204
 
        
 
204
 
205
205
        variable = str_c(name_element->identifier);
206
206
 
207
207
        /* Get/Declare the variable in the global scope */
209
209
        var = sieve_variable_scope_get_variable(ctx->global_vars, variable, TRUE);
210
210
 
211
211
        if ( var == NULL ) {
212
 
                sieve_argument_validate_error(valdtr, arg, 
 
212
                sieve_argument_validate_error(valdtr, arg,
213
213
                        "(implicit) declaration of new global variable '%s' exceeds the limit "
214
 
                        "(max variables: %u)", variable, 
 
214
                        "(max variables: %u)", variable,
215
215
                        sieve_variables_get_max_scope_size());
216
216
                return FALSE;
217
217
        }
218
 
        
 
218
 
219
219
        *var_data = (void *) var;
220
220
 
221
221
        return TRUE;
222
222
}
223
223
 
224
224
bool vnspc_global_variables_generate
225
 
(const struct sieve_codegen_env *cgenv, 
226
 
        const struct sieve_variables_namespace *nspc,   
227
 
        struct sieve_ast_argument *arg ATTR_UNUSED,     
 
225
(const struct sieve_codegen_env *cgenv,
 
226
        const struct sieve_variables_namespace *nspc,
 
227
        struct sieve_ast_argument *arg ATTR_UNUSED,
228
228
        struct sieve_command *cmd ATTR_UNUSED, void *var_data)
229
229
{
230
230
        const struct sieve_extension *this_ext = SIEVE_OBJECT_EXTENSION(nspc);
231
231
        struct ext_include_context *ectx = ext_include_get_context(this_ext);
232
232
        struct sieve_variable *var = (struct sieve_variable *) var_data;
233
 
        
 
233
 
234
234
        sieve_variables_opr_variable_emit(cgenv->sblock, ectx->var_ext, var);
235
235
 
236
236
        return TRUE;