From a300acfcf0a4cd05219012748e89331e360016ae Mon Sep 17 00:00:00 2001 From: Ilya Chesnokov Date: Mon, 14 Jan 2019 14:10:51 +0300 Subject: [PATCH 1/2] Make sure that ips array contains unique values Fixes #10591 --- plugins/hosts/linux/cap/nfs.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/hosts/linux/cap/nfs.rb b/plugins/hosts/linux/cap/nfs.rb index 630dc0f4e..406241e7f 100644 --- a/plugins/hosts/linux/cap/nfs.rb +++ b/plugins/hosts/linux/cap/nfs.rb @@ -67,6 +67,7 @@ module VagrantPlugins nfs_opts_setup(folders) folders = folder_dupe_check(folders) + ips = ips.uniq output = Vagrant::Util::TemplateRenderer.render('nfs/exports_linux', uuid: id, ips: ips, From c4b80c30ea6550aa71a8f86bd0f8f1303ddda551 Mon Sep 17 00:00:00 2001 From: sophia Date: Mon, 23 Mar 2020 16:24:11 -0500 Subject: [PATCH 2/2] Test ips are de-duplicated when writing /etc/exports --- test/unit/plugins/hosts/linux/cap/nfs_test.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/unit/plugins/hosts/linux/cap/nfs_test.rb b/test/unit/plugins/hosts/linux/cap/nfs_test.rb index 575035ab9..f669d2f81 100644 --- a/test/unit/plugins/hosts/linux/cap/nfs_test.rb +++ b/test/unit/plugins/hosts/linux/cap/nfs_test.rb @@ -132,16 +132,16 @@ describe VagrantPlugins::HostLinux::Cap::NFS do end it "should export new entries" do - cap.nfs_export(env, ui, SecureRandom.uuid, ["127.0.0.1"], "tmp" => {:hostpath => "/tmp"}) + cap.nfs_export(env, ui, SecureRandom.uuid, ["127.0.0.1", "127.0.0.1"], "tmp" => {:hostpath => "/tmp"}) exports_content = File.read(exports_path) - expect(exports_content).to match(/\/tmp.*127\.0\.0\.1/) + expect(exports_content.scan(/\/tmp.*127\.0\.0\.1/).length).to be(1) end it "should not remove existing entries" do File.write(exports_path, "/custom/directory hostname1(rw,sync,no_subtree_check)") - cap.nfs_export(env, ui, SecureRandom.uuid, ["127.0.0.1"], "tmp" => {:hostpath => "/tmp"}) + cap.nfs_export(env, ui, SecureRandom.uuid, ["127.0.0.1", "127.0.0.1"], "tmp" => {:hostpath => "/tmp"}) exports_content = File.read(exports_path) - expect(exports_content).to match(/\/tmp.*127\.0\.0\.1/) + expect(exports_content.scan(/\/tmp.*127\.0\.0\.1/).length).to be(1) expect(exports_content).to match(/\/custom\/directory.*hostname1/) end