Blame SOURCES/0002-fw-If-direct-rules-fail-to-apply-add-a-Direct-label-.patch

4d71d0
From efdecad74ac18d93b62a6f9ba3792904bb976b3b Mon Sep 17 00:00:00 2001
4d71d0
From: Eric Garver <e@erig.me>
4d71d0
Date: Fri, 17 Aug 2018 13:26:18 -0400
4d71d0
Subject: [PATCH 2/2] fw: If direct rules fail to apply add a "Direct" label to
4d71d0
 error msg
4d71d0
4d71d0
Since they're free form it's easy to write a bad rule. This will at
4d71d0
least let user know where to look.
4d71d0
4d71d0
(cherry picked from commit db2d72e32579d14b5f03c6f06a9e6f38b00717cd)
4d71d0
---
4d71d0
 src/firewall/core/fw.py | 12 +++++++++---
4d71d0
 1 file changed, 9 insertions(+), 3 deletions(-)
4d71d0
4d71d0
diff --git a/src/firewall/core/fw.py b/src/firewall/core/fw.py
4d71d0
index 9079f1bbc6a4..21f5fc680c10 100644
4d71d0
--- a/src/firewall/core/fw.py
4d71d0
+++ b/src/firewall/core/fw.py
4d71d0
@@ -440,9 +440,15 @@ class Firewall(object):
4d71d0
             log.debug1("Applying direct chains rules and passthrough rules")
4d71d0
             self.direct.apply_direct(transaction)
4d71d0
 
4d71d0
-            # Execute transaction
4d71d0
-            transaction.execute(True)
4d71d0
-            transaction.clear()
4d71d0
+            # since direct rules are easy to make syntax errors lets highlight
4d71d0
+            # the cause if the transaction fails.
4d71d0
+            try:
4d71d0
+                transaction.execute(True)
4d71d0
+                transaction.clear()
4d71d0
+            except FirewallError as e:
4d71d0
+                raise FirewallError(e.code, "Direct: %s" % (e.msg if e.msg else ""))
4d71d0
+            except Exception:
4d71d0
+                raise
4d71d0
 
4d71d0
         del transaction
4d71d0
 
4d71d0
-- 
4d71d0
2.18.0
4d71d0