From 06e398ff474b666f37014fed74f51507e563a2a3 Mon Sep 17 00:00:00 2001 From: Roopa Prabhu Date: Thu, 9 Jul 2015 11:07:06 -0700 Subject: [PATCH 1/2] Move interface name check to networkinterfaces.py where all other parse errors are reported Ticket: CM-5882 Reviewed By: stannous Testing Done: Tested with a long interface name --- ifupdown/ifupdownmain.py | 13 ------------- ifupdown/networkinterfaces.py | 4 ++++ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/ifupdown/ifupdownmain.py b/ifupdown/ifupdownmain.py index ef0392e..f7ea7f4 100644 --- a/ifupdown/ifupdownmain.py +++ b/ifupdown/ifupdownmain.py @@ -754,7 +754,6 @@ class ifupdownMain(ifupdownBase): """ new_ifacenames = [] err_iface = '' - ifnamsiz_error = '' for i in ifacenames: ifaceobjs = self.get_ifaceobjs(i) if not ifaceobjs: @@ -766,19 +765,13 @@ class ifupdownMain(ifupdownBase): if not ifaceobjs: err_iface += ' ' + ri else: - if utils.check_ifname_size_invalid(ri): - ifnamsiz_error += ' ' + ri new_ifacenames.append(ri) else: err_iface += ' ' + i else: - if utils.check_ifname_size_invalid(i): - ifnamsiz_error += ' ' + i new_ifacenames.append(i) if err_iface: raise Exception('cannot find interfaces:%s' %err_iface) - if ifnamsiz_error: - raise Exception('the following interface names are too long:%s' %ifnamsiz_error) return new_ifacenames def _iface_whitelisted(self, auto, allow_classes, excludepats, ifacename): @@ -943,8 +936,6 @@ class ifupdownMain(ifupdownBase): else: self.populate_dependency_info(ops) - if filtered_ifacenames: - filtered_ifacenames = self._preprocess_ifacenames(filtered_ifacenames) try: self._sched_ifaces(filtered_ifacenames, ops, skipupperifaces=skipupperifaces, @@ -1074,8 +1065,6 @@ class ifupdownMain(ifupdownBase): elif ops[0] == 'query-raw': return self.print_ifaceobjs_raw(filtered_ifacenames) - if filtered_ifacenames: - filtered_ifacenames = self._preprocess_ifacenames(filtered_ifacenames) self._sched_ifaces(filtered_ifacenames, ops, followdependents=True if self.WITH_DEPENDS else False) @@ -1160,7 +1149,6 @@ class ifupdownMain(ifupdownBase): return self.logger.info('reload: scheduling up on interfaces: %s' %str(interfaces_to_up)) - interfaces_to_up = self._preprocess_ifacenames(interfaces_to_up) self._sched_ifaces(interfaces_to_up, upops, followdependents=True if self.WITH_DEPENDS else False) if self.DRYRUN: @@ -1278,7 +1266,6 @@ class ifupdownMain(ifupdownBase): self.logger.info('reload: scheduling up on interfaces: %s' %str(filtered_ifacenames)) - filtered_ifacenames = self._preprocess_ifacenames(filtered_ifacenames) try: self._sched_ifaces(filtered_ifacenames, upops, followdependents=True if self.WITH_DEPENDS else False) diff --git a/ifupdown/networkinterfaces.py b/ifupdown/networkinterfaces.py index f241e45..9fe366e 100644 --- a/ifupdown/networkinterfaces.py +++ b/ifupdown/networkinterfaces.py @@ -219,6 +219,10 @@ class networkInterfaces(): iface_attrs = re.split(self._ws_split_regex, iface_line) ifacename = iface_attrs[1] + if utils.check_ifname_size_invalid(ifacename): + self._parse_warn(self._currentfile, lineno, + '%s: interface name too long' %ifacename) + # in cases where mako is unable to render the template # or incorrectly renders it due to user template # errors, we maybe left with interface names with From 29de56fe14f2bb8b6d1e9d2cb29a94c28650879c Mon Sep 17 00:00:00 2001 From: Sam Tannous Date: Mon, 13 Jul 2015 11:12:44 -0400 Subject: [PATCH 2/2] apt-get remove of python-ifupdown2 fails due to postrm script error Ticket: CM-6655 Reviewed By: Trivial Testing Done: tested install and removal of python-ifupdown2 There was an invalid equality test in the postrm script for ifupdown2. In Dash, equality is tested with a single '=' and not '=='. --- debian/python-ifupdown2.postrm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/python-ifupdown2.postrm b/debian/python-ifupdown2.postrm index fe68eb4..6e6ab05 100644 --- a/debian/python-ifupdown2.postrm +++ b/debian/python-ifupdown2.postrm @@ -21,9 +21,9 @@ set -e process_udev() { udevlink=$(readlink /etc/udev/rules.d/80-networking.rules 2>/dev/null || true) - [ -n "$udevlink" -a "$udevlink" == "/dev/null" ] && rm -f /etc/udev/rules.d/80-networking.rules + [ -n "$udevlink" -a "$udevlink" = "/dev/null" ] && rm -f /etc/udev/rules.d/80-networking.rules udevlink=$(readlink /etc/udev/rules.d/60-bridge-network-interface.rules 2>/dev/null || true) - [ -n "$udevlink" -a "$udevlink" == "/dev/null" ] && rm -f /etc/udev/rules.d/60-bridge-network-interface.rules + [ -n "$udevlink" -a "$udevlink" = "/dev/null" ] && rm -f /etc/udev/rules.d/60-bridge-network-interface.rules } postrm_remove()