hosts/bsd: don't execute shell for sudo commands [GH-2808]

This commit is contained in:
Mitchell Hashimoto 2014-01-12 22:34:45 -08:00
parent a241c9ac59
commit b8601423c7
3 changed files with 11 additions and 7 deletions

View File

@ -56,6 +56,7 @@ BUG FIXES:
rather than at runtime.
- guests/redhat: Set hostname to FQDN, per the documentation for RedHat.
[GH-2792]
- hosts/bsd: Don't invoke shell for NFS sudo calls. [GH-2808]
- providers/virtualbox: Enabling internal networks by just setting "true"
works properly. [GH-2751]
- provisioners/chef: When chowning folders, don't follow symlinks.

View File

@ -1,6 +1,7 @@
require "log4r"
require "vagrant/util"
require "vagrant/util/shell_quote"
module VagrantPlugins
module HostBSD
@ -102,14 +103,13 @@ module VagrantPlugins
# Output the rendered template into the exports
output.split("\n").each do |line|
line.gsub!('"', '\"')
line.gsub!("'", "'\\\\''")
system(%Q[sudo -s -- "echo '#{line}' >> /etc/exports"])
line = Vagrant::Util::ShellQuote.escape(line, "'")
system("sudo", "-s", "--", "echo '#{line}' >> /etc/exports")
end
# We run restart here instead of "update" just in case nfsd
# is not starting
system(nfs_restart_command)
system(*nfs_restart_command)
end
def self.nfs_exports_template(environment)
@ -152,7 +152,7 @@ module VagrantPlugins
end
def self.nfs_restart_command(environment)
"sudo nfsd restart"
["sudo", "nfsd", "restart"]
end
protected
@ -168,7 +168,10 @@ module VagrantPlugins
# Use sed to just strip out the block of code which was inserted
# by Vagrant, and restart NFS.
system("sudo sed -E -e '/^# VAGRANT-BEGIN:( #{user})? #{id}/,/^# VAGRANT-END:( #{user})? #{id}/ d' -ibak /etc/exports")
system(
"sudo", "sed", "-E", "-e",
"/^# VAGRANT-BEGIN:( #{user})? #{id}/,/^# VAGRANT-END:( #{user})? #{id}/ d",
"-ibak", "/etc/exports")
end
def self.nfs_checkexports!

View File

@ -23,7 +23,7 @@ module VagrantPlugins
end
def self.nfs_restart_command(environment)
"sudo /etc/rc.d/mountd onereload"
["sudo", "/etc/rc.d/mountd", "onereload"]
end
end
end