All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Valery Reznic <valery_reznic@yahoo.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: execve for script don't return ENOEXEC, bug ?
Date: Fri, 19 Mar 2010 14:07:04 -0700	[thread overview]
Message-ID: <20100319140704.794dec89.akpm@linux-foundation.org> (raw)
In-Reply-To: <812529.11018.qm@web110312.mail.gq1.yahoo.com>

On Thu, 11 Mar 2010 02:56:16 -0800 (PST)
Valery Reznic <valery_reznic@yahoo.com> wrote:

> Hi,
> 
> I Have following to scripts:
> 
> a.sh
> #!/bin/sh
> echo "It's a.sh
> 
> and b.sh:
> #! ./b.sh
> echo "It's b.sh"
> 
> As per execve man page, script interpreter should not be script itself.
> When I run it on my Fedora 8 x86_64 box (with stock kernel, never updated)
> under strace I got following:
> 
> strace -f -e execve  setarch x86_64  ./b.sh 
> execve("/usr/bin/setarch", ["setarch", "x86_64", "./b.sh"], [/* 23 vars */]) = 0
> execve("./b.sh", ["./b.sh"], [/* 23 vars */]) = -1 ENOEXEC (Exec format error)
> execve("/bin/sh", ["/bin/sh", "./b.sh"], [/* 23 vars */]) = 0
> It's b.sh
> 
> I.e execve failed as it should
> 
> When I run same scripts on Fedora 12 x86_64 box with stock kernel 2.6.31.5-127.fc12.x86_64 I got following:
> 
> strace -f -e execve setarch i386  ./b.sh 
> execve("/usr/bin/setarch", ["setarch", "i386", "./b.sh"], [/* 41 vars */]) = 0
> execve("./b.sh", ["./b.sh"], [/* 41 vars */]) = 0
> It's a.sh
> 
> I.e execve succeeded, instead of failing with ENOEXEC
> 

It works for me, I think:

z:/home/akpm> uname -a
Linux z 2.6.31.5-127.fc12.x86_64 #1 SMP Sat Nov 7 21:11:14 EST 2009 x86_64 x86_64 x86_64 GNU/Linux
z:/home/akpm> cat b.sh
#! ./b.sh
echo "It's b.sh"
z:/home/akpm> strace -f -e execve setarch i386  ./b.sh 
execve("/usr/bin/setarch", ["setarch", "i386", "./b.sh"], [/* 60 vars */]) = 0
execve("./b.sh", ["./b.sh"], [/* 60 vars */]) = -1 ENOEXEC (Exec format error)
execve("/bin/sh", ["/bin/sh", "./b.sh"], [/* 60 vars */]) = 0
It's b.sh


Did I do something wrong?  If not, I wonder what's different.

  reply	other threads:[~2010-03-19 21:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-11 10:56 execve for script don't return ENOEXEC, bug ? Valery Reznic
2010-03-19 21:07 ` Andrew Morton [this message]
2010-03-20  0:37   ` David Newall
2010-03-20  6:42     ` Valery Reznic
2010-03-20  9:41       ` David Newall
2010-03-20 12:56         ` Valery Reznic
2010-03-20 17:57           ` David Newall
2010-03-21  8:33             ` Valery Reznic
     [not found]               ` <876436.86374.qm-3jHsvP0p17FeqboJWQvT7/u2YVrzzGjVVpNB7YpNyf8@public.gmane.org>
2010-03-21 19:16                 ` Johannes Stezenbach
2010-03-21 19:16                   ` Johannes Stezenbach

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100319140704.794dec89.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=valery_reznic@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.