dash doesn't execute no signature scripts

Bug #82490 reported by Peter Draper
2
Affects Status Importance Assigned to Milestone
dash (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Binary package hint: dash

Shell scripts that do not have an explicit signature, that is have a blank
first line should be executed using the default shell. When dash is
installed as the default shell this doesn't happen, unless the current
directory is the one containing the script. For instance:
------

# First line should be blank, see execl(3).
echo "No signature script"
exit
------

does not execute when located on the PATH:

$ default_script.sh
/bin/sh: Can't open default_script.sh

cd to directory containing script:

$ cd bin
$ default_script.sh
No signature script

switch to bash, Solaris sh, Tru64 UNIX sh etc. all work.

In support of this (odd usage) I offer that the linux execl(3) man page says:

"If the header of a file isn’t recognized (the attempted execve()
returned ENOEXEC), these functions will execute the shell with the path
of the file as its first argument. (If this attempt fails, no further
searching is done.)"

Similar statements are found in the single UNIX specification of execl, and the
comments in the original scripts say (without justification) that this is
the POSIX behaviour (and avoids the need to know where the standard
shell is installed).

$ dpkg-query -s dash
Installed-Size: 204
Architecture: i386
Version: 0.5.3-3ubuntu4

Revision history for this message
didier (did447-deactivatedaccount) wrote :

Confirmed

strace output

bash:
17932 execve("/bin/bash", ["/bin/bash"], [/* 36 vars */]) = 0
....
17932 clone(child_stack=0, ... ) = 17956
....
17956 execve("/bin/default.sh", ["default.sh"], ...) = -1 ENOEXEC
17956 open("/bin/default.sh", O_RDONLY|O_LARGEFILE) = 3
17956 read(3, "\n# First line should be blank, s"..., 80) = 77
17956 close(3) = 0
...
Hmm, is the running shell also the default shell?

Dash
17844 execve("/bin/dash", ["/bin/dash"], [/* 36 vars */]) = 0
...
17853 execve("/bin/default.sh", ["default.sh"], ...) = -1 ENOEXEC
17853 execve("/bin/sh", ["/bin/sh", "default.sh"], [/* 36 vars */]) = 0

should be
17853 execve("/bin/sh", ["/bin/sh", "/bin/default.sh"], [/* 36 vars */]) = 0

Changed in dash:
status: Unconfirmed → Confirmed
Revision history for this message
Colin Watson (cjwatson) wrote :

Note, for clarity (since it took me a bit of experimentation to make sure) that this only happens when the shell in which you attempt to run default_script.sh is dash; trying this in bash with /bin/sh -> dash isn't sufficient.

Revision history for this message
Peter Draper (p-w-draper) wrote :

This issue seems to be fixed in 8.04.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.