From 43f3351bb2d2c2e80c68bc5c0368c8b5c7f2f9ce Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 26 Jan 2015 16:35:34 +0100 Subject: [PATCH] Make vagrant-lxc-wrapper sudo mechanism useful for system installed vagrant (on fedora) - different path for wrapper - uses vagrant group instead of per-user sudo - prefixes PATH with /usr/bin - use system path for piperwork script ... --- lib/vagrant-lxc.rb | 3 ++- lib/vagrant-lxc/command/sudoers.rb | 6 ++++-- templates/sudoers.rb.erb | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/vagrant-lxc.rb b/lib/vagrant-lxc.rb index 825eb18..1128549 100644 --- a/lib/vagrant-lxc.rb +++ b/lib/vagrant-lxc.rb @@ -8,7 +8,8 @@ module Vagrant end def self.sudo_wrapper_path - "/usr/local/bin/vagrant-lxc-wrapper" + #"/usr/local/bin/vagrant-lxc-wrapper" + "/usr/share/vagrant/gems/gems/vagrant-lxc-1.1.0/scripts/vagrant-lxc-wrapper" end end end diff --git a/lib/vagrant-lxc/command/sudoers.rb b/lib/vagrant-lxc/command/sudoers.rb index fcb2099..d75861b 100644 --- a/lib/vagrant-lxc/command/sudoers.rb +++ b/lib/vagrant-lxc/command/sudoers.rb @@ -48,7 +48,8 @@ module Vagrant 'sudoers.rb', :template_root => Vagrant::LXC.source_root.join('templates').to_s, :cmd_paths => build_cmd_paths_hash, - :pipework_regex => "#{ENV['HOME']}/\.vagrant\.d/gems/gems/vagrant-lxc.+/scripts/pipework" + #:pipework_regex => "#{ENV['HOME']}/\.vagrant\.d/gems/gems/vagrant-lxc.+/scripts/pipework" + :pipework_regex => "/usr/share/vagrant/gems/gems/vagrant-lxc.+/scripts/pipework" ) file.puts template.render end @@ -59,7 +60,8 @@ module Vagrant def create_sudoers!(user, command) sudoers = Tempfile.new('vagrant-lxc-sudoers').tap do |file| file.puts "# Automatically created by vagrant-lxc" - file.puts "#{user} ALL=(root) NOPASSWD: #{command}" + #file.puts "#{user} ALL=(root) NOPASSWD: #{command}" + file.puts "%vagrant ALL=(root) NOPASSWD: #{command}" end sudoers.close sudoers.path diff --git a/templates/sudoers.rb.erb b/templates/sudoers.rb.erb index 94db7f7..d7977bc 100644 --- a/templates/sudoers.rb.erb +++ b/templates/sudoers.rb.erb @@ -1,4 +1,4 @@ -#!/opt/vagrant/embedded/bin/ruby +#!/usr/bin/env ruby # Automatically created by vagrant-lxc class Whitelist @@ -31,7 +31,7 @@ class Whitelist def run!(argv) begin - command, args = `which #{argv.shift}`.chomp, argv || [] + command, args = `PATH=/usr/bin:$PATH which #{argv.shift}`.chomp, argv || [] check!(command, args) system "#{command} #{args.join(" ")}" -- 2.1.0