Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 47506 - sandbox makes ebuild dump core if executing a shell script
Summary: sandbox makes ebuild dump core if executing a shell script
Status: RESOLVED DUPLICATE of bug 46945
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Sandbox (show other bugs)
Hardware: All All
: High major
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-11 06:34 UTC by Tavis Ormandy (RETIRED)
Modified: 2005-07-17 13:06 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tavis Ormandy (RETIRED) gentoo-dev 2004-04-11 06:34:30 UTC
the ebuilds for app-shells/ksh used to work fine, but now they fail with the new sandbox code. a script called `package` is used to do most of the building (they dont use gnu make), which is a shell script that doesnt start with sh_bang.

if the kernel returns ENOEXEC when attempting to execute a executable file (fs/binfmt_script.c), bash will try to run it as a shell script (execute_cmd.c).

This is the behaviour described in the single unix specification, http://www.opengroup.org/onlinepubs/007908799/xcu/chap2.html#tag_001_009_001_001

"...If the execve() function fails due to an error equivalent to the XSH specification error [ENOEXEC], the shell will execute a command equivalent to having a shell invoked with the command name as its first operand, along with any remaining arguments passed along. If the executable file is not a text file, the shell may bypass this command execution, write an error message, and return an exit status of 126."

So, imho, this should work.

But, if you guys decide not to fix it, i'll just make a patch to add the sh_bangs :)

verify by making an ebuild with a src_unpack like this:

src_unpack() {
    #echo '#!/bin/sh' > ${T}/test
    echo 'echo hello' >> ${T}/test
    chmod 755 ${T}/test
    ${T}/test || die 
}

which should dump core, uncomment the first line and it works fine.
Comment 1 Jason Stubbs (RETIRED) gentoo-dev 2004-04-11 07:25:42 UTC
We've been aware of this bug for quite some time. Thanks for your comments though as they helped me to confirm my fix.


*** This bug has been marked as a duplicate of 46945 ***