~james-page/ubuntu/precise/dovecot/upgrade

« back to all changes in this revision

Viewing changes to pigeonhole/src/testsuite/testsuite-arguments.c

  • Committer: James Page
  • Date: 2012-04-04 13:33:43 UTC
  • mfrom: (4.1.26 sid)
  • Revision ID: james.page@canonical.com-20120404133343-p5gnx2l7qfb3pf50
* Merge from Debian testing (LP: #970782), 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/{control,rules}: enable PIE hardening.
  + 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.
  + d/patches/fix-racey-restart.patch: Backported patch from current
    development release which ensures all child processes terminate prior
    to the main dovecot process.
  + debian/patches/CVE-2011-4318.patch: Dropped - applied upstream
  + d/control: Added Pre-Depends: dpkg (>= 1.15.6) to dovecot-dbg to support
    xz compression in Ubuntu.
  + d/control: Demote dovecot-common Recommends: to Suggests: to prevent
    install of extra packages on upgrade.
* d/patches/dovecot-drac.patch: Updated with version for 2.0.x of dovecot.
* [85ae320] Imported Upstream version 2.0.18
* [9cfd1da] Upped standards version to 3.9.3
* [afb4164] Patch to dovecot-core/postinst so that permissions of symlinked
  certificates aren't modified. (Closes: #646508)
  Thanks Michael Kuhn.
* [bf642ee] Patch to enable hardened build flags.  (Closes: #653530)
  Thanks Moritz Muehlenhoff.
* [00b0d0c] Updated pigeonhole to 0.2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 2002-2011 Pigeonhole authors, see the included COPYING file
 
1
/* Copyright (c) 2002-2012 Pigeonhole authors, see the included COPYING file
2
2
 */
3
3
 
4
4
#include "lib.h"
20
20
 
21
21
#include <ctype.h>
22
22
 
23
 
/*
24
 
 * Testsuite string argument
 
23
/* 
 
24
 * Testsuite string argument 
25
25
 */
26
26
 
27
27
static bool arg_testsuite_string_validate
28
 
        (struct sieve_validator *validator, struct sieve_ast_argument **arg,
 
28
        (struct sieve_validator *validator, struct sieve_ast_argument **arg, 
29
29
                struct sieve_command *context);
30
30
 
31
 
const struct sieve_argument_def testsuite_string_argument = {
32
 
        "@testsuite-string",
33
 
        NULL,
34
 
        arg_testsuite_string_validate,
 
31
const struct sieve_argument_def testsuite_string_argument = { 
 
32
        "@testsuite-string", 
 
33
        NULL, 
 
34
        arg_testsuite_string_validate, 
35
35
        NULL, NULL,
36
36
        sieve_arg_catenated_string_generate,
37
37
};
38
38
 
39
39
static bool arg_testsuite_string_validate
40
 
(struct sieve_validator *valdtr, struct sieve_ast_argument **arg,
 
40
(struct sieve_validator *valdtr, struct sieve_ast_argument **arg, 
41
41
        struct sieve_command *cmd)
42
42
{
43
 
        enum { ST_NONE, ST_OPEN, ST_SUBSTITUTION, ST_PARAM, ST_CLOSE } state =
 
43
        enum { ST_NONE, ST_OPEN, ST_SUBSTITUTION, ST_PARAM, ST_CLOSE } state = 
44
44
                ST_NONE;
45
45
        pool_t pool = sieve_ast_pool((*arg)->ast);
46
46
        struct sieve_arg_catenated_string *catstr = NULL;
51
51
        bool result = TRUE;
52
52
        string_t *subs_name = t_str_new(256);
53
53
        string_t *subs_param = t_str_new(256);
54
 
 
 
54
        
55
55
        T_BEGIN {
56
56
                /* Initialize substitution structure */
57
 
 
 
57
        
58
58
                p = strval;
59
59
                strstart = p;
60
60
                while ( result && p < strend ) {
76
76
                                if ( *p == '{' ) {
77
77
                                        state = ST_SUBSTITUTION;
78
78
                                        p++;
79
 
                                } else
 
79
                                } else 
80
80
                                        state = ST_NONE;
81
81
                                break;
82
82
 
83
 
                        /* Got '%{' */
 
83
                        /* Got '%{' */ 
84
84
                        case ST_SUBSTITUTION:
85
 
                                state = ST_PARAM;
 
85
                                state = ST_PARAM;       
86
86
 
87
87
                                while ( *p != '}' && *p != ':' ) {
88
88
                                        if ( !i_isalnum(*p) ) {
89
89
                                                state = ST_NONE;
90
90
                                                break;
91
 
                                        }
 
91
                                        }       
92
92
                                        str_append_c(subs_name, *p);
93
93
                                        p++;
94
94
                                }
95
95
                                break;
96
 
 
 
96
                                
97
97
                        /* Got '%{name' */
98
98
                        case ST_PARAM:
99
99
                                if ( *p == ':' ) {
108
108
 
109
109
                        /* Finished parsing param, expecting '}' */
110
110
                        case ST_CLOSE:
111
 
                                if ( *p == '}' ) {
 
111
                                if ( *p == '}' ) {                              
112
112
                                        struct sieve_ast_argument *strarg;
113
 
 
114
 
                                        /* We now know that the substitution is valid */
115
 
 
 
113
                                
 
114
                                        /* We now know that the substitution is valid */        
 
115
                                        
116
116
                                        if ( catstr == NULL ) {
117
117
                                                catstr = sieve_arg_catenated_string_create(*arg);
118
118
                                        }
119
 
 
120
 
                                        /* Add the substring that is before the substitution to the
 
119
                                
 
120
                                        /* Add the substring that is before the substitution to the 
121
121
                                         * variable-string AST.
122
122
                                         */
123
123
                                        if ( substart > strstart ) {
124
124
                                                string_t *newstr = str_new(pool, substart - strstart);
125
 
                                                str_append_n(newstr, strstart, substart - strstart);
126
 
 
 
125
                                                str_append_n(newstr, strstart, substart - strstart); 
 
126
                                                
127
127
                                                strarg = sieve_ast_argument_string_create_raw
128
128
                                                        ((*arg)->ast, newstr, (*arg)->source_line);
129
129
                                                sieve_arg_catenated_string_add_element(catstr, strarg);
130
 
 
 
130
                                        
131
131
                                                /* Give other substitution extensions a chance to do their work */
132
132
                                                if ( !sieve_validator_argument_activate_super
133
133
                                                        (valdtr, cmd, strarg, FALSE) ) {
135
135
                                                        break;
136
136
                                                }
137
137
                                        }
138
 
 
 
138
                                
139
139
                                        strarg = testsuite_substitution_argument_create
140
 
                                                (valdtr, (*arg)->ast, (*arg)->source_line, str_c(subs_name),
 
140
                                                (valdtr, (*arg)->ast, (*arg)->source_line, str_c(subs_name), 
141
141
                                                        str_c(subs_param));
142
 
 
 
142
                                        
143
143
                                        if ( strarg != NULL )
144
144
                                                sieve_arg_catenated_string_add_element(catstr, strarg);
145
145
                                        else {
146
 
                                                sieve_argument_validate_error(valdtr, *arg,
 
146
                                                sieve_argument_validate_error(valdtr, *arg, 
147
147
                                                        "unknown testsuite substitution type '%s'", str_c(subs_name));
148
148
                                        }
149
149
 
150
150
                                        strstart = p + 1;
151
151
                                        substart = strstart;
152
152
 
153
 
                                        p++;
 
153
                                        p++;    
154
154
                                }
155
 
 
156
 
                                /* Finished, reset for the next substitution */
 
155
                
 
156
                                /* Finished, reset for the next substitution */ 
157
157
                                state = ST_NONE;
158
158
                        }
159
159
                }
161
161
 
162
162
        /* Bail out early if substitution is invalid */
163
163
        if ( !result ) return FALSE;
164
 
 
 
164
        
165
165
        /* Check whether any substitutions were found */
166
166
        if ( catstr == NULL ) {
167
167
                /* No substitutions in this string, pass it on to any other substution
169
169
                 */
170
170
                return sieve_validator_argument_activate_super(valdtr, cmd, *arg, TRUE);
171
171
        }
172
 
 
173
 
        /* Add the final substring that comes after the last substitution to the
 
172
        
 
173
        /* Add the final substring that comes after the last substitution to the 
174
174
         * variable-string AST.
175
175
         */
176
176
        if ( strend > strstart ) {
177
177
                struct sieve_ast_argument *strarg;
178
178
                string_t *newstr = str_new(pool, strend - strstart);
179
 
                str_append_n(newstr, strstart, strend - strstart);
 
179
                str_append_n(newstr, strstart, strend - strstart); 
180
180
 
181
181
                strarg = sieve_ast_argument_string_create_raw
182
182
                        ((*arg)->ast, newstr, (*arg)->source_line);
183
183
                sieve_arg_catenated_string_add_element(catstr, strarg);
184
 
 
185
 
                /* Give other substitution extensions a chance to do their work */
 
184
                        
 
185
                /* Give other substitution extensions a chance to do their work */      
186
186
                if ( !sieve_validator_argument_activate_super
187
187
                        (valdtr, cmd, strarg, FALSE) )
188
188
                        return FALSE;
189
 
        }
190
 
 
 
189
        }       
 
190
        
191
191
        return TRUE;
192
192
}