dash doesn't execute no signature scripts
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
Confirmed
strace output
bash: stack=0, ... ) = 17956 "/bin/default. sh", ["default.sh"], ...) = -1 ENOEXEC bin/default. sh", O_RDONLY| O_LARGEFILE) = 3
17932 execve("/bin/bash", ["/bin/bash"], [/* 36 vars */]) = 0
....
17932 clone(child_
....
17956 execve(
17956 open("/
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 "/bin/default. sh", ["default.sh"], ...) = -1 ENOEXEC
17844 execve("/bin/dash", ["/bin/dash"], [/* 36 vars */]) = 0
...
17853 execve(
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