From 31bb4eadf96db88c1efa5d975fe710b0b8fa49de Mon Sep 17 00:00:00 2001 From: Michael Stucki Date: Tue, 25 Aug 2015 10:18:02 +0200 Subject: [PATCH] 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 %>}, '**'