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

« back to all changes in this revision

Viewing changes to libsieve/src/lib-sieve/plugins/variables/ext-variables-dump.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
 
 
7
#include "sieve-common.h"
 
8
#include "sieve-dump.h"
 
9
#include "sieve-binary.h"
 
10
#include "sieve-code.h"
 
11
 
 
12
#include "ext-variables-common.h"
 
13
#include "ext-variables-dump.h"
 
14
 
 
15
/*
 
16
 * Code dumper extension
 
17
 */
 
18
 
 
19
static void ext_variables_code_dumper_free
 
20
        (struct sieve_code_dumper *dumper, void *context);
 
21
 
 
22
const struct sieve_code_dumper_extension variables_dump_extension = {
 
23
        &variables_extension,
 
24
        ext_variables_code_dumper_free
 
25
};
 
26
 
 
27
/*
 
28
 * Code dump context
 
29
 */
 
30
 
 
31
struct ext_variables_dump_context {
 
32
        struct sieve_variable_scope *main_scope;
 
33
        ARRAY_DEFINE(ext_scopes, struct sieve_variable_scope *);
 
34
};
 
35
 
 
36
static void ext_variables_code_dumper_free
 
37
(struct sieve_code_dumper *dumper ATTR_UNUSED, void *context)
 
38
{
 
39
        struct ext_variables_dump_context *dctx = 
 
40
                (struct ext_variables_dump_context *) context;
 
41
 
 
42
        if ( dctx == NULL || dctx->main_scope == NULL )
 
43
                return;
 
44
 
 
45
        sieve_variable_scope_unref(&dctx->main_scope);
 
46
}
 
47
 
 
48
static struct ext_variables_dump_context *ext_variables_dump_get_context
 
49
        (const struct sieve_dumptime_env *denv)
 
50
{
 
51
        struct sieve_code_dumper *dumper = denv->cdumper;
 
52
        struct ext_variables_dump_context *dctx = sieve_dump_extension_get_context
 
53
                (dumper, &variables_extension);
 
54
        pool_t pool;
 
55
 
 
56
        if ( dctx == NULL ) {
 
57
                /* Create dumper context */
 
58
                pool = sieve_code_dumper_pool(dumper);
 
59
                dctx = p_new(pool, struct ext_variables_dump_context, 1);
 
60
                p_array_init(&dctx->ext_scopes, pool, sieve_extensions_get_count());
 
61
        
 
62
                sieve_dump_extension_set_context(dumper, &variables_extension, dctx);
 
63
        }
 
64
 
 
65
        return dctx;
 
66
 
67
 
 
68
bool ext_variables_code_dump
 
69
(const struct sieve_dumptime_env *denv, sieve_size_t *address)
 
70
{
 
71
        struct ext_variables_dump_context *dctx;
 
72
        struct sieve_variable_scope *main_scope;
 
73
        unsigned int i, scope_size;
 
74
        sieve_size_t pc;
 
75
        int end_offset;
 
76
        
 
77
        sieve_code_mark(denv);
 
78
        if ( !sieve_binary_read_unsigned(denv->sbin, address, &scope_size) )
 
79
                return FALSE;
 
80
                
 
81
        pc = *address;  
 
82
        if ( !sieve_binary_read_offset(denv->sbin, address, &end_offset) )
 
83
                return FALSE;
 
84
        
 
85
        main_scope = sieve_variable_scope_create(NULL);
 
86
        
 
87
        sieve_code_dumpf(denv, "SCOPE [%u] (end: %08x)", 
 
88
                scope_size, (unsigned int) (pc + end_offset));
 
89
        
 
90
        /* Read main variable scope */
 
91
        
 
92
        for ( i = 0; i < scope_size; i++ ) {
 
93
                string_t *identifier;
 
94
 
 
95
                sieve_code_mark(denv);
 
96
                if (!sieve_binary_read_string(denv->sbin, address, &identifier) ) {
 
97
                        return FALSE;
 
98
                }
 
99
                
 
100
                sieve_code_dumpf(denv, "%3d: '%s'", i, str_c(identifier));
 
101
                
 
102
                (void) sieve_variable_scope_declare(main_scope, str_c(identifier));
 
103
        }
 
104
        
 
105
        dctx = ext_variables_dump_get_context(denv);
 
106
        dctx->main_scope = main_scope;
 
107
        
 
108
        return TRUE;
 
109
}
 
110
 
 
111
/*
 
112
 * Scope registry
 
113
 */
 
114
 
 
115
void sieve_ext_variables_dump_set_scope
 
116
(const struct sieve_dumptime_env *denv, const struct sieve_extension *ext, 
 
117
        struct sieve_variable_scope *scope)
 
118
{
 
119
        struct ext_variables_dump_context *dctx = ext_variables_dump_get_context(denv);
 
120
 
 
121
        array_idx_set(&dctx->ext_scopes, (unsigned int) SIEVE_EXT_ID(ext), &scope);     
 
122
}
 
123
 
 
124
/*
 
125
 * Variable identifier dump
 
126
 */
 
127
 
 
128
const char *ext_variables_dump_get_identifier
 
129
(const struct sieve_dumptime_env *denv, const struct sieve_extension *ext,
 
130
        unsigned int index)
 
131
{
 
132
        struct ext_variables_dump_context *dctx = ext_variables_dump_get_context(denv); 
 
133
        struct sieve_variable_scope *scope;
 
134
        struct sieve_variable *var;
 
135
 
 
136
        if ( ext == NULL )
 
137
                scope = dctx->main_scope;
 
138
        else {
 
139
                struct sieve_variable_scope *const *ext_scope;
 
140
                int ext_id = SIEVE_EXT_ID(ext);
 
141
 
 
142
                if  ( ext_id < 0 || ext_id >= (int) array_count(&dctx->ext_scopes) )
 
143
                        return NULL;
 
144
        
 
145
                ext_scope = array_idx(&dctx->ext_scopes, (unsigned int) ext_id);
 
146
                scope = *ext_scope;                     
 
147
        }
 
148
 
 
149
        if ( scope == NULL )
 
150
                return NULL;
 
151
                        
 
152
        var = sieve_variable_scope_get_indexed(scope, index);
 
153
        
 
154
        return var->identifier;
 
155
}
 
156