Allow non privileged user vagrant to run a shell provision

This commit is contained in:
Francisco R. Santos 2013-02-11 19:42:36 +01:00
parent 987b3008fe
commit 4a6e7c756b
2 changed files with 3 additions and 2 deletions

View File

@ -5,9 +5,11 @@ module VagrantPlugins
attr_accessor :path attr_accessor :path
attr_accessor :upload_path attr_accessor :upload_path
attr_accessor :args attr_accessor :args
attr_accessor :privileged
def initialize def initialize
@upload_path = "/tmp/vagrant-shell" @upload_path = "/tmp/vagrant-shell"
@privileged = true
end end
def validate(machine) def validate(machine)

View File

@ -14,8 +14,7 @@ module VagrantPlugins
@machine.communicate.tap do |comm| @machine.communicate.tap do |comm|
comm.upload(path.to_s, config.upload_path) comm.upload(path.to_s, config.upload_path)
# Execute it with sudo comm.execute(command, {:sudo => config.privileged}) do |type, data|
comm.sudo(command) do |type, data|
if [:stderr, :stdout].include?(type) if [:stderr, :stdout].include?(type)
# Output the data with the proper color based on the stream. # Output the data with the proper color based on the stream.
color = type == :stdout ? :green : :red color = type == :stdout ? :green : :red