From: Tomi Ollila Date: Sat, 2 Jan 2016 11:28:02 +0000 (+0200) Subject: Re: [PATCH] cli/insert: do not lose the SMTP envelope X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=3028c4fb21d888acd6e8c6388e97eab6fe842fec;p=notmuch-archives.git Re: [PATCH] cli/insert: do not lose the SMTP envelope --- diff --git a/3a/bd984d102e0ff141bb4df03874056977587f7a b/3a/bd984d102e0ff141bb4df03874056977587f7a new file mode 100644 index 000000000..e3215a4ec --- /dev/null +++ b/3a/bd984d102e0ff141bb4df03874056977587f7a @@ -0,0 +1,155 @@ +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 D56076DE1B22 + for ; Sat, 2 Jan 2016 03:27:49 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: 0.676 +X-Spam-Level: +X-Spam-Status: No, score=0.676 tagged_above=-999 required=5 tests=[AWL=0.024, + SPF_NEUTRAL=0.652] 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 dkroVeIZtIqU for ; + Sat, 2 Jan 2016 03:27:46 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by arlo.cworth.org (Postfix) with ESMTP id A58C66DE1B1D + for ; Sat, 2 Jan 2016 03:27:44 -0800 (PST) +Received: from guru.guru-group.fi (localhost [IPv6:::1]) + by guru.guru-group.fi (Postfix) with ESMTP id D286310008D; + Sat, 2 Jan 2016 13:28:02 +0200 (EET) +From: Tomi Ollila +To: J Farkas , + notmuch@notmuchmail.org +Subject: Re: [PATCH] cli/insert: do not lose the SMTP envelope +In-Reply-To: <1451647279.42.86b0a8ab@201601.l2015aftruuq.dns007.net> +References: <1451647279.42.86b0a8ab@201601.l2015aftruuq.dns007.net> +User-Agent: Notmuch/0.21+32~g73439f8 (http://notmuchmail.org) Emacs/24.3.1 + (x86_64-unknown-linux-gnu) +X-Face: HhBM'cA~ +MIME-Version: 1.0 +Content-Type: text/plain +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: Sat, 02 Jan 2016 11:27:50 -0000 + +On Fri, Jan 01 2016, J Farkas wrote: + +> 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. +> --- + +Probably good feature, but like +http://www.qmail.org/man/man8/qmail-command.html +says: + + qmail-local supplies several useful environment variables to + command. WARNING: These environment variables are not + quoted. They may contain special characters. They are + under the control of a possibly malicious remote user. + +Should we check that the contents of RPLINE and DTLINE are well-formed +before writing these to the mail files ? + +Tomi + + +> 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 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> https://notmuchmail.org/mailman/listinfo/notmuch