Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id 48FAC6DE1A5C for ; Fri, 1 Jan 2016 03:29:42 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: 0.198 X-Spam-Level: X-Spam-Status: No, score=0.198 tagged_above=-999 required=5 tests=[AWL=0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001, TVD_FROM_1=0.999] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jXS4_ur-9qna for ; Fri, 1 Jan 2016 03:29:40 -0800 (PST) X-Greylist: delayed 496 seconds by postgrey-1.35 at arlo; Fri, 01 Jan 2016 03:29:39 PST Received: from know-smtprelay-omc-6.server.virginmedia.net (know-smtprelay-omc-6.server.virginmedia.net [80.0.253.70]) by arlo.cworth.org (Postfix) with ESMTP id C8CBE6DE1642 for ; Fri, 1 Jan 2016 03:29:39 -0800 (PST) Received: from dev.koan19.net ([82.1.197.255]) by know-smtprelay-6-imp with bizsmtp id 0bMM1s00M5X6CWA01bMMZN; Fri, 01 Jan 2016 11:21:21 +0000 X-Originating-IP: [82.1.197.255] X-Spam: 0 X-Authority: v=2.1 cv=P+nH/X0u c=1 sm=1 tr=0 a=D+CNGfzuhY6ArhcYgadsyQ==:117 a=D+CNGfzuhY6ArhcYgadsyQ==:17 a=jxr8AxaCAAAA:8 a=dmPqMsitAAAA:8 a=hov-Noh0Y1sA:10 a=kj9zAlcOel0A:10 a=pGLkceISAAAA:8 a=QS_f28TmvQGgleWyFkgA:9 a=CjuIK1q_8ugA:10 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=l2015aftruuq.dns007.net; i=@l2015aftruuq.dns007.net; q=dns/txt; s=l201512; t=1451647280; h=To : Subject : MIME-Version : Content-Type : From : Message-ID : Date : X-Originating-IP : Subject : From : Date; bh=VzbZWKzDWGaqv+8aF2Q7X1XMCAoFt+JCkczPKyqmkPk=; b=AQM3nYOdP80NIXUNHQubmJ0p/e/m+gC9TV0P2FzGBHzBgEnagMQoSvFcmOgSPTaVvkmTVA IEbSn5kP/bZtPVX6LhrbG2ZfeckweHbBrZ4vXjgQweJYne4mHwQx9EoAWjenocY6Q0dxhc0c ym9GcwnvqgE3lK/yUMlm7XK+ocoDpTU2e1QKLfIY4NkJt6nloVvVejmgSHenbvuTpKwrQp8g == To: notmuch@notmuchmail.org Subject: [PATCH] cli/insert: do not lose the SMTP envelope MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23.1 (2014-03-12) From: J Farkas Message-ID: <1451647279.42.86b0a8ab@201601.l2015aftruuq.dns007.net> Date: Fri, 01 Jan 2016 11:21:19 +0000 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Jan 2016 11:29:42 -0000 From: Janos Farkas Subject: [PATCH] cli/insert: do not lose the SMTP envelope Make sure we store the envelope sender/recipient if provided by qmail-command(8) in $RPLINE and $DTLINE. --- I just realised that the messages delivered directly into maildir don't have the usual envelope addresses that qmail provides. This is a piece of information that's important to (at least my) troubleshooting, so I created a patch that seems to work well, applies cleanly to master (and 0.21), and provided a NEWS entry should it be necessary. NEWS | 9 +++++++++ notmuch-insert.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/NEWS b/NEWS index 6681699..13d45c8 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,12 @@ + + +`notmuch insert` records the envelope addresses if available + + If the caller provides this information as qmail-command(8) does in + the RPLINE and DTLINE environment variables, then notmuch insert will + record it in the maildir file. + + Notmuch 0.21 (2015-10-29) ========================= diff --git a/notmuch-insert.c b/notmuch-insert.c index 5205c17..ecc0fa0 100644 --- a/notmuch-insert.c +++ b/notmuch-insert.c @@ -284,6 +284,26 @@ copy_fd (int fdout, int fdin) } /* + * Write zero (and LF) terminated string to the output fd. It's expected to + * come from getenv(), so it's not checked for correctness. NULL or empty + * string is ignored, successfully. + * Return TRUE on success, FALSE on errors. + */ +static notmuch_bool_t +write_header (int fdout, const char *hdr) +{ + ssize_t written,to_write; + + if (hdr && (to_write = strlen (hdr))) { + written = write (fdout, hdr, to_write); + if (written != to_write) + return FALSE; + } + + return TRUE; +} + +/* * Write fdin to a new temp file in maildir/tmp, return full path to * the file, or NULL on errors. */ @@ -297,6 +317,14 @@ maildir_write_tmp (const void *ctx, int fdin, const char *maildir) if (fdout < 0) return NULL; + /* maildir(5) suggests the message should start with a Return-Path + * and Delivered-To lines. qmail-local(8) supplies these. + */ + if (! write_header(fdout, getenv("RPLINE"))) + goto FAIL; + if (! write_header(fdout, getenv("DTLINE"))) + goto FAIL; + if (! copy_fd (fdout, fdin)) goto FAIL; -- 2.6.3