make-alpha
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Huge command line mitigation (was: Re: .ONESHELL enhancement?)


From: Paul Smith
Subject: Huge command line mitigation (was: Re: .ONESHELL enhancement?)
Date: Wed, 07 Oct 2009 15:07:17 -0400

On Mon, 2009-10-05 at 21:52 +0200, Ralf Wildenhues wrote:
> * Matt McCutchen wrote on Mon, Oct 05, 2009 at 08:50:42AM CEST:
> > 1. It may be hard to predict 100% accurately whether a particular
> > command on a particular OS would exceed the limit,
> 
> If execve fails with E2BIG, you can be pretty sure of what happened.

Yes, this is what I was thinking as well.  Also, offhand I can't think
of any way a script would behave differently if it were given to /bin/sh
-c, vs. being written to a temporary file and the filename given
to /bin/sh ($0 would be different but otherwise...?)

There are still things to be done here though: for example we would only
want to try this method if we knew SHELL was a POSIX-ish shell; it might
not be the case that any random interpreter can handle a filename like
that.  And, if we need to run the command like this we can't use a
simple exec because we need to be there to clean up the temporary file
afterwards.  That means the forked process needs to collect the exit
status of the child, then exit that way itself.  There are ways that a
child process can fail that are hard to "pass back", such as signals,
core dumps, etc.

Using stdin to the shell is less effort here, because we can unlink the
file then exec with the open fd (although this might not work on all
platforms?), but it really WOULD change the behavior of the script, if
it tried to use stdin.  Of course using stdin is not smart (due to
parallel job support if nothing else) but it's there.

As of today make never creates any temporary files: there's no facility
for it.  There are a few other reasons make might want to use temp
files, though (for example, some have asked for parallel builds to
capture stdout/stderr from commands so they can be all shown at once,
rather than mixed together: make is not multi-threaded so that would
need to be done with temporary files).  Adding portable, secure
temporary file handling to make is a bit of a chore.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

[Prev in Thread] Current Thread [Next in Thread]