From 93f02c67f8e27e380678266552ae3cc92a5c4ca3 Mon Sep 17 00:00:00 2001 From: Jose Luis Duran Date: Fri, 29 Mar 2019 02:39:24 -0300 Subject: [PATCH] FreeBSD: Simplify the listing of interfaces According to ifconfig(8), to list only Ethernet interfaces, excluding all other interface types, including the loopback interface, the command to use should be: ifconfig -l ether Related to: #8760 --- plugins/guests/freebsd/cap/configure_networks.rb | 4 ++-- .../plugins/guests/freebsd/cap/configure_networks_test.rb | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/guests/freebsd/cap/configure_networks.rb b/plugins/guests/freebsd/cap/configure_networks.rb index 36b11d1ed..5020eebe8 100644 --- a/plugins/guests/freebsd/cap/configure_networks.rb +++ b/plugins/guests/freebsd/cap/configure_networks.rb @@ -18,8 +18,8 @@ module VagrantPlugins # Remove any previous network additions to the configuration file. commands << "sed -i '' -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf" - comm.sudo("ifconfig -a | grep -o '^[0-9a-z]*' | grep -v '^lo'", options) do |_, stdout| - interfaces = stdout.split("\n") + comm.sudo("ifconfig -l ether", options) do |_, stdout| + interfaces = stdout.split end networks.each.with_index do |network, i| diff --git a/test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb b/test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb index 0d2be59b3..372311bae 100644 --- a/test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb +++ b/test/unit/plugins/guests/freebsd/cap/configure_networks_test.rb @@ -13,8 +13,7 @@ describe "VagrantPlugins::GuestFreeBSD::Cap::ConfigureNetworks" do before do allow(machine).to receive(:communicate).and_return(comm) - comm.stub_command("ifconfig -a | grep -o '^[0-9a-z]*' | grep -v '^lo'", - stdout: "em1\nem2") + comm.stub_command("ifconfig -l ether", stdout: "em1 em2") end after do