hosts/bsd: don't execute shell for sudo commands [GH-2808]
This commit is contained in:
parent
a241c9ac59
commit
b8601423c7
|
@ -56,6 +56,7 @@ BUG FIXES:
|
||||||
rather than at runtime.
|
rather than at runtime.
|
||||||
- guests/redhat: Set hostname to FQDN, per the documentation for RedHat.
|
- guests/redhat: Set hostname to FQDN, per the documentation for RedHat.
|
||||||
[GH-2792]
|
[GH-2792]
|
||||||
|
- hosts/bsd: Don't invoke shell for NFS sudo calls. [GH-2808]
|
||||||
- providers/virtualbox: Enabling internal networks by just setting "true"
|
- providers/virtualbox: Enabling internal networks by just setting "true"
|
||||||
works properly. [GH-2751]
|
works properly. [GH-2751]
|
||||||
- provisioners/chef: When chowning folders, don't follow symlinks.
|
- provisioners/chef: When chowning folders, don't follow symlinks.
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
require "log4r"
|
require "log4r"
|
||||||
|
|
||||||
require "vagrant/util"
|
require "vagrant/util"
|
||||||
|
require "vagrant/util/shell_quote"
|
||||||
|
|
||||||
module VagrantPlugins
|
module VagrantPlugins
|
||||||
module HostBSD
|
module HostBSD
|
||||||
|
@ -102,14 +103,13 @@ module VagrantPlugins
|
||||||
|
|
||||||
# Output the rendered template into the exports
|
# Output the rendered template into the exports
|
||||||
output.split("\n").each do |line|
|
output.split("\n").each do |line|
|
||||||
line.gsub!('"', '\"')
|
line = Vagrant::Util::ShellQuote.escape(line, "'")
|
||||||
line.gsub!("'", "'\\\\''")
|
system("sudo", "-s", "--", "echo '#{line}' >> /etc/exports")
|
||||||
system(%Q[sudo -s -- "echo '#{line}' >> /etc/exports"])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# We run restart here instead of "update" just in case nfsd
|
# We run restart here instead of "update" just in case nfsd
|
||||||
# is not starting
|
# is not starting
|
||||||
system(nfs_restart_command)
|
system(*nfs_restart_command)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.nfs_exports_template(environment)
|
def self.nfs_exports_template(environment)
|
||||||
|
@ -152,7 +152,7 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.nfs_restart_command(environment)
|
def self.nfs_restart_command(environment)
|
||||||
"sudo nfsd restart"
|
["sudo", "nfsd", "restart"]
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
@ -168,7 +168,10 @@ module VagrantPlugins
|
||||||
|
|
||||||
# Use sed to just strip out the block of code which was inserted
|
# Use sed to just strip out the block of code which was inserted
|
||||||
# by Vagrant, and restart NFS.
|
# 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
|
end
|
||||||
|
|
||||||
def self.nfs_checkexports!
|
def self.nfs_checkexports!
|
||||||
|
|
|
@ -23,7 +23,7 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.nfs_restart_command(environment)
|
def self.nfs_restart_command(environment)
|
||||||
"sudo /etc/rc.d/mountd onereload"
|
["sudo", "/etc/rc.d/mountd", "onereload"]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue