diff --git a/lib/vagrant.rb b/lib/vagrant.rb index 5324c8950..af527fa95 100644 --- a/lib/vagrant.rb +++ b/lib/vagrant.rb @@ -254,6 +254,12 @@ if I18n.config.respond_to?(:enforce_available_locales=) I18n.config.enforce_available_locales = true end +if Vagrant.enable_resolv_replace + global_logger.info("resolv replacement has been enabled!") +else + global_logger.warn("resolv replacement has not been enabled!") +end + # Setup the plugin manager and load any defined plugins require_relative "vagrant/plugin/manager" plugins = Vagrant::Plugin::Manager.instance.installed_plugins diff --git a/lib/vagrant/shared_helpers.rb b/lib/vagrant/shared_helpers.rb index 2b0f767d6..e2b18ca88 100644 --- a/lib/vagrant/shared_helpers.rb +++ b/lib/vagrant/shared_helpers.rb @@ -129,4 +129,20 @@ module Vagrant true end end + + # Use Ruby Resolv in place of libc + # + # @return [boolean] enabled or not + def self.enable_resolv_replace + if !ENV["VAGRANT_DISABLE_RESOLV_REPLACE"] + begin + require "resolv-replace" + true + rescue + false + end + else + false + end + end end diff --git a/website/source/docs/other/environmental-variables.html.md b/website/source/docs/other/environmental-variables.html.md index c28df34d3..67d4483f8 100644 --- a/website/source/docs/other/environmental-variables.html.md +++ b/website/source/docs/other/environmental-variables.html.md @@ -218,3 +218,9 @@ If set, this will disable the ability to create symlinks with all virtualbox shared folders. Defaults to true if the option is not set. This can be overriden on a per-folder basis within your Vagrantfile config by settings the `SharedFoldersEnableSymlinksCreate` option to true. + +## `VAGRANT_DISABLE_RESOLV_REPLACE` + +Vagrant will automatically load `resolv-replace` to use Ruby's Resolv library +in place of the libc resolver. This behavior can be disabled by setting this +environment variable.