From: Jani Nikula Date: Sun, 3 Jan 2016 16:04:39 +0000 (+0200) Subject: Re: [PATCH] cli/insert: do not lose the SMTP envelope X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bbbef10829889e745467994f41791b74317808bf;p=notmuch-archives.git Re: [PATCH] cli/insert: do not lose the SMTP envelope --- diff --git a/ec/49cb335deca2298d5dc123101d872f8730321c b/ec/49cb335deca2298d5dc123101d872f8730321c new file mode 100644 index 000000000..e841d2fce --- /dev/null +++ b/ec/49cb335deca2298d5dc123101d872f8730321c @@ -0,0 +1,181 @@ +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 514B66DE17DB + for ; Sun, 3 Jan 2016 08:05:35 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at cworth.org +X-Spam-Flag: NO +X-Spam-Score: -0.545 +X-Spam-Level: +X-Spam-Status: No, score=-0.545 tagged_above=-999 required=5 tests=[AWL=0.175, + DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_LOW=-0.7, + RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] 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 5NJMFwMAXlTQ for ; + Sun, 3 Jan 2016 08:05:32 -0800 (PST) +Received: from mail-wm0-f51.google.com (mail-wm0-f51.google.com + [74.125.82.51]) by arlo.cworth.org (Postfix) with ESMTPS id 949C36DE17BE for + ; Sun, 3 Jan 2016 08:05:32 -0800 (PST) +Received: by mail-wm0-f51.google.com with SMTP id u188so122792982wmu.1 + for ; Sun, 03 Jan 2016 08:05:32 -0800 (PST) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=nikula-org.20150623.gappssmtp.com; s=20150623; + h=from:to:subject:in-reply-to:references:user-agent:date:message-id + :mime-version:content-type; + bh=hcxOWN7jpUJBVQTeHt21fqYFjiP3Z7vffUE4+5EbpCw=; + b=Y1Igp7Hr2xi9e66qBtg0EdLJ2S/MxLD8ZWU5RkOfP5vJPPJQOeZMjrl9dY7uw2lpUm + vpHZEGbftyLalOpq/GWe2BYV/RL3pgWamRAjpw3ZnGUgorzDWcPm4mR1nxmJDzvReOvu + KF9EJvYy2MMtu8Q+MNdMZeSbNfvAS0Vz0jGk41FTF+g9sRZ8+VeYYKybMAIDLCwvDw7I + xUOEYydQCPedcWRgsZZ0yAxvyBvtUAtCzKVvZ8wh0nI7hp5hJWg1hKq/x92w1nRWW6m7 + NgkLbwxisvXz1BTonkWSJDx917YtoXnjmycCqPVOkii+M7qOyFpy9zxiB8G0JTq3m9+9 + EDUQ== +X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; + d=1e100.net; s=20130820; + h=x-gm-message-state:from:to:subject:in-reply-to:references + :user-agent:date:message-id:mime-version:content-type; + bh=hcxOWN7jpUJBVQTeHt21fqYFjiP3Z7vffUE4+5EbpCw=; + b=X/BjVEib05otT1PuGUdx/0KgsF0fdniwpvUNvx6kC+s7M9POg+gAM1qGJwRzzGK+Sx + uBUFF4OvtiXWbSOSXX8ZPhWfvwhTLCxfHn74WJ2patqLIExtH+fHDo9jK2Z74x7eUUsu + C5YWH03VoKTsNR5+SRmwL7joRGMs/q+I0fKzQJ6QOVYm7Q2EM0No/uMWfEUyYn/i/uOw + tulXTzYMxGI5H8P9DUwDSDaLQGHZ5z8AFQ6fO1zPuqcy6qtfC16FzcOCnkzeu34UVGPi + AhU3zHhxI7Hkz1t3HVyU+2Vz5rtQT98j7WVJySkUJIxAk8sqt170+L263/6xWrwQzdkp + 6GFw== +X-Gm-Message-State: ALoCoQlaDZxJ5zVXMtGqrjRsSVU+yVt2Yds3MWNBitf8yb1cBcgy4Tuxzn/zmaS/vV8v+ISojGd+fOjXSVz9V9JBRz4f1thRbA== +X-Received: by 10.194.6.37 with SMTP id x5mr77378888wjx.178.1451837130548; + Sun, 03 Jan 2016 08:05:30 -0800 (PST) +Received: from localhost (mobile-access-bceec9-49.dhcp.inet.fi. + [188.238.201.49]) + by smtp.gmail.com with ESMTPSA id ft4sm81742162wjb.37.2016.01.03.08.05.29 + (version=TLSv1/SSLv3 cipher=OTHER); + Sun, 03 Jan 2016 08:05:29 -0800 (PST) +From: Jani Nikula +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+34~ge1fb729 (http://notmuchmail.org) Emacs/24.4.1 + (x86_64-pc-linux-gnu) +Date: Sun, 03 Jan 2016 18:04:39 +0200 +Message-ID: <87bn92wsx4.fsf@nikula.org> +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: Sun, 03 Jan 2016 16:05:35 -0000 + +On Fri, 01 Jan 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. +> --- +> +> 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. + +I'd be more interested in seeing some tests for this... + +> +> 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. + +We usually refer to message files. Perhaps you should also mention what +the RPLINE and DTLINE variables should contain. + +> + +> + +> 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; +> + } + +It's not an error for write() to return prematurely with written < +to_write. Please see the write(2) man page and the copy_fd() +implementation in this file. + +BR, +Jani. + +> + +> + 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