From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Justus Winter Newsgroups: gmane.emacs.bugs Subject: bug#56855: 27.1; sendmail-send-it considers it an error if sendmail wrote to stdout/stderr Date: Tue, 02 Aug 2022 07:59:06 +0200 Message-ID: <875yjbi3th.fsf@thinkbox> References: <87wnbtig4z.fsf@thinkbox> <87o7x34rqg.fsf@rfc20.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38484"; mail-complaints-to="usenet@ciao.gmane.io" To: Matt Armstrong , 56855@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 02 08:03:53 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oIl0T-0009oi-8a for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 02 Aug 2022 08:03:53 +0200 Original-Received: from localhost ([::1]:45802 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIl0S-0007lT-6l for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 02 Aug 2022 02:03:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36238) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIkwl-0005gn-NR for bug-gnu-emacs@gnu.org; Tue, 02 Aug 2022 02:00:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:52316) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIkwl-0001nz-E4 for bug-gnu-emacs@gnu.org; Tue, 02 Aug 2022 02:00:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oIkwl-00083K-AG for bug-gnu-emacs@gnu.org; Tue, 02 Aug 2022 02:00:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Justus Winter Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 02 Aug 2022 06:00:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 56855 X-GNU-PR-Package: emacs Original-Received: via spool by 56855-submit@debbugs.gnu.org id=B56855.165941996430853 (code B ref 56855); Tue, 02 Aug 2022 06:00:03 +0000 Original-Received: (at 56855) by debbugs.gnu.org; 2 Aug 2022 05:59:24 +0000 Original-Received: from localhost ([127.0.0.1]:42061 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oIkw8-00081X-1X for submit@debbugs.gnu.org; Tue, 02 Aug 2022 01:59:24 -0400 Original-Received: from harrington.uberspace.de ([185.26.156.85]:42540) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oIkw6-00081M-H4 for 56855@debbugs.gnu.org; Tue, 02 Aug 2022 01:59:23 -0400 Original-Received: (qmail 28787 invoked by uid 500); 2 Aug 2022 05:59:19 -0000 Authentication-Results: harrington.uberspace.de; auth=pass (plain) In-Reply-To: <87o7x34rqg.fsf@rfc20.org> X-Rspamd-Bar: / X-Rspamd-Report: MIME_GOOD(-0.1) MID_RHS_NOT_FQDN(0.5) BAYES_HAM(-1.11445) X-Rspamd-Score: -0.71445 Original-Received: from unknown (HELO unkown) (::1) by harrington.uberspace.de (Haraka/2.8.28) with ESMTPSA; Tue, 02 Aug 2022 07:59:19 +0200 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:238488 Archived-At: Matt Armstrong writes: > Justus Winter writes: > >> sendmail-send-it considers it an error if sendmail wrote to >> stdout/stderr, despite the fact that the process returned success. > > [...] > >> I read documentation of various sendmail implementations, and all >> agreed that returning success meant that the operation succeeded. I >> found no justification for emacs thinking that the operation failed if >> the process printed to stdout or stderr. > > This is perhaps surprising. It is also behavior that has come to be > expected, especially in more traditional Unix programs. E.g. crontab > also considers jobs that print to stderr to have an error, regardless of > exit status. >From man cron(8) I see: When executing commands, any output is mailed to the owner of the crontab (or to the user named in the MAILTO environment variable in the crontab, if such exists) from the owner of the crontab (or from the email address given in the MAILFROM environment variable in the crontab, if such exists). Note how it says nothing about considering it an error. In fact, I did an experiment on my cron implementation (ISC cron 3.0pl1-149 as packaged by Debian), and it did send me any output written to stdout or stderr regardless of the exit status, and it did *not* notify me of a failing command if no output was written. Clearly, sending mails is orthogonal to the exit status as far as cron is concerned. > From the sendmail(8) manpage we have this statement: > > Sendmail is not intended as a user interface routine; other programs > provide user-friendly front ends; sendmail is used only to deliver > pre-formatted messages. > > An implementation of the "sendmail program" should probably emulate the > original sendmail as closely as possible. It prints no messages when it > succeeds. I don't read the snippet you quoted as promising to never send text to stderr if the process succeeds. Now, I don't know which version of the manpage you consider authoritative, but I found e.g. https://linux.die.net/man/8/sendmail.sendmail which does contain your snippet, and then clearly states: Sendmail returns an exit status describing what it did. The codes are defined in : EX_OK Successful completion on all addresses. And: % grep EX_OK /usr/include/sysexits.h #define EX_OK 0 /* successful termination */ > On this we do have roughly 35 years of historical precedent, since the > original Sendmail began in the mid-80s. :-) Well, happily, we're also 35 years wiser than to trust the original sendmail with anything. > This may seem like a historical wart, but I have personally found this > behavior to be helpful, especially in programs that are typically run > non-interactively and "out of sight" like a crontab or sendmail wrapper > script. E.g. when a shell script prints to stderr there may indeed have > been a problem, but a bug in the script may still have caused it to exit > with zero regardless. It is usually easy to arange for such programs to > print nothing when they succeed. I don't understand that argument. I agree that seeing the output is beneficial, but then you say that it is easy to suppress that output, the same output that seeing you deemed beneficial just a few lines earlier. In fact, I think we should ask what the best thing is for the user. I think that (a) emacs should correctly indicate whether sending the mail succeeded or not, and (b) any warnings should be presented to the user. Currently, emacs fails at (a) and your workaround violates (b). >> I use msmtp with the authentication password encrypted using OpenPGP. >> Then, I use 'gpg --no-tty -q -d ...' as msmtp's passwordeval function. >> Now, my OpenPGP key has expired, but that doesn't stop GnuPG from >> decrypting the secret, and in fact it returns the status code 0. It >> also prints >> >> gpg: Note: secret key 08CC70F8D8CC765A expired at Mon 25 Jul 2022 05:31:26 PM CEST >> >> to stderr, which is picked up by emacs, it says >> >> sending...failed to gpg: Note: secret key 08CC70F8D8CC765A expired at Mon 25 Jul 2022 05:31:26 PM CEST >> >> in the status buffer while the compose buffer stays open. Note that >> despite this, the message has been sent successfully, while emacs >> indicates that the sending has failed. > > Can you configure your msmtp to behave like sendmail and refrain from > printing human readable messages upon success? Perhaps the --logger-fd > or --logger-file arguments to gpg could be used to direct the output you > do not wish to read to /dev/null? Yes I can, but the question is: should I have to? Best, Justus