summaryrefslogtreecommitdiffstats
path: root/vagrant-lxc-sudo-wrapper.patch
blob: 925832a6e13b44f73e882d22d9ccd274c7239666 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
From 43f3351bb2d2c2e80c68bc5c0368c8b5c7f2f9ce Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox@samba.org>
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