~ubuntu-branches/ubuntu/saucy/ufw/saucy-proposed

« back to all changes in this revision

Viewing changes to debian/patches/0002-lp1044361.patch

  • Committer: Package Import Robot
  • Author(s): Jamie Strandboge
  • Date: 2012-09-24 08:52:57 UTC
  • Revision ID: package-import@ubuntu.com-20120924085257-uqiulz242yd4ab2a
Tags: 0.33-0ubuntu2
* debian/patches/0002-lp1044361.patch: move netfilter capabilities checking
  into initcaps(), and call initcaps() only when we need it (LP: #1044361)
* 0003-fix-typeerror-on-error.patch: fix TypeError on error when using zh_CN

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Origin: r795, r796
 
2
Description: move netfilter capabilities checking into initcaps(), and call
 
3
 initcaps() only when we need it.
 
4
Bug-Ubuntu: https://launchpad.net/bugs/1044361
 
5
 
 
6
Index: ufw-0.33/src/backend_iptables.py
 
7
===================================================================
 
8
--- ufw-0.33.orig/src/backend_iptables.py       2012-09-23 09:58:34.000000000 -0500
 
9
+++ ufw-0.33/src/backend_iptables.py    2012-09-23 09:58:36.000000000 -0500
 
10
@@ -160,6 +160,9 @@
 
11
             out += "> " + _("Checking raw ip6tables\n")
 
12
             return out
 
13
 
 
14
+        # Initialize the capabilities database
 
15
+        self.initcaps()
 
16
+
 
17
         args = ['-n', '-v', '-x', '-L']
 
18
         items = []
 
19
         items6 = []
 
20
@@ -470,6 +473,9 @@
 
21
         if self.dryrun:
 
22
             return False
 
23
 
 
24
+        # Initialize the capabilities database
 
25
+        self.initcaps()
 
26
+
 
27
         prefix = "ufw"
 
28
         exe = self.iptables
 
29
         if v6:
 
30
@@ -684,6 +690,9 @@
 
31
         except Exception:
 
32
             raise
 
33
 
 
34
+        # Initialize the capabilities database
 
35
+        self.initcaps()
 
36
+
 
37
         chain_prefix = "ufw"
 
38
         rules = self.rules
 
39
         if v6:
 
40
@@ -830,6 +839,10 @@
 
41
         * updating user rules file
 
42
         * reloading the user rules file if rule is modified
 
43
         '''
 
44
+
 
45
+        # Initialize the capabilities database
 
46
+        self.initcaps()
 
47
+
 
48
         rstr = ""
 
49
 
 
50
         if rule.v6:
 
51
@@ -1073,6 +1086,9 @@
 
52
         if self.dryrun:
 
53
             return
 
54
 
 
55
+        # Initialize the capabilities database
 
56
+        self.initcaps()
 
57
+
 
58
         rules_t = []
 
59
         try:
 
60
             rules_t = self._get_logging_rules(level)
 
61
Index: ufw-0.33/src/backend.py
 
62
===================================================================
 
63
--- ufw-0.33.orig/src/backend.py        2012-09-23 09:58:34.000000000 -0500
 
64
+++ ufw-0.33/src/backend.py     2012-09-23 09:59:03.000000000 -0500
 
65
@@ -21,7 +21,7 @@
 
66
 import stat
 
67
 import sys
 
68
 import ufw.util
 
69
-from ufw.util import warn, debug
 
70
+from ufw.util import error, warn, debug
 
71
 from ufw.common import UFWError, config_dir, iptables_dir, UFWRule
 
72
 import ufw.applications
 
73
 
 
74
@@ -68,6 +68,17 @@
 
75
             err_msg = _("Couldn't determine iptables version")
 
76
             raise UFWError(err_msg)
 
77
 
 
78
+        # Initialize via initcaps only when we need it (LP: #1044361)
 
79
+        self.caps = None
 
80
+
 
81
+    def initcaps(self):
 
82
+        '''Initialize the capabilities database. This needs to be called
 
83
+           before accessing the database.'''
 
84
+
 
85
+        # Only initialize if not initialized already
 
86
+        if self.caps != None:
 
87
+            return
 
88
+
 
89
         self.caps = {}
 
90
         self.caps['limit'] = {}
 
91
 
 
92
@@ -78,14 +89,20 @@
 
93
         # Try to get capabilities from the running system if root
 
94
         if self.do_checks and os.getuid() == 0 and not self.dryrun:
 
95
             # v4
 
96
-            nf_caps = ufw.util.get_netfilter_capabilities(self.iptables)
 
97
+            try:
 
98
+                nf_caps = ufw.util.get_netfilter_capabilities(self.iptables)
 
99
+            except OSError as e:
 
100
+                error("initcaps\n%s" % e)
 
101
             if 'recent-set' in nf_caps and 'recent-update' in nf_caps:
 
102
                 self.caps['limit']['4'] = True
 
103
             else:
 
104
                 self.caps['limit']['4'] = False
 
105
 
 
106
             # v6
 
107
-            nf_caps = ufw.util.get_netfilter_capabilities(self.ip6tables)
 
108
+            try:
 
109
+                nf_caps = ufw.util.get_netfilter_capabilities(self.ip6tables)
 
110
+            except OSError as e:
 
111
+                error("initcaps\n%s" % e)
 
112
             if 'recent-set' in nf_caps and 'recent-update' in nf_caps:
 
113
                 self.caps['limit']['6'] = True
 
114
             else: