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

« back to all changes in this revision

Viewing changes to libsieve/src/testsuite/testsuite-arguments.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 "str.h"
 
6
#include "str-sanitize.h"
 
7
#include "array.h"
 
8
 
 
9
#include "sieve-common.h"
 
10
#include "sieve-ast.h"
 
11
#include "sieve-commands.h"
 
12
#include "sieve-code.h"
 
13
#include "sieve-validator.h"
 
14
#include "sieve-generator.h"
 
15
#include "sieve-dump.h"
 
16
 
 
17
#include "testsuite-common.h"
 
18
#include "testsuite-substitutions.h"
 
19
#include "testsuite-arguments.h"
 
20
 
 
21
#include <ctype.h>
 
22
 
 
23
/* 
 
24
 * Testsuite string argument 
 
25
 */
 
26
 
 
27
static bool arg_testsuite_string_validate
 
28
        (struct sieve_validator *validator, struct sieve_ast_argument **arg, 
 
29
                struct sieve_command_context *context);
 
30
 
 
31
const struct sieve_argument testsuite_string_argument = { 
 
32
        "@testsuite-string", 
 
33
        NULL, NULL,
 
34
        arg_testsuite_string_validate, 
 
35
        NULL, 
 
36
        sieve_arg_catenated_string_generate,
 
37
};
 
38
 
 
39
static bool arg_testsuite_string_validate
 
40
(struct sieve_validator *valdtr, struct sieve_ast_argument **arg, 
 
41
        struct sieve_command_context *cmd)
 
42
{
 
43
        enum { ST_NONE, ST_OPEN, ST_SUBSTITUTION, ST_PARAM, ST_CLOSE } state = 
 
44
                ST_NONE;
 
45
        pool_t pool = sieve_ast_pool((*arg)->ast);
 
46
        struct sieve_arg_catenated_string *catstr = NULL;
 
47
        string_t *str = sieve_ast_argument_str(*arg);
 
48
        const char *p, *strstart, *substart = NULL;
 
49
        const char *strval = (const char *) str_data(str);
 
50
        const char *strend = strval + str_len(str);
 
51
        bool result = TRUE;
 
52
        string_t *subs_name = t_str_new(256);
 
53
        string_t *subs_param = t_str_new(256);
 
54
        
 
55
        T_BEGIN {
 
56
                /* Initialize substitution structure */
 
57
        
 
58
                p = strval;
 
59
                strstart = p;
 
60
                while ( result && p < strend ) {
 
61
                        switch ( state ) {
 
62
 
 
63
                        /* Nothing found yet */
 
64
                        case ST_NONE:
 
65
                                if ( *p == '%' ) {
 
66
                                        substart = p;
 
67
                                        state = ST_OPEN;
 
68
                                        str_truncate(subs_name, 0);
 
69
                                        str_truncate(subs_param, 0);
 
70
                                }
 
71
                                p++;
 
72
                                break;
 
73
 
 
74
                        /* Got '%' */
 
75
                        case ST_OPEN:
 
76
                                if ( *p == '{' ) {
 
77
                                        state = ST_SUBSTITUTION;
 
78
                                        p++;
 
79
                                } else 
 
80
                                        state = ST_NONE;
 
81
                                break;
 
82
 
 
83
                        /* Got '%{' */ 
 
84
                        case ST_SUBSTITUTION:
 
85
                                state = ST_PARAM;       
 
86
 
 
87
                                while ( *p != '}' && *p != ':' ) {
 
88
                                        if ( !i_isalnum(*p) ) {
 
89
                                                state = ST_NONE;
 
90
                                                break;
 
91
                                        }       
 
92
                                        str_append_c(subs_name, *p);
 
93
                                        p++;
 
94
                                }
 
95
                                break;
 
96
                                
 
97
                        /* Got '%{name' */
 
98
                        case ST_PARAM:
 
99
                                if ( *p == ':' ) {
 
100
                                        p++;
 
101
                                        while ( *p != '}' ) {
 
102
                                                str_append_c(subs_param, *p);
 
103
                                                p++;
 
104
                                        }
 
105
                                }
 
106
                                state = ST_CLOSE;
 
107
                                break;
 
108
 
 
109
                        /* Finished parsing param, expecting '}' */
 
110
                        case ST_CLOSE:
 
111
                                if ( *p == '}' ) {                              
 
112
                                        struct sieve_ast_argument *strarg;
 
113
                                
 
114
                                        /* We now know that the substitution is valid */        
 
115
                                        
 
116
                                        if ( catstr == NULL ) {
 
117
                                                catstr = sieve_arg_catenated_string_create(*arg);
 
118
                                        }
 
119
                                
 
120
                                        /* Add the substring that is before the substitution to the 
 
121
                                         * variable-string AST.
 
122
                                         */
 
123
                                        if ( substart > strstart ) {
 
124
                                                string_t *newstr = str_new(pool, substart - strstart);
 
125
                                                str_append_n(newstr, strstart, substart - strstart); 
 
126
                                                
 
127
                                                strarg = sieve_ast_argument_string_create_raw
 
128
                                                        ((*arg)->ast, newstr, (*arg)->source_line);
 
129
                                                sieve_arg_catenated_string_add_element(catstr, strarg);
 
130
                                        
 
131
                                                /* Give other substitution extensions a chance to do their work */
 
132
                                                if ( !sieve_validator_argument_activate_super
 
133
                                                        (valdtr, cmd, strarg, FALSE) ) {
 
134
                                                        result = FALSE;
 
135
                                                        break;
 
136
                                                }
 
137
                                        }
 
138
                                
 
139
                                        strarg = testsuite_substitution_argument_create
 
140
                                                (valdtr, (*arg)->ast, (*arg)->source_line, str_c(subs_name), 
 
141
                                                        str_c(subs_param));
 
142
                                        
 
143
                                        if ( strarg != NULL )
 
144
                                                sieve_arg_catenated_string_add_element(catstr, strarg);
 
145
                                        else {
 
146
                                                sieve_argument_validate_error(valdtr, *arg, 
 
147
                                                        "unknown testsuite substitution type '%s'", str_c(subs_name));
 
148
                                        }
 
149
 
 
150
                                        strstart = p + 1;
 
151
                                        substart = strstart;
 
152
 
 
153
                                        p++;    
 
154
                                }
 
155
                
 
156
                                /* Finished, reset for the next substitution */ 
 
157
                                state = ST_NONE;
 
158
                        }
 
159
                }
 
160
        } T_END;
 
161
 
 
162
        /* Bail out early if substitution is invalid */
 
163
        if ( !result ) return FALSE;
 
164
        
 
165
        /* Check whether any substitutions were found */
 
166
        if ( catstr == NULL ) {
 
167
                /* No substitutions in this string, pass it on to any other substution
 
168
                 * extension.
 
169
                 */
 
170
                return sieve_validator_argument_activate_super(valdtr, cmd, *arg, TRUE);
 
171
        }
 
172
        
 
173
        /* Add the final substring that comes after the last substitution to the 
 
174
         * variable-string AST.
 
175
         */
 
176
        if ( strend > strstart ) {
 
177
                struct sieve_ast_argument *strarg;
 
178
                string_t *newstr = str_new(pool, strend - strstart);
 
179
                str_append_n(newstr, strstart, strend - strstart); 
 
180
 
 
181
                strarg = sieve_ast_argument_string_create_raw
 
182
                        ((*arg)->ast, newstr, (*arg)->source_line);
 
183
                sieve_arg_catenated_string_add_element(catstr, strarg);
 
184
                        
 
185
                /* Give other substitution extensions a chance to do their work */      
 
186
                if ( !sieve_validator_argument_activate_super
 
187
                        (valdtr, cmd, strarg, FALSE) )
 
188
                        return FALSE;
 
189
        }       
 
190
        
 
191
        return TRUE;
 
192
}