From 14d61f61baba617c91b7b995623a38769c88ff31 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 11 Jan 2012 23:14:04 -0800 Subject: [PATCH] The full options data is sent to mount_shared_folder --- lib/vagrant/action/vm/share_folders.rb | 9 ++++++--- lib/vagrant/guest/base.rb | 4 +++- lib/vagrant/guest/linux.rb | 12 ++++++------ lib/vagrant/guest/solaris.rb | 6 +++++- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/vagrant/action/vm/share_folders.rb b/lib/vagrant/action/vm/share_folders.rb index 4e761baea..79192f00f 100644 --- a/lib/vagrant/action/vm/share_folders.rb +++ b/lib/vagrant/action/vm/share_folders.rb @@ -91,12 +91,15 @@ module Vagrant :name => name, :guest_path => data[:guestpath])) + # Dup the data so we can pass it to the guest API + data = data.dup + # Calculate the owner and group - owner = data[:owner] || @env[:vm].config.ssh.username - group = data[:group] || @env[:vm].config.ssh.username + data[:owner] ||= @env[:vm].config.ssh.username + data[:group] ||= @env[:vm].config.ssh.username # Mount the actual folder - @env[:vm].guest.mount_shared_folder(name, data[:guestpath], owner, group) + @env[:vm].guest.mount_shared_folder(name, data[:guestpath], data) else # If no guest path is specified, then automounting is disabled @env[:ui].info(I18n.t("vagrant.actions.vm.share_folders.nomount_entry", diff --git a/lib/vagrant/guest/base.rb b/lib/vagrant/guest/base.rb index 4cde0658c..b9fba239e 100644 --- a/lib/vagrant/guest/base.rb +++ b/lib/vagrant/guest/base.rb @@ -61,7 +61,9 @@ module Vagrant # @param [String] name The name of the shared folder. # @param [String] guestpath The path on the machine which the user # wants the folder mounted. - def mount_shared_folder(name, guestpath, owner, group) + # @param [Hash] options Additional options for the shared folder + # which can be honored. + def mount_shared_folder(name, guestpath, options) raise BaseError, :_key => :unsupported_shared_folder end diff --git a/lib/vagrant/guest/linux.rb b/lib/vagrant/guest/linux.rb index d2d373b65..8c1d219c0 100644 --- a/lib/vagrant/guest/linux.rb +++ b/lib/vagrant/guest/linux.rb @@ -34,10 +34,10 @@ module Vagrant end end - def mount_shared_folder(name, guestpath, owner, group) + def mount_shared_folder(name, guestpath, options) @vm.channel.sudo("mkdir -p #{guestpath}") - mount_folder(name, guestpath, owner, group) - @vm.channel.sudo("chown `id -u #{owner}`:`id -g #{group}` #{guestpath}") + mount_folder(name, guestpath, options) + @vm.channel.sudo("chown `id -u #{options[:owner]}`:`id -g #{options[:group]}` #{guestpath}") end def mount_nfs(ip, folders) @@ -54,9 +54,9 @@ module Vagrant #------------------------------------------------------------------- # "Private" methods which assist above methods #------------------------------------------------------------------- - def mount_folder(name, guestpath, owner, group, sleeptime=5) + def mount_folder(name, guestpath, options) # Determine the permission string to attach to the mount command - options = "-o uid=`id -u #{owner}`,gid=`id -g #{group}`" + options = "-o uid=`id -u #{options[:owner]}`,gid=`id -g #{options[:group]}`" attempts = 0 while true @@ -69,7 +69,7 @@ module Vagrant attempts += 1 raise LinuxError, :mount_fail if attempts >= 10 - sleep sleeptime + sleep 5 end end end diff --git a/lib/vagrant/guest/solaris.rb b/lib/vagrant/guest/solaris.rb index 8c65ceab1..a2ae488dd 100644 --- a/lib/vagrant/guest/solaris.rb +++ b/lib/vagrant/guest/solaris.rb @@ -90,7 +90,11 @@ module Vagrant end # while end - def mount_shared_folder(name, guestpath, owner, group) + def mount_shared_folder(name, guestpath, options) + # These are just far easier to use than the full options syntax + owner = options[:owner] + group = options[:group] + # Create the shared folder vm.channel.execute("#{vm.config.solaris.suexec_cmd} mkdir -p #{guestpath}")