~ubuntu-branches/ubuntu/wily/dovecot/wily

« back to all changes in this revision

Viewing changes to src/lib-imap/imap-seqset.c

  • Committer: Bazaar Package Importer
  • Author(s): CHuck Short, Chuck Short
  • Date: 2009-11-06 00:47:29 UTC
  • mfrom: (4.1.9 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091106004729-i39n7v9e7d4h51f6
Tags: 1:1.2.6-1ubuntu1
* 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 restrictions
    - 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 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
   + debian/patches/dovecot-postfix.conf.diff:
     + 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.
   + debian/rules:
     - Create emtpy stamp.h.in files in dovecot-sieve/ and dovecot-managesieve/
       if they're not there since empty files are not included in the diff.gz 
       file.
   + Add SMTP-AUTH support for Outlook (login auth mechanism)
   + Dropped:
     - debian/patches/security-CVE-2009-3235: Applied upstream.
     - debian/patches/fix-pop3-assertion.dpatch: Applied upstream.
     - dovecot-sieve and dovecot-managesieve: Use the debian patches instead.

  [Chuck Short]
  - Updated dovecot-sieve to 0.1.13.
  - Updated dovecot-managesieve to 0.11.9.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2002-2009 Dovecot authors, see the included COPYING file */
 
2
 
 
3
#include "lib.h"
 
4
#include "imap-seqset.h"
 
5
 
 
6
static uint32_t get_next_number(const char **str)
 
7
{
 
8
        uint32_t num;
 
9
 
 
10
        num = 0;
 
11
        while (**str != '\0') {
 
12
                if (**str < '0' || **str > '9')
 
13
                        break;
 
14
 
 
15
                num = num*10 + (**str - '0');
 
16
                (*str)++;
 
17
        }
 
18
 
 
19
        if (num == (uint32_t)-1) {
 
20
                /* FIXME: ugly hack, we're using this number to mean the
 
21
                   last existing message. In reality UIDs should never get
 
22
                   this high, so we can quite safely just drop this one down. */
 
23
                num--;
 
24
        }
 
25
 
 
26
        return num;
 
27
}
 
28
 
 
29
static int
 
30
get_next_seq_range(const char **str, uint32_t *seq1_r, uint32_t *seq2_r)
 
31
{
 
32
        uint32_t seq1, seq2;
 
33
 
 
34
        if (**str == '*') {
 
35
                /* last message */
 
36
                seq1 = (uint32_t)-1;
 
37
                *str += 1;
 
38
        } else {
 
39
                seq1 = get_next_number(str);
 
40
                if (seq1 == 0)
 
41
                        return -1;
 
42
        }
 
43
 
 
44
        if (**str != ':')
 
45
                seq2 = seq1;
 
46
        else {
 
47
                /* first:last range */
 
48
                *str += 1;
 
49
 
 
50
                if (**str == '*') {
 
51
                        seq2 = (uint32_t)-1;
 
52
                        *str += 1;
 
53
                } else {
 
54
                        seq2 = get_next_number(str);
 
55
                        if (seq2 == 0)
 
56
                                return -1;
 
57
                }
 
58
        }
 
59
 
 
60
        if (seq1 > seq2) {
 
61
                /* swap, as specified by RFC-3501 */
 
62
                *seq1_r = seq2;
 
63
                *seq2_r = seq1;
 
64
        } else {
 
65
                *seq1_r = seq1;
 
66
                *seq2_r = seq2;
 
67
        }
 
68
        return 0;
 
69
}
 
70
 
 
71
int imap_seq_set_parse(const char *str, ARRAY_TYPE(seq_range) *dest)
 
72
{
 
73
        uint32_t seq1, seq2;
 
74
 
 
75
        while (*str != '\0') {
 
76
                if (get_next_seq_range(&str, &seq1, &seq2) < 0)
 
77
                        return -1;
 
78
                seq_range_array_add_range(dest, seq1, seq2);
 
79
 
 
80
                if (*str == ',')
 
81
                        str++;
 
82
                else if (*str != '\0')
 
83
                        return -1;
 
84
        }
 
85
        return 0;
 
86
}
 
87
 
 
88
int imap_seq_range_parse(const char *str, uint32_t *seq1_r, uint32_t *seq2_r)
 
89
{
 
90
        if (get_next_seq_range(&str, seq1_r, seq2_r) < 0)
 
91
                return -1;
 
92
        return *str == '\0' ? 0 : -1;
 
93
}