From f89c4412b2ccc1716e0073d2a12572a5ce0ad402 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 30 Dec 2013 14:45:40 -0800 Subject: [PATCH] synced_folders/nfs: lock around sudo input [GH-2680] --- CHANGELOG.md | 2 ++ plugins/synced_folders/nfs/synced_folder.rb | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 20bc9b346..1ffb9c285 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ BUG FIXES: [GH-2714] - commands/plugin: Fix exception that could happen rarely when installing a plugin. + - synced\_folders/nfs: sudo will only ask for password one at a time + when using a parallel provider [GH-2680] ## 1.4.1 (December 18, 2013) diff --git a/plugins/synced_folders/nfs/synced_folder.rb b/plugins/synced_folders/nfs/synced_folder.rb index 4d98b12ac..5e7f2292c 100644 --- a/plugins/synced_folders/nfs/synced_folder.rb +++ b/plugins/synced_folders/nfs/synced_folder.rb @@ -1,4 +1,5 @@ require 'fileutils' +require 'thread' require 'zlib' require "log4r" @@ -15,6 +16,8 @@ module VagrantPlugins # will be mounted. # class SyncedFolder < Vagrant.plugin("2", :synced_folder) + @@lock = Mutex.new + def initialize(*args) super @@ -41,9 +44,13 @@ module VagrantPlugins # and such on the folder itself. folders.each { |id, opts| prepare_folder(machine, opts) } - # Export the folders - machine.ui.info I18n.t("vagrant.actions.vm.nfs.exporting") - machine.env.host.nfs_export(machine.id, machine_ip, folders) + # Export the folders. We do this with a class-wide lock because + # NFS exporting often requires sudo privilege and we don't want + # overlapping input requests. [GH-2680] + @@lock.synchronize do + machine.ui.info I18n.t("vagrant.actions.vm.nfs.exporting") + machine.env.host.nfs_export(machine.id, machine_ip, folders) + end # Mount machine.ui.info I18n.t("vagrant.actions.vm.nfs.mounting")