Re: [feature request] emacs: use `notmuch insert` for FCC
[notmuch-archives.git] / 3a / bd984d102e0ff141bb4df03874056977587f7a
1 Return-Path: <tomi.ollila@iki.fi>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5  by arlo.cworth.org (Postfix) with ESMTP id D56076DE1B22\r
6  for <notmuch@notmuchmail.org>; Sat,  2 Jan 2016 03:27:49 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at cworth.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.676\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0.676 tagged_above=-999 required=5 tests=[AWL=0.024, \r
12  SPF_NEUTRAL=0.652] autolearn=disabled\r
13 Received: from arlo.cworth.org ([127.0.0.1])\r
14  by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024)\r
15  with ESMTP id dkroVeIZtIqU for <notmuch@notmuchmail.org>;\r
16  Sat,  2 Jan 2016 03:27:46 -0800 (PST)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18  by arlo.cworth.org (Postfix) with ESMTP id A58C66DE1B1D\r
19  for <notmuch@notmuchmail.org>; Sat,  2 Jan 2016 03:27:44 -0800 (PST)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21  by guru.guru-group.fi (Postfix) with ESMTP id D286310008D;\r
22  Sat,  2 Jan 2016 13:28:02 +0200 (EET)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: J Farkas <jf.hyqohaczlksw4tx6ae@l2015aftruuq.dns007.net>,\r
25  notmuch@notmuchmail.org\r
26 Subject: Re: [PATCH] cli/insert: do not lose the SMTP envelope\r
27 In-Reply-To: <1451647279.42.86b0a8ab@201601.l2015aftruuq.dns007.net>\r
28 References: <1451647279.42.86b0a8ab@201601.l2015aftruuq.dns007.net>\r
29 User-Agent: Notmuch/0.21+32~g73439f8 (http://notmuchmail.org) Emacs/24.3.1\r
30  (x86_64-unknown-linux-gnu)\r
31 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
32  $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
33  !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
34 Date: Sat, 02 Jan 2016 13:28:02 +0200\r
35 Message-ID: <m2a8oob4ql.fsf@guru.guru-group.fi>\r
36 MIME-Version: 1.0\r
37 Content-Type: text/plain\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.20\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42  <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <https://notmuchmail.org/mailman/options/notmuch>,\r
44  <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch/>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <https://notmuchmail.org/mailman/listinfo/notmuch>,\r
49  <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Sat, 02 Jan 2016 11:27:50 -0000\r
51 \r
52 On Fri, Jan 01 2016, J Farkas <jf.hyqohaczlksw4tx6ae@l2015aftruuq.dns007.net> wrote:\r
53 \r
54 > From: Janos Farkas <chexum+dev@gmail.com>\r
55 > Subject: [PATCH] cli/insert: do not lose the SMTP envelope\r
56 >\r
57 > Make sure we store the envelope sender/recipient if provided by\r
58 > qmail-command(8) in $RPLINE and $DTLINE.\r
59 > ---\r
60 \r
61 Probably good feature, but like\r
62 http://www.qmail.org/man/man8/qmail-command.html \r
63 says:\r
64 \r
65           qmail-local supplies several useful environment variables to\r
66           command.  WARNING: These environment variables are not\r
67           quoted.  They may contain special characters.  They are\r
68           under the control of a possibly malicious remote user.\r
69 \r
70 Should we check that the contents of RPLINE and DTLINE are well-formed\r
71 before writing these to the mail files ?\r
72 \r
73 Tomi\r
74 \r
75 \r
76 > I just realised that the messages delivered directly into maildir don't have\r
77 > the usual envelope addresses that qmail provides.  This is a piece of\r
78 > information that's important to (at least my) troubleshooting, so I created a\r
79 > patch that seems to work well, applies cleanly to master (and 0.21), and\r
80 > provided a NEWS entry should it be necessary.\r
81 >\r
82 >  NEWS             |  9 +++++++++\r
83 >  notmuch-insert.c | 28 ++++++++++++++++++++++++++++\r
84 >  2 files changed, 37 insertions(+)\r
85 >\r
86 > diff --git a/NEWS b/NEWS\r
87 > index 6681699..13d45c8 100644\r
88 > --- a/NEWS\r
89 > +++ b/NEWS\r
90 > @@ -1,3 +1,12 @@\r
91 > +\r
92 > +\r
93 > +`notmuch insert` records the envelope addresses if available\r
94 > +\r
95 > +  If the caller provides this information as qmail-command(8) does in\r
96 > +  the RPLINE and DTLINE environment variables, then notmuch insert will\r
97 > +  record it in the maildir file.\r
98 > +\r
99 > +\r
100 >  Notmuch 0.21 (2015-10-29)\r
101 >  =========================\r
102 >  \r
103 > diff --git a/notmuch-insert.c b/notmuch-insert.c\r
104 > index 5205c17..ecc0fa0 100644\r
105 > --- a/notmuch-insert.c\r
106 > +++ b/notmuch-insert.c\r
107 > @@ -284,6 +284,26 @@ copy_fd (int fdout, int fdin)\r
108 >  }\r
109 >  \r
110 >  /*\r
111 > + * Write zero (and LF) terminated string to the output fd.  It's expected to\r
112 > + * come from getenv(), so it's not checked for correctness.  NULL or empty\r
113 > + * string is ignored, successfully.\r
114 > + * Return TRUE on success, FALSE on errors.\r
115 > + */\r
116 > +static notmuch_bool_t\r
117 > +write_header (int fdout, const char *hdr)\r
118 > +{\r
119 > +    ssize_t written,to_write;\r
120 > +\r
121 > +    if (hdr && (to_write = strlen (hdr))) {\r
122 > +        written = write (fdout, hdr, to_write);\r
123 > +     if (written != to_write)\r
124 > +         return FALSE;\r
125 > +    }\r
126 > +\r
127 > +    return TRUE;\r
128 > +}\r
129 > +\r
130 > +/*\r
131 >   * Write fdin to a new temp file in maildir/tmp, return full path to\r
132 >   * the file, or NULL on errors.\r
133 >   */\r
134 > @@ -297,6 +317,14 @@ maildir_write_tmp (const void *ctx, int fdin, const char *maildir)\r
135 >      if (fdout < 0)\r
136 >       return NULL;\r
137 >  \r
138 > +    /* maildir(5) suggests the message should start with a Return-Path\r
139 > +     * and Delivered-To lines.  qmail-local(8) supplies these.\r
140 > +     */\r
141 > +    if (! write_header(fdout, getenv("RPLINE")))\r
142 > +     goto FAIL;\r
143 > +    if (! write_header(fdout, getenv("DTLINE")))\r
144 > +     goto FAIL;\r
145 > +\r
146 >      if (! copy_fd (fdout, fdin))\r
147 >       goto FAIL;\r
148 >  \r
149 > -- \r
150 > 2.6.3\r
151 >\r
152 > _______________________________________________\r
153 > notmuch mailing list\r
154 > notmuch@notmuchmail.org\r
155 > https://notmuchmail.org/mailman/listinfo/notmuch\r