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

« back to all changes in this revision

Viewing changes to src/util/logview.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:
21
21
                (((uint32_t)buf[0] & 0x7f) << 23);
22
22
}
23
23
 
24
 
static void dump_hdr(int fd)
 
24
static void dump_hdr(int fd, uint64_t *modseq_r)
25
25
{
26
26
        struct mail_transaction_log_header hdr;
27
27
        ssize_t ret;
43
43
        printf("file seq = %u\n", hdr.file_seq);
44
44
        printf("prev file = %u/%u\n", hdr.prev_file_seq, hdr.prev_file_offset);
45
45
        printf("create stamp = %u\n", hdr.create_stamp);
 
46
        printf("initial modseq = %llu\n",
 
47
               (unsigned long long)hdr.initial_modseq);
 
48
        printf("compat flags = %x\n", hdr.compat_flags);
 
49
        *modseq_r = hdr.initial_modseq;
46
50
}
47
51
 
 
52
static bool
 
53
mail_transaction_header_has_modseq(const struct mail_transaction_header *hdr)
 
54
{
 
55
        switch (hdr->type & MAIL_TRANSACTION_TYPE_MASK) {
 
56
        case MAIL_TRANSACTION_EXPUNGE | MAIL_TRANSACTION_EXPUNGE_PROT:
 
57
                if ((hdr->type & MAIL_TRANSACTION_EXTERNAL) == 0) {
 
58
                        /* ignore expunge requests */
 
59
                        break;
 
60
                }
 
61
        case MAIL_TRANSACTION_APPEND:
 
62
        case MAIL_TRANSACTION_FLAG_UPDATE:
 
63
        case MAIL_TRANSACTION_KEYWORD_UPDATE:
 
64
        case MAIL_TRANSACTION_KEYWORD_RESET:
 
65
                /* these changes increase modseq */
 
66
                return TRUE;
 
67
        }
 
68
        return FALSE;
 
69
}
48
70
static const char *log_record_type(unsigned int type)
49
71
{
50
72
        const char *name;
208
230
}
209
231
 
210
232
static void log_record_print(const struct mail_transaction_header *hdr,
211
 
                             const void *data)
 
233
                             const void *data, uint64_t *modseq)
212
234
{
213
235
        unsigned int size = hdr->size - sizeof(*hdr);
214
236
 
260
282
                printf(" - hdr_size = %u\n", intro->hdr_size);
261
283
                printf(" - record_size = %u\n", intro->record_size);
262
284
                printf(" - record_align = %u\n", intro->record_align);
 
285
                printf(" - flags = %u\n", intro->flags);
263
286
                printf(" - name_size = %u\n", intro->name_size);
264
287
                if (intro->name_size > 0) {
265
 
                        printf(" - name = '%.*s'\n",
266
 
                               intro->name_size, (const char *)(intro+1));
 
288
                        const char *name = (const char *)(intro+1);
 
289
 
 
290
                        printf(" - name = '%.*s'\n", intro->name_size, name);
 
291
                        if (*modseq == 0 && intro->name_size == 6 &&
 
292
                            memcmp(name, "modseq", 6) == 0)
 
293
                                *modseq = 1;
267
294
                }
268
295
                break;
269
296
        }
330
357
        }
331
358
}
332
359
 
333
 
static int dump_record(int fd)
 
360
static int dump_record(int fd, uint64_t *modseq)
334
361
{
335
362
        off_t offset;
336
363
        ssize_t ret;
357
384
                return 0;
358
385
        }
359
386
 
360
 
        printf("record: offset=%"PRIuUOFF_T", type=%s, size=%u\n",
 
387
        printf("record: offset=%"PRIuUOFF_T", type=%s, size=%u",
361
388
               offset, log_record_type(hdr.type), hdr.size);
 
389
        if (*modseq > 0 && mail_transaction_header_has_modseq(&hdr)) {
 
390
                *modseq += 1;
 
391
                printf(", modseq=%llu", (unsigned long long)*modseq);
 
392
        }
 
393
        printf("\n");
362
394
 
363
395
        if (hdr.size < 1024*1024) {
364
396
                unsigned char *buf = t_malloc(hdr.size);
368
400
                        i_fatal("rec data read() %"PRIuSIZE_T" != %"PRIuSIZE_T,
369
401
                                ret, hdr.size - sizeof(hdr));
370
402
                }
371
 
                log_record_print(&hdr, buf);
 
403
                log_record_print(&hdr, buf, modseq);
372
404
        } else {
373
405
                lseek(fd, hdr.size - sizeof(hdr), SEEK_CUR);
374
406
        }
377
409
 
378
410
int main(int argc, const char *argv[])
379
411
{
 
412
        uint64_t modseq;
380
413
        int fd, ret;
381
414
 
382
415
        lib_init();
390
423
                return 1;
391
424
        }
392
425
 
393
 
        dump_hdr(fd);
 
426
        dump_hdr(fd, &modseq);
394
427
        do {
395
428
                T_BEGIN {
396
 
                        ret = dump_record(fd);
 
429
                        ret = dump_record(fd, &modseq);
397
430
                } T_END;
398
431
        } while (ret > 0);
399
432
        return 0;