From fb661300e7942f5dc331611c03d06b84d8780743 Mon Sep 17 00:00:00 2001 From: Michael Stucki Date: Mon, 6 Jul 2015 17:44:28 +0200 Subject: [PATCH 01/17] Move bridge_exists check into a function --- lib/vagrant-lxc/driver.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index 9fe0993..f39175a 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -164,6 +164,12 @@ module Vagrant `ip -4 addr show scope global #{bridge_name}` =~ /^\s+inet ([0-9.]+)\/[0-9]+\s+/ end + def bridge_exists?(bridge_name) + @logger.info "Checking whether bridge #{bridge_name} exists" + brctl_output = `ifconfig -a | grep -q #{bridge_name}` + $?.to_i == 0 + end + def bridge_is_in_use?(bridge_name) # REFACTOR: This method is **VERY** hacky @logger.info "Checking if bridge #{bridge_name} is in use" @@ -172,9 +178,7 @@ module Vagrant end def remove_bridge(bridge_name) - @logger.info "Checking whether bridge #{bridge_name} exists" - brctl_output = `ifconfig -a | grep -q #{bridge_name}` - return if $?.to_i != 0 + return unless bridge_exists?(bridge_name) @logger.info "Removing bridge #{bridge_name}" @sudo_wrapper.run('ifconfig', bridge_name, 'down') From c3508870fd8f9a1170bcd14d5459a49cc7581143 Mon Sep 17 00:00:00 2001 From: Michael Stucki Date: Mon, 6 Jul 2015 17:44:35 +0200 Subject: [PATCH 02/17] Private networking: Create bridge if it is missing --- lib/vagrant-lxc/driver.rb | 15 +++++++++++++++ templates/sudoers.rb.erb | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index f39175a..07f1ca1 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -134,6 +134,20 @@ module Vagrant ip += '/24' end + if ! bridge_exists?(bridge_name) + if not bridge_ip + raise "Bridge is missing and no IP was specified!" + end + + @logger.info "Creating the bridge #{bridge_name}" + cmd = [ + 'brctl', + 'addbr', + bridge_name + ] + @sudo_wrapper.run(*cmd) + end + if ! bridge_has_an_ip?(bridge_name) if not bridge_ip raise "Bridge has no IP and none was specified!" @@ -148,6 +162,7 @@ module Vagrant bridge_name ] @sudo_wrapper.run(*cmd) + @sudo_wrapper.run('ifconfig', bridge_name, 'up') end cmd = [ diff --git a/templates/sudoers.rb.erb b/templates/sudoers.rb.erb index e9e6fd5..18a8894 100644 --- a/templates/sudoers.rb.erb +++ b/templates/sudoers.rb.erb @@ -106,8 +106,8 @@ Whitelist.add '<%= cmd_paths['tar'] %>', '--numeric-owner', '-cvzf', %r{/tmp/.*/ Whitelist.add '<%= cmd_paths['chown'] %>', /\A\d+:\d+\z/, %r{\A/tmp/.*/rootfs\.tar\.gz\z} # - Private network script and commands Whitelist.add '<%= cmd_paths['ip'] %>', 'addr', 'add', /(\d+|\.)+\/24/, 'dev', /.+/ -Whitelist.add '<%= cmd_paths['ifconfig'] %>', /.+/, 'down' -Whitelist.add '<%= cmd_paths['brctl'] %>', 'delbr', /.+/ +Whitelist.add '<%= cmd_paths['ifconfig'] %>', /.+/, /(up|down)/ +Whitelist.add '<%= cmd_paths['brctl'] %>', /(addbr|delbr)/, /.+/ Whitelist.add_regex %r{<%= pipework_regex %>}, '**' ## From 31bb4eadf96db88c1efa5d975fe710b0b8fa49de Mon Sep 17 00:00:00 2001 From: Michael Stucki Date: Tue, 25 Aug 2015 10:18:02 +0200 Subject: [PATCH 03/17] Move away from using `ifconfig` to `ip link` for enabling / disabling bridge devices --- lib/vagrant-lxc/driver.rb | 6 +++--- templates/sudoers.rb.erb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index 07f1ca1..4683900 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -162,7 +162,7 @@ module Vagrant bridge_name ] @sudo_wrapper.run(*cmd) - @sudo_wrapper.run('ifconfig', bridge_name, 'up') + @sudo_wrapper.run('ip', 'link', 'set', bridge_name, 'up') end cmd = [ @@ -181,7 +181,7 @@ module Vagrant def bridge_exists?(bridge_name) @logger.info "Checking whether bridge #{bridge_name} exists" - brctl_output = `ifconfig -a | grep -q #{bridge_name}` + brctl_output = `ip link | grep -q #{bridge_name}` $?.to_i == 0 end @@ -196,7 +196,7 @@ module Vagrant return unless bridge_exists?(bridge_name) @logger.info "Removing bridge #{bridge_name}" - @sudo_wrapper.run('ifconfig', bridge_name, 'down') + @sudo_wrapper.run('ip', 'link', 'set', bridge_name, 'down') @sudo_wrapper.run('brctl', 'delbr', bridge_name) end diff --git a/templates/sudoers.rb.erb b/templates/sudoers.rb.erb index 18a8894..72c6ae2 100644 --- a/templates/sudoers.rb.erb +++ b/templates/sudoers.rb.erb @@ -106,7 +106,7 @@ Whitelist.add '<%= cmd_paths['tar'] %>', '--numeric-owner', '-cvzf', %r{/tmp/.*/ Whitelist.add '<%= cmd_paths['chown'] %>', /\A\d+:\d+\z/, %r{\A/tmp/.*/rootfs\.tar\.gz\z} # - Private network script and commands Whitelist.add '<%= cmd_paths['ip'] %>', 'addr', 'add', /(\d+|\.)+\/24/, 'dev', /.+/ -Whitelist.add '<%= cmd_paths['ifconfig'] %>', /.+/, /(up|down)/ +Whitelist.add '<%= cmd_paths['ip'] %>', 'link', 'set', /.+/, /(up|down)/ Whitelist.add '<%= cmd_paths['brctl'] %>', /(addbr|delbr)/, /.+/ Whitelist.add_regex %r{<%= pipework_regex %>}, '**' From 7eb3be37de66b7f8e8be58493ffef1db50c9fb3d Mon Sep 17 00:00:00 2001 From: Michael Stucki Date: Tue, 25 Aug 2015 10:20:21 +0200 Subject: [PATCH 04/17] driver.rb: Check for correct bridge device name --- lib/vagrant-lxc/driver.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index 4683900..93e7465 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -181,7 +181,7 @@ module Vagrant def bridge_exists?(bridge_name) @logger.info "Checking whether bridge #{bridge_name} exists" - brctl_output = `ip link | grep -q #{bridge_name}` + brctl_output = `ip link | egrep -q " #{bridge_name}:"` $?.to_i == 0 end From 64f561073c7a065bc291b5e7eab54e456434bb96 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Sun, 19 Jul 2015 12:05:53 -0300 Subject: [PATCH 05/17] forward_ports: bind to localhost only by default This has been raised as security concern on vagrant itself, and fixed there some time ago. --- lib/vagrant-lxc/action/forward_ports.rb | 4 +++- spec/unit/action/forward_ports_spec.rb | 16 ++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/vagrant-lxc/action/forward_ports.rb b/lib/vagrant-lxc/action/forward_ports.rb index 0d25da0..4e472fd 100644 --- a/lib/vagrant-lxc/action/forward_ports.rb +++ b/lib/vagrant-lxc/action/forward_ports.rb @@ -67,7 +67,9 @@ module Vagrant # TODO: Deprecate this behavior of "automagically" skipping ssh forwarded ports if type == :forwarded_port && options[:id] != 'ssh' - options.delete(:host_ip) if options.fetch(:host_ip, '').to_s.strip.empty? + if options.fetch(:host_ip, '').to_s.strip.empty? + options[:host_ip] = '127.0.0.1' + end mappings[options[:host]] = options end end diff --git a/spec/unit/action/forward_ports_spec.rb b/spec/unit/action/forward_ports_spec.rb index 4109891..09f6d78 100644 --- a/spec/unit/action/forward_ports_spec.rb +++ b/spec/unit/action/forward_ports_spec.rb @@ -38,21 +38,21 @@ describe Vagrant::LXC::Action::ForwardPorts do ) end - it 'skips --laddr parameter if host_ip is nil' do + it 'Uses 127.0.0.1 as default if host_ip is nil' do forward_conf.delete(:host_ip) subject.stub(system: true) subject.call(env) expect(subject).to have_received(:spawn).with( - "redir --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null" + "redir --laddr=127.0.0.1 --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null" ) end - it 'skips --laddr parameter if host_ip is a blank string' do + it 'Uses 127.0.0.1 by default if host_ip is a blank string' do forward_conf[:host_ip] = ' ' subject.stub(system: true) subject.call(env) expect(subject).to have_received(:spawn).with( - "redir --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null" + "redir --laddr=127.0.0.1 --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null" ) end @@ -86,21 +86,21 @@ describe Vagrant::LXC::Action::ForwardPorts do ) end - it 'skips --laddr parameter if host_ip is nil' do + it 'Uses 127.0.0.1 by default if host_ip is nil' do forward_conf.delete(:host_ip) subject.stub(system: true) subject.call(env) expect(subject).to have_received(:spawn).with( - "sudo redir --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null" + "sudo redir --laddr=127.0.0.1 --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null" ) end - it 'skips --laddr parameter if host_ip is a blank string' do + it 'Uses 127.0.0.1 by default if host_ip is a blank string' do forward_conf[:host_ip] = ' ' subject.stub(system: true) subject.call(env) expect(subject).to have_received(:spawn).with( - "sudo redir --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null" + "sudo redir --laddr=127.0.0.1 --lport=#{host_port} --caddr=#{container_ip} --cport=#{guest_port} 2>/dev/null" ) end end From e5a55d1020a6fac6865ca646d02ee09831e3b0b2 Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Thu, 14 May 2015 12:42:32 +0200 Subject: [PATCH 06/17] fix shebang in template --- scripts/lxc-template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/lxc-template b/scripts/lxc-template index 8036bba..50baf96 100755 --- a/scripts/lxc-template +++ b/scripts/lxc-template @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # This is a modified version of /usr/share/lxc/templates/lxc-download # that comes with ubuntu-lxc 1.0.0 stable from ppa changed to suit vagrant-lxc needs From 611a86ce84c59efcd602ed38230b27b41d4dd9f6 Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Thu, 14 May 2015 12:43:47 +0200 Subject: [PATCH 07/17] do not copy the lxc template instead use the full path --- lib/vagrant-lxc/driver.rb | 41 +++------------------------------------ spec/unit/driver_spec.rb | 2 +- templates/sudoers.rb.erb | 6 ------ 3 files changed, 4 insertions(+), 45 deletions(-) diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index 93e7465..5e87b8a 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -79,10 +79,8 @@ module Vagrant def create(name, backingstore, backingstore_options, template_path, config_file, template_options = {}) @cli.name = @container_name = name - import_template(template_path) do |template_name| - @logger.debug "Creating container..." - @cli.create template_name, backingstore, backingstore_options, config_file, template_options - end + @logger.debug "Creating container..." + @cli.create template_path, backingstore, backingstore_options, config_file, template_options end def share_folders(folders) @@ -92,7 +90,7 @@ module Vagrant end def share_folder(host_path, guest_path, mount_options = nil) - guest_path = guest_path.gsub(/^\//, '').gsub(' ', '\\\040') + guest_path = guest_path.gsub(/^\//, '').gsub(' ', '\\\040') mount_options = Array(mount_options || ['bind', 'create=dir']) host_path = host_path.to_s.gsub(' ', '\\\040') @customizations << ['mount.entry', "#{host_path} #{guest_path} none #{mount_options.join(',')} 0 0"] @@ -258,39 +256,6 @@ module Vagrant @sudo_wrapper.run 'chown', 'root:root', base_path.join('config').to_s end end - - def import_template(path) - template_name = "vagrant-tmp-#{@container_name}" - tmp_template_path = templates_path.join("lxc-#{template_name}").to_s - - @logger.info 'Copying LXC template into place' - @sudo_wrapper.run('cp', path, tmp_template_path) - @sudo_wrapper.run('chmod', '+x', tmp_template_path) - - yield template_name - ensure - @logger.info 'Removing LXC template' - if tmp_template_path - @sudo_wrapper.run('rm', tmp_template_path) - end - end - - TEMPLATES_PATH_LOOKUP = %w( - /usr/share/lxc/templates - /usr/lib/lxc/templates - /usr/lib64/lxc/templates - /usr/local/lib/lxc/templates - ) - def templates_path - return @templates_path if @templates_path - - path = TEMPLATES_PATH_LOOKUP.find { |candidate| File.directory?(candidate) } - if !path - raise Errors::TemplatesDirMissing.new paths: TEMPLATES_PATH_LOOKUP.inspect - end - - @templates_path = Pathname(path) - end end end end diff --git a/spec/unit/driver_spec.rb b/spec/unit/driver_spec.rb index 0aed4b5..571c2bf 100644 --- a/spec/unit/driver_spec.rb +++ b/spec/unit/driver_spec.rb @@ -54,7 +54,7 @@ describe Vagrant::LXC::Driver do it 'creates container with the right arguments' do expect(cli).to have_received(:create).with( - template_name, + template_path, backingstore, backingstore_opts, config_file, diff --git a/templates/sudoers.rb.erb b/templates/sudoers.rb.erb index 72c6ae2..cfcb68a 100644 --- a/templates/sudoers.rb.erb +++ b/templates/sudoers.rb.erb @@ -80,7 +80,6 @@ end base = "/var/lib/lxc" base_path = %r{\A#{base}/.*\z} -templates_path = %r{\A/usr/(share|lib|lib64|local/lib)/lxc/templates/.*\z} ## # Commands from provider.rb @@ -96,11 +95,6 @@ Whitelist.add '<%= cmd_paths['mkdir'] %>', '-p', base_path # - Container config customizations and pruning Whitelist.add '<%= cmd_paths['cp'] %>', '-f', %r{/tmp/.*}, base_path Whitelist.add '<%= cmd_paths['chown'] %>', 'root:root', base_path -# - Template import -Whitelist.add '<%= cmd_paths['cp'] %>', %r{\A.*\z}, templates_path -Whitelist.add '<%= cmd_paths['chmod'] %>', '+x', templates_path -# - Template removal -Whitelist.add '<%= cmd_paths['rm'] %>', templates_path # - Packaging Whitelist.add '<%= cmd_paths['tar'] %>', '--numeric-owner', '-cvzf', %r{/tmp/.*/rootfs.tar.gz}, '-C', base_path, './rootfs' Whitelist.add '<%= cmd_paths['chown'] %>', /\A\d+:\d+\z/, %r{\A/tmp/.*/rootfs\.tar\.gz\z} From fddd8cc2573f6304ce46eb67f3936bc6eaa9eb3b Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Sat, 18 Jul 2015 23:20:21 +0000 Subject: [PATCH 08/17] Update gems to resolve dependencies on NixOS --- Gemfile | 2 +- Gemfile.lock | 131 +++++++++++++++++++++++---------------------------- 2 files changed, 59 insertions(+), 74 deletions(-) diff --git a/Gemfile b/Gemfile index b0d8fc3..92fea22 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' group :development do - gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git', tag: 'v1.7.2' + gem 'vagrant', git: 'https://github.com/mitchellh/vagrant.git', tag: 'v1.7.4' gem 'guard' gem 'guard-rspec' gem 'rb-inotify' diff --git a/Gemfile.lock b/Gemfile.lock index 9b8e147..68d2007 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,12 +1,12 @@ GIT remote: https://github.com/fgrehm/vagrant-cachier.git - revision: 9f6b615e84364b851939a8e7ee8229fc0d276c73 + revision: 40dddfb368526948e769492a00a7937c5a044a4d specs: - vagrant-cachier (1.1.0) + vagrant-cachier (1.2.1) GIT remote: https://github.com/fgrehm/vagrant-pristine.git - revision: 503dbc47848c81d0fbfa6840491856f518d244a1 + revision: 6d044265db17451c606f000bf43437e95a742bb4 specs: vagrant-pristine (0.3.0) @@ -22,16 +22,16 @@ GIT GIT remote: https://github.com/mitchellh/vagrant.git - revision: 1cd667b243f4a263cd5322b6455165cc676b6f7f - tag: v1.7.2 + revision: 78ea5e4a78ce644717ab16d8001ab77430168f0f + tag: v1.7.4 specs: - vagrant (1.7.2) - bundler (>= 1.5.2, < 1.8.0) + vagrant (1.7.4) + bundler (>= 1.5.2, <= 1.10.5) childprocess (~> 0.5.0) erubis (~> 2.7.0) hashicorp-checkpoint (~> 0.1.1) - i18n (~> 0.6.0) - listen (~> 2.8.0) + i18n (>= 0.6.0, <= 0.8.0) + listen (~> 3.0.2) log4r (~> 1.1.9, < 1.1.11) net-scp (~> 1.1.0) net-sftp (~> 2.1) @@ -40,7 +40,8 @@ GIT rb-kqueue (~> 0.2.0) rest-client (>= 1.6.0, < 2.0) wdm (~> 0.1.0) - winrm (~> 1.1.3) + winrm (~> 1.3) + winrm-fs (~> 0.2.0) PATH remote: . @@ -50,52 +51,44 @@ PATH GEM remote: https://rubygems.org/ specs: - akami (1.2.2) - gyoku (>= 0.4.0) - nokogiri builder (3.2.2) - celluloid (0.16.0) - timers (~> 4.0.0) - childprocess (0.5.5) + childprocess (0.5.6) ffi (~> 1.0, >= 1.0.11) coderay (1.1.0) - coveralls (0.7.1) + coveralls (0.7.2) multi_json (~> 1.3) - rest-client + rest-client (= 1.6.7) simplecov (>= 0.7) - term-ansicolor - thor + term-ansicolor (= 1.2.2) + thor (= 0.18.1) diff-lcs (1.2.5) docile (1.1.5) erubis (2.7.0) - ffi (1.9.6) + ffi (1.9.10) formatador (0.2.5) - gssapi (1.0.3) + gssapi (1.2.0) ffi (>= 1.0.1) - guard (2.11.1) + guard (2.12.8) formatador (>= 0.2.4) - listen (~> 2.7) + listen (>= 2.7, <= 4.0) lumberjack (~> 1.0) nenv (~> 0.1) notiffany (~> 0.0) pry (>= 0.9.12) shellany (~> 0.0) thor (>= 0.18.1) - guard-compat (1.2.0) - guard-rspec (4.5.0) + guard-compat (1.2.1) + guard-rspec (4.6.2) guard (~> 2.1) guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) - gyoku (1.2.2) + gyoku (1.3.1) builder (>= 2.1.2) hashicorp-checkpoint (0.1.4) - hitimes (1.2.2) httpclient (2.6.0.1) - httpi (0.9.7) - rack - i18n (0.6.11) - listen (2.8.5) - celluloid (>= 0.15.2) + i18n (0.7.0) + json (1.8.3) + listen (3.0.2) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) little-plugger (1.1.3) @@ -105,36 +98,33 @@ GEM multi_json (>= 1.8.4) lumberjack (1.0.9) method_source (0.8.2) - mime-types (2.4.3) + mime-types (2.6.1) mini_portile (0.6.0) - multi_json (1.10.1) - nenv (0.1.1) + multi_json (1.11.2) + nenv (0.2.0) net-scp (1.1.2) net-ssh (>= 2.6.5) net-sftp (2.1.2) net-ssh (>= 2.6.5) - net-ssh (2.9.1) - netrc (0.10.2) + net-ssh (2.9.2) nokogiri (1.6.3.1) mini_portile (= 0.6.0) - nori (1.1.5) - notiffany (0.0.2) + nori (2.6.0) + notiffany (0.0.6) nenv (~> 0.1) shellany (~> 0.0) pry (0.10.1) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - rack (1.6.0) rake (10.4.2) - rb-fsevent (0.9.4) + rb-fsevent (0.9.5) rb-inotify (0.9.5) ffi (>= 0.5.0) - rb-kqueue (0.2.3) + rb-kqueue (0.2.4) ffi (>= 0.5.0) - rest-client (1.7.2) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) + rest-client (1.6.7) + mime-types (>= 1.16) rspec (2.99.0) rspec-core (~> 2.99.0) rspec-expectations (~> 2.99.0) @@ -142,42 +132,37 @@ GEM rspec-core (2.99.2) rspec-expectations (2.99.2) diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.99.2) - rubyntlm (0.1.1) - savon (0.9.5) - akami (~> 1.0) - builder (>= 2.1.2) - gyoku (>= 0.4.0) - httpi (~> 0.9) - nokogiri (>= 1.4.0) - nori (~> 1.0) - wasabi (~> 1.0) + rspec-mocks (2.99.4) + rubyntlm (0.4.0) + rubyzip (1.1.7) shellany (0.0.1) - simplecov (0.9.1) + simplecov (0.10.0) docile (~> 1.1.0) - multi_json (~> 1.0) - simplecov-html (~> 0.8.0) - simplecov-html (0.8.0) + json (~> 1.8) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.0) slop (3.6.0) - term-ansicolor (1.3.0) - tins (~> 1.0) + term-ansicolor (1.2.2) + tins (~> 0.8) thor (0.18.1) - timers (4.0.1) - hitimes - tins (1.3.3) + tins (0.13.2) uuidtools (2.1.5) vagrant-omnibus (1.4.1) - wasabi (1.0.0) - nokogiri (>= 1.4.0) - wdm (0.1.0) - winrm (1.1.3) - gssapi (~> 1.0.0) + wdm (0.1.1) + winrm (1.3.3) + builder (>= 2.1.2) + gssapi (~> 1.2) + gyoku (~> 1.0) httpclient (~> 2.2, >= 2.2.0.2) logging (~> 1.6, >= 1.6.1) - nokogiri (~> 1.5) - rubyntlm (~> 0.1.1) - savon (= 0.9.5) + nori (~> 2.0) + rubyntlm (~> 0.4.0) uuidtools (~> 2.1.2) + winrm-fs (0.2.0) + erubis (~> 2.7) + logging (~> 1.6, >= 1.6.1) + rubyzip (~> 1.1) + winrm (~> 1.3.0) PLATFORMS ruby From ea99d13f7658f04e98b8215fa68f44dfb5cc9ff3 Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Sat, 18 Jul 2015 23:21:31 +0000 Subject: [PATCH 09/17] Fix test on NixOS Tempfile can be created in /run, too. --- spec/unit/driver_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/unit/driver_spec.rb b/spec/unit/driver_spec.rb index 571c2bf..9851acd 100644 --- a/spec/unit/driver_spec.rb +++ b/spec/unit/driver_spec.rb @@ -97,7 +97,7 @@ describe Vagrant::LXC::Driver do before do sudo.should_receive(:run).with('cat', '/var/lib/lxc/name/config').exactly(2).times. and_return('# CONFIGURATION') - sudo.should_receive(:run).twice.with('cp', '-f', %r{/tmp/.*}, '/var/lib/lxc/name/config') + sudo.should_receive(:run).twice.with('cp', '-f', %r{/(run|tmp)/.*}, '/var/lib/lxc/name/config') sudo.should_receive(:run).twice.with('chown', 'root:root', '/var/lib/lxc/name/config') subject.customizations << internal_customization From 993e430cccf5fddf9a92dffbbabe0aa5ff6001d0 Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Sun, 2 Aug 2015 10:13:40 +0000 Subject: [PATCH 10/17] Use /usr/bin/env CMD instead of hardcoded paths This fixes commands that currently rely on hardcoded paths and break on systems like NixOS that don't have all binaries in /usr/bin etc. --- lib/vagrant-lxc/provider.rb | 2 +- lib/vagrant-lxc/sudo_wrapper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-lxc/provider.rb b/lib/vagrant-lxc/provider.rb index ab56279..dead6ab 100644 --- a/lib/vagrant-lxc/provider.rb +++ b/lib/vagrant-lxc/provider.rb @@ -36,7 +36,7 @@ module Vagrant def ensure_lxc_installed! begin - sudo_wrapper.run("/usr/bin/which", "lxc-create") + sudo_wrapper.run("which", "lxc-create") rescue Vagrant::LXC::Errors::ExecuteError raise Errors::LxcNotInstalled end diff --git a/lib/vagrant-lxc/sudo_wrapper.rb b/lib/vagrant-lxc/sudo_wrapper.rb index 406c0f0..f344d9f 100644 --- a/lib/vagrant-lxc/sudo_wrapper.rb +++ b/lib/vagrant-lxc/sudo_wrapper.rb @@ -14,7 +14,7 @@ module Vagrant def run(*command) options = command.last.is_a?(Hash) ? command.last : {} command.unshift @wrapper_path if @wrapper_path && !options[:no_wrapper] - execute *(['sudo'] + command) + execute *(['sudo', '/usr/bin/env'] + command) end private From 2accd886fa4e0e3396f42000f11d37588651b4a4 Mon Sep 17 00:00:00 2001 From: Cam Cope Date: Sun, 5 Apr 2015 18:35:17 -0700 Subject: [PATCH 11/17] remove /tmp cleanup, fixes lvm rootfs --- lib/vagrant-lxc/action.rb | 2 -- .../action/remove_temporary_files.rb | 23 ------------------- 2 files changed, 25 deletions(-) delete mode 100644 lib/vagrant-lxc/action/remove_temporary_files.rb diff --git a/lib/vagrant-lxc/action.rb b/lib/vagrant-lxc/action.rb index 49f0707..0b2a82a 100644 --- a/lib/vagrant-lxc/action.rb +++ b/lib/vagrant-lxc/action.rb @@ -13,7 +13,6 @@ require 'vagrant-lxc/action/handle_box_metadata' require 'vagrant-lxc/action/prepare_nfs_settings' require 'vagrant-lxc/action/prepare_nfs_valid_ids' require 'vagrant-lxc/action/private_networks' -require 'vagrant-lxc/action/remove_temporary_files' require 'vagrant-lxc/action/setup_package_files' require 'vagrant-lxc/action/warn_networks' @@ -126,7 +125,6 @@ module Vagrant end b2.use ClearForwardedPorts - b2.use RemoveTemporaryFiles b2.use GcPrivateNetworkBridges b2.use Builtin::Call, Builtin::GracefulHalt, :stopped, :running do |env2, b3| if !env2[:result] diff --git a/lib/vagrant-lxc/action/remove_temporary_files.rb b/lib/vagrant-lxc/action/remove_temporary_files.rb deleted file mode 100644 index 81a2f11..0000000 --- a/lib/vagrant-lxc/action/remove_temporary_files.rb +++ /dev/null @@ -1,23 +0,0 @@ -module Vagrant - module LXC - module Action - class RemoveTemporaryFiles - def initialize(app, env) - @app = app - @logger = Log4r::Logger.new("vagrant::lxc::action::remove_tmp_files") - end - - def call(env) - # Continue execution, we need the container to be stopped - @app.call env - - if env[:machine].state.id == :stopped - @logger.debug 'Removing temporary files' - tmp_path = env[:machine].provider.driver.rootfs_path.join('tmp') - env[:machine].provider.sudo_wrapper.run('rm', '-rf', "#{tmp_path}/*") - end - end - end - end - end -end From 9b70f3daab3917ca50f888dd6385d41098d8887e Mon Sep 17 00:00:00 2001 From: Cam Cope Date: Mon, 17 Aug 2015 14:23:55 -0700 Subject: [PATCH 12/17] make /tmp a tmpfs --- lib/vagrant-lxc/action/boot.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/vagrant-lxc/action/boot.rb b/lib/vagrant-lxc/action/boot.rb index 90b783f..08d331d 100644 --- a/lib/vagrant-lxc/action/boot.rb +++ b/lib/vagrant-lxc/action/boot.rb @@ -26,6 +26,9 @@ module Vagrant config.customize 'mount.entry', '/sys/fs/selinux sys/fs/selinux none bind,ro 0 0' end + # Make /tmp a tmpfs to prevent init scripts from nuking synced folders mounted in here + config.customize 'mount.entry', 'tmpfs tmp tmpfs nodev,nosuid,size=2G 0 0' + env[:ui].info I18n.t("vagrant_lxc.messages.starting") env[:machine].provider.driver.start(config.customizations) From 6136ebb9663ea7ca36b20c0c7d18c204d79288ad Mon Sep 17 00:00:00 2001 From: Andriy Date: Mon, 16 Mar 2015 19:34:40 +0200 Subject: [PATCH 13/17] Update driver.rb Fixing https://github.com/fgrehm/vagrant-lxc/issues/353 issue --- lib/vagrant-lxc/driver.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index 5e87b8a..918dbd7 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -191,6 +191,11 @@ module Vagrant end def remove_bridge(bridge_name) + if bridge_name == "lxcbr0" + @logger.info "Skipping removal system bridge #{bridge_name}" + return + end + return unless bridge_exists?(bridge_name) @logger.info "Removing bridge #{bridge_name}" From 06bbc7a5ef231518a8cf8d41d642660e8e6e3741 Mon Sep 17 00:00:00 2001 From: Andriy Date: Mon, 23 Mar 2015 11:03:22 +0200 Subject: [PATCH 14/17] Update gc_private_network_bridges.rb --- lib/vagrant-lxc/action/gc_private_network_bridges.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/vagrant-lxc/action/gc_private_network_bridges.rb b/lib/vagrant-lxc/action/gc_private_network_bridges.rb index dc33a92..c6d358e 100644 --- a/lib/vagrant-lxc/action/gc_private_network_bridges.rb +++ b/lib/vagrant-lxc/action/gc_private_network_bridges.rb @@ -35,8 +35,9 @@ module Vagrant if ! driver.bridge_is_in_use?(bridge) env[:ui].info I18n.t("vagrant_lxc.messages.remove_bridge", name: bridge) - # TODO: Output that bridge is being removed - driver.remove_bridge(bridge) + if bridge_name != "lxcbr0" + driver.remove_bridge(bridge) + end end end end From 3257bd25bb1bd2815ef91365134664815ec1033b Mon Sep 17 00:00:00 2001 From: Michael Stucki Date: Mon, 6 Jul 2015 18:12:25 +0200 Subject: [PATCH 15/17] Fix variable name --- lib/vagrant-lxc/action/gc_private_network_bridges.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-lxc/action/gc_private_network_bridges.rb b/lib/vagrant-lxc/action/gc_private_network_bridges.rb index c6d358e..946283e 100644 --- a/lib/vagrant-lxc/action/gc_private_network_bridges.rb +++ b/lib/vagrant-lxc/action/gc_private_network_bridges.rb @@ -35,7 +35,7 @@ module Vagrant if ! driver.bridge_is_in_use?(bridge) env[:ui].info I18n.t("vagrant_lxc.messages.remove_bridge", name: bridge) - if bridge_name != "lxcbr0" + if bridge != "lxcbr0" driver.remove_bridge(bridge) end end From 9e5637a9fed516d3ba036bd80de66187ebaea216 Mon Sep 17 00:00:00 2001 From: Michael Stucki Date: Tue, 25 Aug 2015 14:36:59 +0200 Subject: [PATCH 16/17] Do not remove system bridge virbr0 --- lib/vagrant-lxc/action/gc_private_network_bridges.rb | 4 ++-- lib/vagrant-lxc/driver.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/vagrant-lxc/action/gc_private_network_bridges.rb b/lib/vagrant-lxc/action/gc_private_network_bridges.rb index 946283e..8bb31f8 100644 --- a/lib/vagrant-lxc/action/gc_private_network_bridges.rb +++ b/lib/vagrant-lxc/action/gc_private_network_bridges.rb @@ -35,8 +35,8 @@ module Vagrant if ! driver.bridge_is_in_use?(bridge) env[:ui].info I18n.t("vagrant_lxc.messages.remove_bridge", name: bridge) - if bridge != "lxcbr0" - driver.remove_bridge(bridge) + unless ['lxcbr0', 'virbr0'].include? bridge + driver.remove_bridge(bridge) end end end diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index 918dbd7..d205670 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -191,7 +191,7 @@ module Vagrant end def remove_bridge(bridge_name) - if bridge_name == "lxcbr0" + if ['lxcbr0', 'virbr0'].include? bridge_name @logger.info "Skipping removal system bridge #{bridge_name}" return end From 7c778dfb4d171902da040e627b2b61bd644be843 Mon Sep 17 00:00:00 2001 From: Michael Stucki Date: Tue, 25 Aug 2015 14:37:31 +0200 Subject: [PATCH 17/17] Fix warning message --- lib/vagrant-lxc/driver.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant-lxc/driver.rb b/lib/vagrant-lxc/driver.rb index d205670..e2304bf 100644 --- a/lib/vagrant-lxc/driver.rb +++ b/lib/vagrant-lxc/driver.rb @@ -192,7 +192,7 @@ module Vagrant def remove_bridge(bridge_name) if ['lxcbr0', 'virbr0'].include? bridge_name - @logger.info "Skipping removal system bridge #{bridge_name}" + @logger.info "Skipping removal of system bridge #{bridge_name}" return end