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

« back to all changes in this revision

Viewing changes to pigeonhole/src/lib-sieve/cmd-require.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"
6
6
#include "sieve-common.h"
7
7
#include "sieve-commands.h"
8
8
#include "sieve-extensions.h"
9
 
#include "sieve-validator.h" 
 
9
#include "sieve-validator.h"
10
10
#include "sieve-generator.h"
11
11
 
12
 
/* 
 
12
/*
13
13
 * Require command
14
14
 *
15
 
 * Syntax 
 
15
 * Syntax
16
16
 *   Syntax: require <capabilities: string-list>
17
17
 */
18
18
 
19
19
static bool cmd_require_validate
20
20
        (struct sieve_validator *valdtr, struct sieve_command *cmd);
21
21
 
22
 
const struct sieve_command_def cmd_require = { 
23
 
        "require", 
24
 
        SCT_COMMAND, 
 
22
const struct sieve_command_def cmd_require = {
 
23
        "require",
 
24
        SCT_COMMAND,
25
25
        1, 0, FALSE, FALSE,
26
 
        NULL, NULL, 
27
 
        cmd_require_validate, 
 
26
        NULL, NULL,
 
27
        cmd_require_validate,
28
28
        NULL, NULL, NULL
29
29
};
30
 
 
31
 
/* 
32
 
 * Validation 
 
30
 
 
31
/*
 
32
 * Validation
33
33
 */
34
34
 
35
35
static bool cmd_require_validate
36
 
(struct sieve_validator *valdtr, struct sieve_command *cmd) 
 
36
(struct sieve_validator *valdtr, struct sieve_command *cmd)
37
37
{
38
38
        bool result = TRUE;
39
39
        struct sieve_ast_argument *arg;
40
40
        struct sieve_command *prev = sieve_command_prev(cmd);
41
 
        
 
41
 
42
42
        /* Check valid command placement */
43
43
        if ( !sieve_command_is_toplevel(cmd) ||
44
44
                ( !sieve_command_is_first(cmd) && prev != NULL &&
45
 
                        !sieve_command_is(prev, cmd_require) ) ) 
46
 
        {       
47
 
                sieve_command_validate_error(valdtr, cmd, 
 
45
                        !sieve_command_is(prev, cmd_require) ) )
 
46
        {
 
47
                sieve_command_validate_error(valdtr, cmd,
48
48
                        "require commands can only be placed at top level "
49
49
                        "at the beginning of the file");
50
50
                return FALSE;
51
51
        }
52
 
        
 
52
 
53
53
        /* Check argument and load specified extension(s) */
54
54
 
55
55
        arg = cmd->first_positional;
56
56
        if ( sieve_ast_argument_type(arg) == SAAT_STRING ) {
57
57
                /* Single string */
58
58
                const struct sieve_extension *ext = sieve_validator_extension_load_by_name
59
 
                        (valdtr, cmd, arg, sieve_ast_argument_strc(arg));       
 
59
                        (valdtr, cmd, arg, sieve_ast_argument_strc(arg));
60
60
 
61
61
                if ( ext == NULL ) result = FALSE;
62
 
                
 
62
 
63
63
        } else if ( sieve_ast_argument_type(arg) == SAAT_STRING_LIST ) {
64
64
                /* String list */
65
65
                struct sieve_ast_argument *stritem = sieve_ast_strlist_first(arg);
66
 
                
 
66
 
67
67
                while ( stritem != NULL ) {
68
68
                        const struct sieve_extension *ext = sieve_validator_extension_load_by_name
69
69
                                (valdtr, cmd, stritem, sieve_ast_strlist_strc(stritem));
70
70
 
71
71
                        if ( ext == NULL ) result = FALSE;
72
 
        
 
72
 
73
73
                        stritem = sieve_ast_strlist_next(stritem);
74
74
                }
75
75
        } else {
76
76
                /* Something else */
77
 
                sieve_argument_validate_error(valdtr, arg, 
 
77
                sieve_argument_validate_error(valdtr, arg,
78
78
                        "the require command accepts a single string or string list argument, "
79
 
                        "but %s was found", 
 
79
                        "but %s was found",
80
80
                        sieve_ast_argument_name(arg));
81
81
                return FALSE;
82
82
        }
83
 
         
 
83
 
84
84
        return result;
85
85
}