Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a752ec13d |
6 changed files with 293 additions and 1 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
/vagrant-lxc-1.1.0.gem
|
||||
63
create_wrapper.rb
Normal file
63
create_wrapper.rb
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
# Create the vagrant-lxc sudo-wrapper from the template.
|
||||
# Roughly taken from lib/vagrant-lxc/command/sudoers.rb
|
||||
#
|
||||
# Michael Adam <obnox@samba.org>
|
||||
|
||||
require 'tempfile'
|
||||
|
||||
require "vagrant/util/template_renderer"
|
||||
|
||||
|
||||
class CreateWrapper
|
||||
class << self
|
||||
def run!(argv)
|
||||
raise "Argument missing" unless(argv)
|
||||
|
||||
template_root = argv.shift
|
||||
wrapper_dst = "./vagrant-lxc-wrapper"
|
||||
|
||||
wrapper_tmp = create_wrapper!(template_root)
|
||||
|
||||
system "cp #{wrapper_tmp} #{wrapper_dst}"
|
||||
puts "#{wrapper_dst} created"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# This requires vagrant 1.5.2+
|
||||
# https://github.com/mitchellh/vagrant/commit/3371c3716278071680af9b526ba19235c79c64cb
|
||||
def create_wrapper!(template_root)
|
||||
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,
|
||||
#:template_root => "/usr/share/vagrant/gems/gems/vagrant-lxc-1.1.0/templates",
|
||||
:template_root => template_root,
|
||||
:cmd_paths => build_cmd_paths_hash,
|
||||
#: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
|
||||
wrapper.close
|
||||
wrapper.path
|
||||
end
|
||||
|
||||
# for fedora, we know that all these commands
|
||||
# are found in /usr/bin ...
|
||||
def build_cmd_paths_hash
|
||||
{}.tap do |hash|
|
||||
%w( which cat mkdir cp chown chmod rm tar chown ip ifconfig brctl ).each do |cmd|
|
||||
#hash[cmd] = `which #{cmd}`.strip
|
||||
hash[cmd] = "/usr/bin/#{cmd}"
|
||||
end
|
||||
#hash['lxc_bin'] = Pathname(`which lxc-create`.strip).parent.to_s
|
||||
hash['lxc_bin'] = "/usr/bin"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
CreateWrapper.run!(ARGV)
|
||||
|
|
@ -1 +0,0 @@
|
|||
Orphaned for 6+ weeks
|
||||
1
sources
Normal file
1
sources
Normal file
|
|
@ -0,0 +1 @@
|
|||
7ecfc9d962fecd6aac8c3880ed0a00c3 vagrant-lxc-1.1.0.gem
|
||||
77
vagrant-lxc-sudo-wrapper.patch
Normal file
77
vagrant-lxc-sudo-wrapper.patch
Normal file
|
|
@ -0,0 +1,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
|
||||
|
||||
151
vagrant-lxc.spec
Normal file
151
vagrant-lxc.spec
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
%global vagrant_plugin_name vagrant-lxc
|
||||
|
||||
Name: %{vagrant_plugin_name}
|
||||
Version: 1.1.0
|
||||
Release: 7%{?dist}
|
||||
Summary: LXC provider for vagrant
|
||||
Group: Development/Languages
|
||||
License: MIT
|
||||
URL: https://github.com/fgrehm/vagrant-lxc
|
||||
Source0: https://rubygems.org/gems/%{vagrant_plugin_name}-%{version}.gem
|
||||
|
||||
# script needed to generate the vagrant-lxc sudo wrapper script from template.
|
||||
# part of this srpm
|
||||
Source1: create_wrapper.rb
|
||||
|
||||
Patch1: vagrant-lxc-sudo-wrapper.patch
|
||||
|
||||
Requires(pre): shadow-utils
|
||||
Requires(posttrans): vagrant
|
||||
Requires(preun): vagrant
|
||||
Requires: ruby(release)
|
||||
Requires: ruby(rubygems)
|
||||
Requires: lxc
|
||||
Requires: lxc-extra
|
||||
Requires: vagrant
|
||||
|
||||
BuildRequires: vagrant
|
||||
BuildRequires: rubygem(rspec) < 3
|
||||
BuildArch: noarch
|
||||
|
||||
%description
|
||||
LXC provider for vagrant.
|
||||
|
||||
%package doc
|
||||
Summary: Documentation for %{name}
|
||||
Group: Documentation
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
BuildArch: noarch
|
||||
|
||||
%description doc
|
||||
Documentation for %{name}.
|
||||
|
||||
%prep
|
||||
gem unpack %{SOURCE0}
|
||||
|
||||
%setup -q -D -T -n %{vagrant_plugin_name}-%{version}
|
||||
|
||||
%patch1 -p1
|
||||
|
||||
gem spec %{SOURCE0} -l --ruby > %{vagrant_plugin_name}.gemspec
|
||||
|
||||
|
||||
%build
|
||||
gem build %{vagrant_plugin_name}.gemspec
|
||||
%vagrant_plugin_install
|
||||
|
||||
%install
|
||||
mkdir -p %{buildroot}%{vagrant_plugin_dir}
|
||||
cp -a .%{vagrant_plugin_dir}/* \
|
||||
%{buildroot}%{vagrant_plugin_dir}/
|
||||
|
||||
ruby -I /usr/share/vagrant/lib %{SOURCE1} %{buildroot}%{vagrant_plugin_instdir}/templates
|
||||
install -m 0555 ./vagrant-lxc-wrapper %{buildroot}%{vagrant_plugin_instdir}/scripts/vagrant-lxc-wrapper
|
||||
|
||||
echo "%vagrant ALL=(root) NOPASSWD: %{vagrant_plugin_instdir}/scripts/vagrant-lxc-wrapper" > ./sudoers_file
|
||||
mkdir -p %{buildroot}%{_sysconfdir}/sudoers.d
|
||||
install -m 0440 ./sudoers_file %{buildroot}%{_sysconfdir}/sudoers.d/vagrant-lxc
|
||||
|
||||
# TODO: enable check.
|
||||
# currently rubygem-hitimes is missing, but
|
||||
# Problems building under f21 and newer:
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1068980
|
||||
#
|
||||
#%check
|
||||
#pushd .%{vagrant_plugin_instdir}
|
||||
#sed -i '/git/ s/^/#/' Gemfile
|
||||
#
|
||||
#bundle exec rspec2 spec
|
||||
#popd
|
||||
|
||||
%pre
|
||||
getent group vagrant >/dev/null || groupadd -r vagrant
|
||||
|
||||
%posttrans
|
||||
%vagrant_plugin_register %{vagrant_plugin_name}
|
||||
|
||||
|
||||
%preun
|
||||
%vagrant_plugin_unregister %{vagrant_plugin_name}
|
||||
|
||||
%files
|
||||
%dir %{vagrant_plugin_instdir}
|
||||
%license %{vagrant_plugin_instdir}/LICENSE.txt
|
||||
%doc %{vagrant_plugin_instdir}/README.md
|
||||
%{vagrant_plugin_libdir}
|
||||
%{vagrant_plugin_instdir}/locales
|
||||
%exclude %{vagrant_plugin_cache}
|
||||
%exclude %{vagrant_plugin_instdir}/.gitignore
|
||||
%{vagrant_plugin_spec}
|
||||
%attr(440, root, root) %{_sysconfdir}/sudoers.d/vagrant-lxc
|
||||
|
||||
%exclude %{vagrant_plugin_instdir}/.rspec
|
||||
%exclude %{vagrant_plugin_instdir}/.travis.yml
|
||||
%exclude %{vagrant_plugin_instdir}/.vimrc
|
||||
%{vagrant_plugin_instdir}/Gemfile.lock
|
||||
%dir %{vagrant_plugin_instdir}/scripts
|
||||
%{vagrant_plugin_instdir}/scripts/lxc-template
|
||||
%{vagrant_plugin_instdir}/scripts/pipework
|
||||
%attr(555, root, root) %{vagrant_plugin_instdir}/scripts/vagrant-lxc-wrapper
|
||||
%dir %{vagrant_plugin_instdir}/templates
|
||||
%{vagrant_plugin_instdir}/templates/sudoers.rb.erb
|
||||
|
||||
|
||||
%files doc
|
||||
%doc %{vagrant_plugin_docdir}
|
||||
%doc %{vagrant_plugin_instdir}/CHANGELOG.md
|
||||
%doc %{vagrant_plugin_instdir}/BOXES.md
|
||||
%doc %{vagrant_plugin_instdir}/CONTRIBUTING.md
|
||||
%{vagrant_plugin_instdir}/Rakefile
|
||||
%{vagrant_plugin_instdir}/Gemfile
|
||||
%{vagrant_plugin_instdir}/vagrant-lxc.gemspec
|
||||
%{vagrant_plugin_instdir}/spec
|
||||
%exclude %{vagrant_plugin_instdir}/spec/support/.gitkeep
|
||||
%{vagrant_plugin_instdir}/Guardfile
|
||||
%dir %{vagrant_plugin_instdir}/tasks
|
||||
%{vagrant_plugin_instdir}/tasks/spec.rake
|
||||
%{vagrant_plugin_instdir}/vagrant-spec.config.rb
|
||||
|
||||
%changelog
|
||||
* Wed Feb 18 2015 Michael Adam <madam@redhat.com> - 1.1.0-7
|
||||
- Add missing dependency for lxc-extra (BZ #1193438).
|
||||
|
||||
* Thu Jan 29 2015 Michael Adam <madam@redhat.com> - 1.1.0-6
|
||||
- Make some non-standard perms explicit in the files section.
|
||||
- Own directories that we create.
|
||||
|
||||
* Tue Jan 27 2015 Michael Adam <madam@redhat.com> - 1.1.0-5
|
||||
- Cleanup specfile.
|
||||
|
||||
* Mon Jan 26 2015 Michael Adam <madam@redhat.com> - 1.1.0-4
|
||||
- Ship precreated sudo-wrapper and sudoers file.
|
||||
|
||||
* Mon Jan 26 2015 Michael Adam <madam@redhat.com> - 1.1.0-3
|
||||
- Capitalize summary and description.
|
||||
- Fix sudo wrapper and "vagrant lxc sudoers" mechansim from upstream.
|
||||
|
||||
* Mon Jan 26 2015 Michael Adam <madam@redhat.com> - 1.1.0-2
|
||||
- Move some files from -doc to main package.
|
||||
|
||||
* Sat Jan 24 2015 Michael Adam <madam@redhat.com> - 1.1.0-1
|
||||
- Initial package for Fedora
|
||||
Loading…
Add table
Add a link
Reference in a new issue