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
This commit is contained in:
Jose Luis Duran 2019-03-29 02:39:24 -03:00
parent 6edcf12979
commit 93f02c67f8
No known key found for this signature in database
GPG Key ID: 8BE8242E460537F4
2 changed files with 3 additions and 4 deletions

View File

@ -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|

View File

@ -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