On Tue, Nov 13, 2018 at 09:16:33AM -0600, Eric Blake wrote:
On 11/13/18 7:40 AM, Richard W.M. Jones wrote:
>>(I think the error message is "incorrect ELF header") could be
>>something to do with the way we use shebangs (#!). IIRC this also
>>fails on FreeBSD so probably nbdkit is doing something which is not
>>correct POSIX.
>
POSIX says that #! shebangs are undefined behavior. You're at the
mercy of each operating system, because there is no portable
solution across all systems.
>I reproduced this on FreeBSD. The path used in the tests is indeed
>relative:
>
> #!../nbdkit
>
>However replacing this with an absolute path did *not* fix the issue.
>FreeBSD seems to not like running a shell script from a shebang,
>probably because this is (was?) insecure. However because of the way
>our test harness works we really need to run the shell script. As
>there seems to be no simple way to fix this for now, I left the bug in
>1.8.0.
Can you use '#!/bin/sh /path/to/nbdkit'?
I didn't reproduce the full shebang above, but it's actually:
#!../nbdkit perl
(
https://github.com/libguestfs/nbdkit/blob/90c0de1c2518510ae0fd8ce6aa41f2f...)
So I suppose adding the extra parameter will not work.
That way, the shebang is
running a binary (not a script), where the binary in turn runs the
desired script? Or does that run into other limitations (for
example, #! can only portably used with exactly one argument after
the interpreter name; BSD and more recently coreutils have added
'env -S' to work around that limitation, although it is not yet
widespread portable).
This might work. I'll check and get back.
But yes, I do seem to recall that #! must
point to a binary interpreter rather than a script of an unspecified
language (the fact that Linux will happily run a script under
/bin/sh is not universal).
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW