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

« back to all changes in this revision

Viewing changes to src/lib-lda/mail-send.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) 2005-2011 Dovecot authors, see the included COPYING file */
 
1
/* Copyright (c) 2005-2012 Dovecot authors, see the included COPYING file */
2
2
 
3
3
#include "lib.h"
4
4
#include "ioloop.h"
56
56
    struct istream *input;
57
57
    struct smtp_client *smtp_client;
58
58
    FILE *f;
59
 
    struct message_size hdr_size;
60
59
    const char *return_addr, *hdr;
61
60
    const unsigned char *data;
62
61
    const char *value, *msgid, *orig_msgid, *boundary;
100
99
    fprintf(f, "To: <%s>\r\n", return_addr);
101
100
    fprintf(f, "MIME-Version: 1.0\r\n");
102
101
    fprintf(f, "Content-Type: "
103
 
            "multipart/report; report-type=disposition-notification;\r\n"
104
 
            "\tboundary=\"%s\"\r\n", boundary);
 
102
            "multipart/report; report-type=%s;\r\n"
 
103
            "\tboundary=\"%s\"\r\n",
 
104
            ctx->dsn ? "delivery-status" : "disposition-notification",
 
105
            boundary);
105
106
 
106
107
    str = t_str_new(256);
107
108
    var_expand(str, ctx->set->rejection_subject,
123
124
               get_var_expand_table(mail, reason, recipient));
124
125
    fprintf(f, "%s\r\n", str_c(str));
125
126
 
126
 
    /* MDN status report */
127
 
    fprintf(f, "--%s\r\n"
128
 
            "Content-Type: message/disposition-notification\r\n\r\n",
129
 
            boundary);
130
 
    fprintf(f, "Reporting-UA: %s; Dovecot Mail Delivery Agent\r\n",
131
 
            ctx->set->hostname);
132
 
    if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0)
133
 
            fprintf(f, "Original-Recipient: rfc822; %s\r\n", hdr);
134
 
    fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient);
 
127
    if (ctx->dsn) {
 
128
            /* DSN status report: For LDA rejects. currently only used when
 
129
               user is out of quota */
 
130
            fprintf(f, "--%s\r\n"
 
131
                    "Content-Type: message/delivery-status\r\n\r\n",
 
132
                    boundary);
 
133
            fprintf(f, "Reporting-MTA: dns; %s\r\n",
 
134
                    ctx->set->hostname);
 
135
            if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0)
 
136
                    fprintf(f, "Original-Recipient: rfc822; %s\r\n", hdr);
 
137
            fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient);
 
138
            fprintf(f, "Action: failed\r\n");
 
139
            fprintf(f, "Status: %s\r\n", ctx->mailbox_full ? "5.2.2" : "5.2.0");
 
140
    } else {
 
141
            /* MDN status report: For Sieve "reject" */
 
142
            fprintf(f, "--%s\r\n"
 
143
                    "Content-Type: message/disposition-notification\r\n\r\n",
 
144
                    boundary);
 
145
            fprintf(f, "Reporting-UA: %s; Dovecot Mail Delivery Agent\r\n",
 
146
                    ctx->set->hostname);
 
147
            if (mail_get_first_header(mail, "Original-Recipient", &hdr) > 0)
 
148
                    fprintf(f, "Original-Recipient: rfc822; %s\r\n", hdr);
 
149
            fprintf(f, "Final-Recipient: rfc822; %s\r\n", recipient);
135
150
 
136
 
    if (orig_msgid != NULL)
137
 
        fprintf(f, "Original-Message-ID: %s\r\n", orig_msgid);
138
 
    fprintf(f, "Disposition: "
139
 
            "automatic-action/MDN-sent-automatically; deleted\r\n");
 
151
            if (orig_msgid != NULL)
 
152
                    fprintf(f, "Original-Message-ID: %s\r\n", orig_msgid);
 
153
            fprintf(f, "Disposition: "
 
154
                    "automatic-action/MDN-sent-automatically; deleted\r\n");
 
155
    }
140
156
    fprintf(f, "\r\n");
141
157
 
142
158
    /* original message's headers */
143
159
    fprintf(f, "--%s\r\nContent-Type: message/rfc822\r\n\r\n", boundary);
144
160
 
145
 
    if (mail_get_stream(mail, &hdr_size, NULL, &input) == 0) {
 
161
    if (mail_get_hdr_stream(mail, NULL, &input) == 0) {
146
162
            /* Note: If you add more headers, they need to be sorted.
147
163
               We'll drop Content-Type because we're not including the message
148
164
               body, and having a multipart Content-Type may confuse some