~james-page/ubuntu/raring/dovecot/autopkgtest

« back to all changes in this revision

Viewing changes to src/doveadm/dsync/test-dsync-common.c

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-06-11 11:11:54 UTC
  • mfrom: (1.15.2) (4.1.27 sid)
  • Revision ID: package-import@ubuntu.com-20120611111154-678cwbdj6ktgsv1h
Tags: 1:2.1.7-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/{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/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 dovecot >= 2.0.0.
  + d/control: Drop B-D on systemd.
* Dropped changes:
  + d/patches/fix-racey-restart.patch: part of 2.1.x, no longer required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (c) 2009-2012 Dovecot authors, see the included COPYING file */
 
2
 
 
3
#include "lib.h"
 
4
#include "array.h"
 
5
#include "hex-binary.h"
 
6
#include "sha1.h"
 
7
#include "dsync-data.h"
 
8
#include "test-dsync-common.h"
 
9
 
 
10
const guid_128_t test_mailbox_guid1 = {
 
11
        0x12, 0x34, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef,
 
12
        0x21, 0x43, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe
 
13
};
 
14
 
 
15
const guid_128_t test_mailbox_guid2 = {
 
16
        0xa3, 0xbd, 0x78, 0x24, 0xde, 0xfe, 0x08, 0xf7,
 
17
        0xac, 0xc7, 0xca, 0x8c, 0xe7, 0x39, 0xdb, 0xca
 
18
};
 
19
 
 
20
bool dsync_messages_equal(const struct dsync_message *m1,
 
21
                          const struct dsync_message *m2)
 
22
{
 
23
        unsigned int i;
 
24
 
 
25
        if (strcmp(m1->guid, m2->guid) != 0 ||
 
26
            m1->uid != m2->uid || m1->flags != m2->flags ||
 
27
            m1->modseq != m2->modseq || m1->save_date != m2->save_date)
 
28
                return FALSE;
 
29
 
 
30
        if (m1->keywords == m2->keywords)
 
31
                return TRUE;
 
32
        if (m1->keywords == NULL)
 
33
                return m2->keywords == NULL || m2->keywords[0] == NULL;
 
34
        if (m2->keywords == NULL)
 
35
                return m1->keywords[0] == NULL;
 
36
 
 
37
        for (i = 0; m1->keywords[i] != NULL && m2->keywords[i] != NULL; i++) {
 
38
                if (strcasecmp(m1->keywords[i], m2->keywords[i]) != 0)
 
39
                        return FALSE;
 
40
        }
 
41
        return m1->keywords[i] == NULL && m2->keywords[i] == NULL;
 
42
}
 
43
 
 
44
bool dsync_mailboxes_equal(const struct dsync_mailbox *box1,
 
45
                           const struct dsync_mailbox *box2)
 
46
{
 
47
        const struct mailbox_cache_field *f1 = NULL, *f2 = NULL;
 
48
        unsigned int i, f1_count = 0, f2_count = 0;
 
49
 
 
50
        if (strcmp(box1->name, box2->name) != 0 ||
 
51
            box1->name_sep != box2->name_sep ||
 
52
            memcmp(box1->mailbox_guid.guid, box2->mailbox_guid.guid,
 
53
                   sizeof(box1->mailbox_guid.guid)) != 0 ||
 
54
            box1->uid_validity != box2->uid_validity ||
 
55
            box1->uid_next != box2->uid_next ||
 
56
            box1->highest_modseq != box2->highest_modseq)
 
57
                return FALSE;
 
58
 
 
59
        if (array_is_created(&box1->cache_fields))
 
60
                f1 = array_get(&box1->cache_fields, &f1_count);
 
61
        if (array_is_created(&box2->cache_fields))
 
62
                f2 = array_get(&box2->cache_fields, &f2_count);
 
63
        if (f1_count != f2_count)
 
64
                return FALSE;
 
65
        for (i = 0; i < f1_count; i++) {
 
66
                if (strcmp(f1[i].name, f2[i].name) != 0 ||
 
67
                    f1[i].decision != f2[i].decision ||
 
68
                    f1[i].last_used != f2[i].last_used)
 
69
                        return FALSE;
 
70
        }
 
71
        return TRUE;
 
72
}
 
73
 
 
74
void mail_generate_guid_128_hash(const char *guid, guid_128_t guid_128_r)
 
75
{
 
76
        unsigned char sha1_sum[SHA1_RESULTLEN];
 
77
 
 
78
        sha1_get_digest(guid, strlen(guid), sha1_sum);
 
79
        memcpy(guid_128_r, sha1_sum, GUID_128_SIZE);
 
80
}