From 496f2a2be48ec44c49dc42f77403e5f24766ae48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez?= Date: Wed, 6 Jul 2022 15:16:49 +0200 Subject: [PATCH] M #: catch iptables version command exceptions (#2223) (cherry picked from commit 8103c4bceb334a818f9c9d19ad00f6d84286c5e1) --- src/vnm_mad/remotes/lib/command.rb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/vnm_mad/remotes/lib/command.rb b/src/vnm_mad/remotes/lib/command.rb index 419d14746c..7f047776c6 100644 --- a/src/vnm_mad/remotes/lib/command.rb +++ b/src/vnm_mad/remotes/lib/command.rb @@ -38,14 +38,17 @@ module VNMMAD :ipset => 'sudo -n ipset' } - # Adjust :ip[6]tables commands to work with legacy version - stdout = Open3.capture3('sudo iptables --version')[0] - regex = /.*v(?\d+.\d+.\d+)/ - iptables_version = Gem::Version.new(stdout.match(regex)[:version]) + # Adjust :ip[6]tables commands to work with legacy versions + begin + stdout = Open3.capture3('sudo iptables --version')[0] + regex = /.*v(?\d+.\d+.\d+)/ + iptables_version = Gem::Version.new(stdout.match(regex)[:version]) - if Gem::Version.new('1.6.1') > iptables_version - COMMANDS[:iptables] = 'sudo -n iptables -w 3' - COMMANDS[:ip6tables] = 'sudo -n ip6tables -w 3' + if Gem::Version.new('1.6.1') > iptables_version + COMMANDS[:iptables] = 'sudo -n iptables -w 3' + COMMANDS[:ip6tables] = 'sudo -n ip6tables -w 3' + end + rescue StandardError end # Represents an Array of commands to be executed by the networking