[libvirt] [PATCH] nwfilter: use /bin/sh rather than requiring bash

Stefan Berger stefanb at linux.vnet.ibm.com
Tue Nov 16 02:18:43 UTC 2010


On 11/15/2010 07:18 PM, Eric Blake wrote:
> On 11/13/2010 05:04 PM, Stefan Berger wrote:
>> On 11/13/2010 04:52 PM, Eric Blake wrote:
>>> * src/nwfilter/nwfilter_ebiptables_driver.c
>>> (ebiptablesWriteToTempFile): Use /bin/sh.
>>> (bash_cmd_path): Delete.
>>> (ebiptablesDriverInit, ebiptablesDriverShutdown): No need to
>>> search for bash.
>>> (CMD_EXEC): Prefer $() over ``, since we can assume POSIX.
>>> (iptablesSetupVirtInPost): Use portable 'test' syntax.
>>> (iptablesLinkIPTablesBaseChain): Use POSIX $(()) syntax.
>> Since you are the expert with shells and I trust that the TCK tests now
>> pass with all possible /bin/sh's, you get my ACK.
> Well, at least with all POSIX-compliant /bin/sh, which is what Linux is
> likely to have, and nwfilter requires Linux.
>
> It won't work with Solaris /bin/sh, but that's a much harder portability
> target since it is so old (bourne shell, which pre-dates POSIX).  But
> thankfully not an issue for this patch.
>
> I've gone ahead and pushed it.
>
Unfortunately it doesn't work. The code produces a file like this now 
for some basic probing. The file now has a syntax error.

#!/bin/sh
cmd='/sbin/iptables -n -L FORWARD'
eval res=\$("${cmd}")
if [ $? -ne 0 ]; then  echo "Failure to execute command '${cmd}'.";  
exit 1;fi

    Stefan




More information about the libvir-list mailing list