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

« back to all changes in this revision

Viewing changes to src/lib-storage/index/maildir/maildir-mail.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) 2003-2012 Dovecot authors, see the included COPYING file */
 
1
/* Copyright (c) 2003-2013 Dovecot authors, see the included COPYING file */
2
2
 
3
3
#include "lib.h"
4
4
#include "istream.h"
125
125
 
126
126
        if (imail->data.stream != NULL) {
127
127
                mail->transaction->stats.fstat_lookup_count++;
128
 
                stp = i_stream_stat(imail->data.stream, FALSE);
129
 
                if (stp == NULL)
 
128
                if (i_stream_stat(imail->data.stream, FALSE, &stp) < 0)
130
129
                        return -1;
131
130
                *st_r = *stp;
132
131
        } else if (!mail->saving) {
201
200
        /* one reason this could happen is if we delayed opening
202
201
           dovecot-uidlist and we're trying to open a mail that got recently
203
202
           expunged. Let's test this theory first: */
204
 
        (void)mail_index_refresh(mbox->box.index);
 
203
        mail_index_refresh(mbox->box.index);
205
204
        view = mail_index_view_open(mbox->box.index);
206
205
        exists = mail_index_lookup_seq(view, mail->uid, &seq);
207
206
        mail_index_view_close(&view);
476
475
        struct index_mail *mail = (struct index_mail *)_mail;
477
476
        struct maildir_mailbox *mbox = (struct maildir_mailbox *)_mail->box;
478
477
        const char *path, *fname = NULL, *end, *guid, *uidl, *order;
 
478
        struct stat st;
479
479
 
480
480
        switch (field) {
481
481
        case MAIL_FETCH_GUID:
496
496
                if (guid != NULL) {
497
497
                        if (*guid != '\0') {
498
498
                                *value_r = mail->data.guid =
499
 
                                        p_strdup(mail->data_pool, guid);
 
499
                                        p_strdup(mail->mail.data_pool, guid);
500
500
                                return 0;
501
501
                        }
502
502
 
504
504
                                "Maildir %s: Corrupted dovecot-uidlist: "
505
505
                                "UID %u had empty GUID, clearing it",
506
506
                                mailbox_get_path(_mail->box), _mail->uid);
507
 
                        maildir_uidlist_set_ext(mbox->uidlist, _mail->uid,
508
 
                                MAILDIR_UIDLIST_REC_EXT_GUID, NULL);
 
507
                        maildir_uidlist_unset_ext(mbox->uidlist, _mail->uid,
 
508
                                MAILDIR_UIDLIST_REC_EXT_GUID);
509
509
                }
510
510
 
511
511
                /* default to base filename: */
533
533
                }
534
534
                end = strchr(fname, MAILDIR_INFO_SEP);
535
535
                mail->data.filename = end == NULL ?
536
 
                        p_strdup(mail->data_pool, fname) :
537
 
                        p_strdup_until(mail->data_pool, fname, end);
 
536
                        p_strdup(mail->mail.data_pool, fname) :
 
537
                        p_strdup_until(mail->mail.data_pool, fname, end);
538
538
                *value_r = mail->data.filename;
539
539
                return 0;
540
540
        case MAIL_FETCH_UIDL_BACKEND:
548
548
                        return maildir_mail_get_special(_mail,
549
549
                                        MAIL_FETCH_UIDL_FILE_NAME, value_r);
550
550
                } else {
551
 
                        *value_r = p_strdup(mail->data_pool, uidl);
 
551
                        *value_r = p_strdup(mail->mail.data_pool, uidl);
552
552
                }
553
553
                return 0;
554
554
        case MAIL_FETCH_POP3_ORDER:
557
557
                if (order == NULL) {
558
558
                        *value_r = "";
559
559
                } else {
560
 
                        *value_r = p_strdup(mail->data_pool, order);
 
560
                        *value_r = p_strdup(mail->mail.data_pool, order);
561
561
                }
562
562
                return 0;
 
563
        case MAIL_FETCH_REFCOUNT:
 
564
                if (maildir_mail_stat(_mail, &st) < 0)
 
565
                        return -1;
 
566
                *value_r = p_strdup_printf(mail->mail.data_pool, "%lu",
 
567
                                           (unsigned long)st.st_nlink);
 
568
                return 0;
563
569
        default:
564
570
                return index_mail_get_special(_mail, field, value_r);
565
571
        }
585
591
                }
586
592
                if (mail->mail.v.istream_opened != NULL) {
587
593
                        if (mail->mail.v.istream_opened(_mail,
588
 
                                                        &data->stream) < 0)
 
594
                                                        &data->stream) < 0) {
 
595
                                i_stream_unref(&data->stream);
589
596
                                return -1;
 
597
                        }
590
598
                }
591
599
        }
592
600
 
617
625
 
618
626
        if (maildir_uidlist_lookup_ext(mbox->uidlist, mail->uid,
619
627
                                       MAILDIR_UIDLIST_REC_EXT_VSIZE) != NULL) {
620
 
                maildir_uidlist_set_ext(mbox->uidlist, mail->uid,
621
 
                                        MAILDIR_UIDLIST_REC_EXT_VSIZE, NULL);
 
628
                maildir_uidlist_unset_ext(mbox->uidlist, mail->uid,
 
629
                                          MAILDIR_UIDLIST_REC_EXT_VSIZE);
622
630
        }
623
631
        if (maildir_uidlist_lookup_ext(mbox->uidlist, mail->uid,
624
632
                                       MAILDIR_UIDLIST_REC_EXT_PSIZE) != NULL) {
625
 
                maildir_uidlist_set_ext(mbox->uidlist, mail->uid,
626
 
                                        MAILDIR_UIDLIST_REC_EXT_PSIZE, NULL);
 
633
                maildir_uidlist_unset_ext(mbox->uidlist, mail->uid,
 
634
                                          MAILDIR_UIDLIST_REC_EXT_PSIZE);
627
635
        }
628
636
}
629
637
 
630
638
static int
631
 
do_fix_size(struct maildir_mailbox *mbox, const char *path,
632
 
            const char *wrong_key_p)
 
639
do_fix_size(struct maildir_mailbox *mbox, const char *path, char *wrong_key_p)
633
640
{
634
641
        const char *fname, *newpath, *extra, *info, *dir;
635
642
        struct stat st;
680
687
        uoff_t size;
681
688
        char wrong_key;
682
689
 
 
690
        if (mbox->storage->set->maildir_broken_filename_sizes) {
 
691
                /* never try to fix sizes in maildir filenames */
 
692
                return;
 
693
        }
 
694
 
683
695
        if (maildir_sync_lookup(mbox, mail->uid, &flags, &fname) <= 0)
684
696
                return;
685
697
        if (strchr(fname, MAILDIR_EXTRA_SEP) == NULL)
726
738
        index_mail_get_keywords,
727
739
        index_mail_get_keyword_indexes,
728
740
        index_mail_get_modseq,
 
741
        index_mail_get_pvt_modseq,
729
742
        index_mail_get_parts,
730
743
        index_mail_get_date,
731
744
        maildir_mail_get_received_date,
736
749
        index_mail_get_headers,
737
750
        index_mail_get_header_stream,
738
751
        maildir_mail_get_stream,
 
752
        index_mail_get_binary_stream,
739
753
        maildir_mail_get_special,
740
754
        index_mail_get_real_mail,
741
755
        index_mail_update_flags,
742
756
        index_mail_update_keywords,
743
757
        index_mail_update_modseq,
 
758
        index_mail_update_pvt_modseq,
744
759
        maildir_update_pop3_uidl,
745
760
        index_mail_expunge,
746
761
        maildir_mail_set_cache_corrupted,