From: Valery Reznic <valery_reznic@yahoo.com>
To: David Newall <davidn@davidnewall.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: execve for script don't return ENOEXEC, bug ?
Date: Fri, 19 Mar 2010 23:42:41 -0700 (PDT) [thread overview]
Message-ID: <687582.96058.qm@web110305.mail.gq1.yahoo.com> (raw)
In-Reply-To: <4BA418B2.8090200@davidnewall.com>
--- 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, 2:37 AM
> 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"
> >
> [...]
> > 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 see no circumstance which would make b.sh invoke a.sh
> (and thus emit "It's a.sh"). Are you sure these are the
> actual scripts and output?
Of course you are right. Somehow I messed up b.sh
(OK, this file is so long and complicated, so no wonder :)
Anyway my bad, sorry.
In the b.sh interpreter should be ./a.sh
Another attempt to provide correct data:
[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
[valery@localhost ~]$
>
> On the other hand, if the output was "It's b.sh", this is
> compatible with many historical versions of UNIX, which
> assumed /bin/sh to be the script interpreter. On
> 2.6.28-16-generic #55-Ubuntu SMP i686 GNU/Linux I get
> successful output for the following variants of "x.sh":
>
> :
> echo worked
>
> and
>
> #!
> echo worked
>
> and
>
> #! ./x.sh
> echo worked
My problem is not incorrect output, but successful execve, when script's interpreter is interpreter itself.
Somewhere between Fedora 8 and Fedora 12 execve's behaviour changed.
@Andrew:
When b.sh has interpreter ./b.sh I got expected ENOEXEC, same as you.
Regards,
Valery.
>
next prev parent reply other threads:[~2010-03-20 6:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-11 10:56 Valery Reznic
2010-03-19 21:07 ` Andrew Morton
2010-03-20 0:37 ` David Newall
2010-03-20 6:42 ` Valery Reznic [this message]
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
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=687582.96058.qm@web110305.mail.gq1.yahoo.com \
--to=valery_reznic@yahoo.com \
--cc=davidn@davidnewall.com \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome