]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
ifupdownmain: ifquery check read_iface_config errors
authorJulien Fortin <julien@cumulusnetworks.com>
Fri, 12 Jul 2019 18:46:56 +0000 (22:46 +0400)
committerJulien Fortin <julien@cumulusnetworks.com>
Wed, 18 Sep 2019 10:47:29 +0000 (12:47 +0200)
auto swp1
iface swp1
      typo_attribute 42

$ ifquery -ac
error: /etc/network/interfaces: line9: iface swp1: unsupported keyword (typo_attribute)
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp                                                [pass]

auto swp1
iface swp1

$ echo $?
1
$
$ echo $?
1
$ ifup -a
error: /etc/network/interfaces: line9: iface swp1: unsupported keyword (typo_attribute)
$ echo $?
1
$

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
ifupdown2/ifupdown/ifupdownmain.py

index f520994511d5486ecb585cc73cb7dc06779430d6..c7747287a30efe474581ddce1ad0e02c1d8edc40 100644 (file)
@@ -1800,6 +1800,9 @@ class ifupdownMain(ifupdownBase):
         if self.flags.STATEMANAGER_ENABLE and ops[0] == 'query-savedstate':
             return self.statemanager.dump_pretty(ifacenames)
         self.flags.STATEMANAGER_UPDATE = False
+
+        iface_read_ret = True
+
         if auto:
             self.logger.debug('setting flag ALL')
             ifupdownflags.flags.ALL = True
@@ -1814,7 +1817,7 @@ class ifupdownMain(ifupdownBase):
                                 ifacePrivFlags(False, True)), ifacenames)
         else:
             try:
-                self.read_iface_config()
+                iface_read_ret = self.read_iface_config()
             except Exception:
                 raise
 
@@ -1865,14 +1868,16 @@ class ifupdownMain(ifupdownBase):
         if ops[0] == 'query' and ifupdownflags.flags.WITHDEFAULTS:
             return self.print_ifaceobjs_pretty(filtered_ifacenames, format)
         elif ops[0] == 'query-checkcurr':
-            ret = self.print_ifaceobjscurr_pretty(filtered_ifacenames, format)
-            if ret != 0:
+            if self.print_ifaceobjscurr_pretty(filtered_ifacenames, format):
                 # if any of the object has an error, signal that silently
                 raise Exception('')
         elif ops[0] == 'query-running':
             self.print_ifaceobjsrunning_pretty(filtered_ifacenames, format)
             return
 
+        if not iface_read_ret or not ret:
+            raise Exception()
+
     def _reload_currentlyup(self, upops, downops, auto=False, allow=None,
             ifacenames=None, excludepats=None, usecurrentconfig=False,
             syntaxcheck=False, **extra_args):