Re: [tck PATCH 4/9] Fix no-ip-spoofing test script generation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Feb 07, 2018 at 09:04:54PM -0500, Laine Stump wrote:
> The setting of the environment variable MASK was for some reason
> producing "8" instead of "24". Changing from using back-ticks "`" that
> resolved at the time the script was created, to using $(blah) resolved
> when the script is *run* magically fixed the problem.

Oh, I bet the `` were being evaluated on the *host* when perl initializes
the $cmdfile variable. Your change to $() means it is now correctly
evaluated on the *guest* inside the SSH sesssion. Fun !

> Note that this doesn't change the outcome of the test at all, since
> the guest never needs to connect outside the local subnet, and is
> immediately halted after setting the IP using $MASK. It just bothered
> me that the value was incorrect (and that backticks were being used,
> when $() is more portable - again it is duly noted that portability
> doesn't matter in this case, since we know that the script will always
> be executed on Fedora with bash).
> 
> ---
>  scripts/nwfilter/220-no-ip-spoofing.t | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/nwfilter/220-no-ip-spoofing.t b/scripts/nwfilter/220-no-ip-spoofing.t
> index 872dcc3..5903961 100644
> --- a/scripts/nwfilter/220-no-ip-spoofing.t
> +++ b/scripts/nwfilter/220-no-ip-spoofing.t
> @@ -79,9 +79,10 @@ my $ssh = Net::OpenSSH->new($guestip,
>  # now bring eth0 down, change IP and bring it up again
>  diag "preparing ip spoof";
>  my $cmdfile = <<EOF;
> -echo "DEV=`ip link | head -3 | tail -1 | awk '{print \\\$2}' | sed -e 's/://'`
> -MASK=`ip addr show \\\$DEV | grep 'inet ' | awk '{print \\\$2}' | sed -e 's/.*\\///;q'`
> +echo "DEV=\\\$(ip link | head -3 | tail -1 | awk '{print \\\$2}' | sed -e 's/://')
> +MASK=\\\$(ip addr show \\\$DEV | grep 'inet ' | awk '{print \\\$2}' | sed -e 's/.*\\///;q')
>  /sbin/ip addr show \\\$DEV
> +kill \\\$(pidof dhclient)
>  /sbin/ip link set \\\$DEV down
>  /sbin/ip addr flush dev \\\$DEV
>  /sbin/ip addr add 192.168.122.183/\\\$MASK dev \\\$DEV
> -- 
> 2.13.6
> 

Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux