[PATCH 4 of 4] mail: switch from os to subprocess module when invoking sendmail

Matt Mackall mpm at selenic.com
Mon Jan 11 16:54:55 CST 2016


On Wed, 2016-01-06 at 00:11 +0900, Yuya Nishihara wrote:
> On Mon, 04 Jan 2016 21:56:10 -0800, Bryan O'Sullivan wrote:
> > # HG changeset patch
> > # User Bryan O'Sullivan <bos at serpentine.com>
> > # Date 1451973286 28800
> > #      Mon Jan 04 21:54:46 2016 -0800
> > # Node ID 09ce74e1f92f8838bbcd2ac1309519f0448ffbed
> > # Parent  3838e999a656ccd5644fadac75ed91f15ad22854
> > mail: switch from os to subprocess module when invoking sendmail

Except it's actually switching from -util- to subprocess. Util is where we put
our os abstractions and this is one so you should either fix util.popen to be
sensible or add another method there.

> avoids a potentially unsafe trip through the shell;

This is not part of our threat model. As a command line tool, we assume you can
already run arbitrary shell commands with your existing privileges and if you
want to run arbitrary shell commands -through- hg, we're more than happy to help
you in a bunch of different ways. The shell is our friend. 

> >  and (bonus!) reports the correct
> > exit code if sendmail fails.

The weird number is 256 * exit code. Linux et al roll the exit code into the
wait(2) return code for unpacking with WEXITSTATUS().

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list