diff --git a/lib/vagrant-lxc.rb b/lib/vagrant-lxc.rb index 825eb18..a1e3bf1 100644 --- a/lib/vagrant-lxc.rb +++ b/lib/vagrant-lxc.rb @@ -1,5 +1,6 @@ require "vagrant-lxc/version" require "vagrant-lxc/plugin" +require "vagrant-lxc/sudo_wrapper" module Vagrant module LXC @@ -10,5 +11,12 @@ module Vagrant def self.sudo_wrapper_path "/usr/local/bin/vagrant-lxc-wrapper" end + + def self.sudo_wrapper + wrapper = Pathname.new(sudo_wrapper_path).exist? && + sudo_wrapper_path || nil + SudoWrapper.new(wrapper) + end + end end diff --git a/lib/vagrant-lxc/command/sudoers.rb b/lib/vagrant-lxc/command/sudoers.rb index 0016c13..58752e7 100644 --- a/lib/vagrant-lxc/command/sudoers.rb +++ b/lib/vagrant-lxc/command/sudoers.rb @@ -1,5 +1,7 @@ require 'tempfile' +require "vagrant-lxc/driver" + module Vagrant module LXC module Command @@ -43,11 +45,13 @@ module Vagrant # This requires vagrant 1.5.2+ https://github.com/mitchellh/vagrant/commit/3371c3716278071680af9b526ba19235c79c64cb def create_wrapper! + lxc_base_path = Driver.new(0, LXC.sudo_wrapper).containers_path wrapper = Tempfile.new('lxc-wrapper').tap do |file| template = Vagrant::Util::TemplateRenderer.new( 'sudoers.rb', :template_root => Vagrant::LXC.source_root.join('templates').to_s, :cmd_paths => build_cmd_paths_hash, + :lxc_base_path => lxc_base_path, :pipework_regex => "#{ENV['HOME']}/\.vagrant\.d/gems/(?:\\d+?\\.\\d+?\\.\\d+?/)?gems/vagrant-lxc.+/scripts/pipework" ) file.puts template.render diff --git a/lib/vagrant-lxc/provider.rb b/lib/vagrant-lxc/provider.rb index dead6ab..806733d 100644 --- a/lib/vagrant-lxc/provider.rb +++ b/lib/vagrant-lxc/provider.rb @@ -2,7 +2,6 @@ require "log4r" require "vagrant-lxc/action" require "vagrant-lxc/driver" -require "vagrant-lxc/sudo_wrapper" module Vagrant module LXC @@ -26,12 +25,7 @@ module Vagrant end def sudo_wrapper - @shell ||= begin - wrapper = Pathname.new(LXC.sudo_wrapper_path).exist? && - LXC.sudo_wrapper_path || nil - @logger.debug("Found sudo wrapper : #{wrapper}") if wrapper - SudoWrapper.new(wrapper) - end + @shell ||= LXC.sudo_wrapper end def ensure_lxc_installed! diff --git a/templates/sudoers.rb.erb b/templates/sudoers.rb.erb index cfcb68a..6f91123 100644 --- a/templates/sudoers.rb.erb +++ b/templates/sudoers.rb.erb @@ -78,7 +78,7 @@ class Whitelist end end -base = "/var/lib/lxc" +base = "<%= lxc_base_path %>" base_path = %r{\A#{base}/.*\z} ##