[Libguestfs] Further nbdkit patches for Haiku

Eric Blake eblake at redhat.com
Tue Nov 13 15:16:33 UTC 2018


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'?  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).  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).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org




More information about the Libguestfs mailing list