From 56fa014af87ce074702a71f48c9c3119fb8a1bdf Mon Sep 17 00:00:00 2001 From: sophia Date: Wed, 19 Aug 2020 14:59:25 -0500 Subject: [PATCH] Don't persist shared folders if mount options capability not provided --- lib/vagrant/action/builtin/mixin_synced_folders.rb | 2 +- .../linux/cap/persist_mount_shared_folder.rb | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/vagrant/action/builtin/mixin_synced_folders.rb b/lib/vagrant/action/builtin/mixin_synced_folders.rb index f505d2241..507c5d475 100644 --- a/lib/vagrant/action/builtin/mixin_synced_folders.rb +++ b/lib/vagrant/action/builtin/mixin_synced_folders.rb @@ -245,7 +245,7 @@ module Vagrant def cached_synced_folders(machine) import = JSON.parse(machine.data_dir.join("synced_folders").read) import.each do |type, folders| - impl = plugins[type.to_sym].first.new._initialize(machine, type) + impl = plugins[type.to_sym].first.new._initialize(machine, type.to_sym) folders.each { |_, v| v[:plugin] = impl } end # Symbolize the keys we want as symbols diff --git a/plugins/guests/linux/cap/persist_mount_shared_folder.rb b/plugins/guests/linux/cap/persist_mount_shared_folder.rb index c2f7c3cc5..338d62e07 100644 --- a/plugins/guests/linux/cap/persist_mount_shared_folder.rb +++ b/plugins/guests/linux/cap/persist_mount_shared_folder.rb @@ -23,12 +23,18 @@ module VagrantPlugins ssh_info = machine.ssh_info export_folders = folders.map { |type, folder| folder.map { |name, data| + guest_path = Shellwords.escape(data[:guestpath]) data[:owner] ||= ssh_info[:username] data[:group] ||= ssh_info[:username] - guest_path = Shellwords.escape(data[:guestpath]) - mount_options, _, _ = data[:plugin].capability( - :mount_options, name, guest_path, data) - mount_type = data[:plugin].capability(:mount_type) + + if data[:plugin].capability?(:mount_type) + mount_type = data[:plugin].capability(:mount_type) + mount_options, _, _ = data[:plugin].capability( + :mount_options, name, guest_path, data) + else + next + end + mount_options = "#{mount_options},nofail" { name: name,