lkml.org 
[lkml]   [2010]   [Mar]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: execve for script don't return ENOEXEC, bug ?


--- On Sat, 3/20/10, David Newall <davidn@davidnewall.com> wrote:

> From: David Newall <davidn@davidnewall.com>
> Subject: Re: execve for script don't return ENOEXEC, bug ?
> To: "Valery Reznic" <valery_reznic@yahoo.com>
> Cc: linux-kernel@vger.kernel.org
> Date: Saturday, March 20, 2010, 11:41 AM
> Valery Reznic wrote:
> > [valery@localhost ~]$ cat a.sh #!/bin/sh
> > echo "It's a.sh"
> > [valery@localhost ~]$ cat b.sh #! ./a.sh
> > echo "It's b.sh"
> > [valery@localhost ~]$ [valery@localhost ~]$ strace -f
> -e execve setarch i386 ./b.sh execve("/usr/bin/setarch",
> ["setarch", "i386", "./b.sh"], [/* 40 vars */]) = 0
> > execve("./b.sh", ["./b.sh"], [/* 40 vars */]) = 0
> > It's a.sh
> >   
>
> That is the correct output for a script which is being
> interpreted by a.sh, when a.sh prints "It's a.sh" using
> /bin/sh as its interpreter.  Remember, you didn't ask
> /bin/sh to interpret b.sh, you asked a.sh to do it, and a.sh
> is a simple echo statement, not an interpreter.  There
> is no error here.

execve's man page state that script's interprtert should not be
interpreter itself:
------------------------------------------------------
Interpreter scripts
An interpreter script is a text file that has execute permission
enabled and whose first line is of the form:

#! interpreter [optional-arg]

The interpreter must be a valid pathname for an executable which is not
itself a script.
------------------------------------------------------

I.e, execve should return ENOEXEC. And it did it at least in Fedora 8 and earlier.

To me it looks like execve and it's man page disagree. Do you know is it new intended behaviour of execve and just man page wasn't update or it's a bug in execve ?

Valery.
>



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2010-03-20 13:59    [W:0.049 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site