diff --git a/lib/vagrant/util/string_block_editor.rb b/lib/vagrant/util/string_block_editor.rb index 23400b44fc4..0901809ec8a 100644 --- a/lib/vagrant/util/string_block_editor.rb +++ b/lib/vagrant/util/string_block_editor.rb @@ -42,6 +42,16 @@ def keys end end + # This returns the keys (or ids) that are in the string regarding current user only (fix for issue 9070). + # + # @return [] + def cur_user_keys + regexp = /^#\s*VAGRANT-BEGIN:\s*(#{Process.uid}\s.+?)$\r?\n?(.*)$\r?\n?^#\s*VAGRANT-END:\s(\1)$/m + @value.scan(regexp).map do |match| + match[0] + end + end + # This deletes the block with the given key if it exists. def delete(key) key = Regexp.quote(key) diff --git a/plugins/hosts/linux/cap/nfs.rb b/plugins/hosts/linux/cap/nfs.rb index 4a551606578..fdbabc65027 100644 --- a/plugins/hosts/linux/cap/nfs.rb +++ b/plugins/hosts/linux/cap/nfs.rb @@ -114,7 +114,10 @@ def self.nfs_prune(environment, ui, valid_ids) composite_ids = valid_ids.map do |v_id| "#{user} #{v_id}" end - remove_ids = editor.keys - composite_ids + + #Fix for issue 9070, pruning other users' NFS exports + #remove_ids = editor.keys - composite_ids + remove_ids = editor.cur_user_keys - composite_ids logger.debug("Known valid NFS export IDs: #{valid_ids}") logger.debug("Composite valid NFS export IDs with user: #{composite_ids}")