summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilcet <camorga1@gmail.com>2021-04-27 08:38:49 +0200
committerKhem Raj <raj.khem@gmail.com>2021-05-03 08:07:40 -0700
commit0a0894b78e7423bb4c55a630a3d9a16e4bf9b97c (patch)
treec22c68c06e0a17bf22beda4b0d0433efe38dae62
parent17f43204f27c1421f494dbcc80ec7cb90dbec659 (diff)
downloadmeta-openembedded-0a0894b78e7423bb4c55a630a3d9a16e4bf9b97c.tar.gz
ufw: bump version to 0.36 and add services
This commit brings the version of ufw up to 0.36 since version 0.33 had some problems: * The setup.py calls sed to replace some variables in the source code with the correct paths. However, this is done using a hardcoded path and conflicts with distutils * The python shebang was not properly corrected in setup.py, leading to a script that only run if there is a python symlink to python2 or python3 The first issue is addressed by the bump in version, while the second one is fixed in patch 0003 of the recipe. Also, the new version provides examples for systemd service and sysvinit scripts to autostart ufw. These are added into the recipe now. Signed-off-by: Silcet <camorga1@gmail.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r--meta-networking/recipes-connectivity/ufw/ufw/0001-optimize-boot.patch37
-rw-r--r--meta-networking/recipes-connectivity/ufw/ufw/0002-add-an-option-to-specify-iptables-location.patch (renamed from meta-networking/recipes-connectivity/ufw/ufw/setup-add-an-option-to-specify-iptables-location.patch)41
-rw-r--r--meta-networking/recipes-connectivity/ufw/ufw/0002-lp1044361.patch118
-rw-r--r--meta-networking/recipes-connectivity/ufw/ufw/0003-fix-typeerror-on-error.patch20
-rw-r--r--meta-networking/recipes-connectivity/ufw/ufw/0003-only-make-one-reference-to-env.patch73
-rw-r--r--meta-networking/recipes-connectivity/ufw/ufw/0004-lp1039729.patch40
-rw-r--r--meta-networking/recipes-connectivity/ufw/ufw/0005-lp1191197.patch32
-rw-r--r--meta-networking/recipes-connectivity/ufw/ufw/fix-dynamic-update-of-python-shebang.patch57
-rw-r--r--meta-networking/recipes-connectivity/ufw/ufw/setup-only-make-one-reference-to-env.patch77
-rw-r--r--meta-networking/recipes-connectivity/ufw/ufw_0.36.bb (renamed from meta-networking/recipes-connectivity/ufw/ufw_0.33.bb)34
10 files changed, 140 insertions, 389 deletions
diff --git a/meta-networking/recipes-connectivity/ufw/ufw/0001-optimize-boot.patch b/meta-networking/recipes-connectivity/ufw/ufw/0001-optimize-boot.patch
index a1e56b7cac..28068bba11 100644
--- a/meta-networking/recipes-connectivity/ufw/ufw/0001-optimize-boot.patch
+++ b/meta-networking/recipes-connectivity/ufw/ufw/0001-optimize-boot.patch
@@ -1,18 +1,31 @@
1Author: Jamie Strandboge <jamie@canonical.com> 1From 92fcdbc1a57086e4decc1597217c0739dc16342a Mon Sep 17 00:00:00 2001
2Description: to improve boot speed when disabled, don't source all of 2From: Silcet <camorga1@gmail.com>
3 ufw-init-functions (which also sources in other files). 3Date: Tue, 27 Apr 2021 05:34:59 +0000
4Subject: [PATCH] Author: Jamie Strandboge <jamie@canonical.com>
5Description:
6to improve boot speed when disabled, don't source all of ufw-init-functions
7(which also sources in other files).
4 8
5Upstream-Status: Inappropriate [ not author ] 9Upstream-Status: Inappropriate [ not author ]
6 10
7Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com> 11Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
8 12
9Index: ufw-0.31/src/ufw-init 13The patch was imported from the OpenEmbedded git server
10=================================================================== 14(git://git.openembedded.org/openembedded) as of commit id
11--- ufw-0.31.orig/src/ufw-init 2012-03-09 17:07:11.000000000 -0600 152cc1bd9dd060f5002c2fde7aacba86fe230c12af.
12+++ ufw-0.31/src/ufw-init 2012-03-17 09:37:51.000000000 -0500 16
13@@ -18,6 +18,12 @@ 17Signed-off-by: Silcet <camorga1@gmail.com>
14 # 18---
15 set -e 19 src/ufw-init | 6 ++++++
20 1 file changed, 6 insertions(+)
21
22diff --git a/src/ufw-init b/src/ufw-init
23index 3505a02..dde37f0 100755
24--- a/src/ufw-init
25+++ b/src/ufw-init
26@@ -31,6 +31,12 @@ if [ "$1" = "--datadir" ] && [ -s "$2" ]; then
27 fi
28 export DATA_DIR="$datadir"
16 29
17+# Debian/Ubuntu: small boot speed improvement 30+# Debian/Ubuntu: small boot speed improvement
18+. "#CONFIG_PREFIX#/ufw/ufw.conf" 31+. "#CONFIG_PREFIX#/ufw/ufw.conf"
@@ -20,6 +33,6 @@ Index: ufw-0.31/src/ufw-init
20+ exit 0 33+ exit 0
21+fi 34+fi
22+ 35+
23 if [ -s "#STATE_PREFIX#/ufw-init-functions" ]; then 36 if [ -s "${rootdir}#STATE_PREFIX#/ufw-init-functions" ]; then
24 . "#STATE_PREFIX#/ufw-init-functions" 37 . "${rootdir}#STATE_PREFIX#/ufw-init-functions"
25 else 38 else
diff --git a/meta-networking/recipes-connectivity/ufw/ufw/setup-add-an-option-to-specify-iptables-location.patch b/meta-networking/recipes-connectivity/ufw/ufw/0002-add-an-option-to-specify-iptables-location.patch
index 5117423387..884fa1647e 100644
--- a/meta-networking/recipes-connectivity/ufw/ufw/setup-add-an-option-to-specify-iptables-location.patch
+++ b/meta-networking/recipes-connectivity/ufw/ufw/0002-add-an-option-to-specify-iptables-location.patch
@@ -1,6 +1,6 @@
1From c54d36d0582a60fd281cd9287077cea205fd849d Mon Sep 17 00:00:00 2001 1From 808577f8464f542076840d0d93fe168a5f79442c Mon Sep 17 00:00:00 2001
2From: Joe MacDonald <joe_macdonald@mentor.com> 2From: Silcet <camorga1@gmail.com>
3Date: Thu, 27 Nov 2014 15:20:34 -0500 3Date: Tue, 27 Apr 2021 05:40:03 +0000
4Subject: [PATCH] setup: add an option to specify iptables location 4Subject: [PATCH] setup: add an option to specify iptables location
5 5
6When cross-compiling it isn't certain that the location of iptables on the 6When cross-compiling it isn't certain that the location of iptables on the
@@ -13,15 +13,21 @@ version of iptables to be used.
13Upstream-Status: Pending 13Upstream-Status: Pending
14 14
15Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com> 15Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
16
17The patch was imported from the OpenEmbedded git server
18(git://git.openembedded.org/openembedded) as of commit id
192cc1bd9dd060f5002c2fde7aacba86fe230c12af.
20
21Signed-off-by: Silcet <camorga1@gmail.com>
16--- 22---
17 setup.py | 69 ++++++++++++++++++++++++++++++++++++---------------------------- 23 setup.py | 65 ++++++++++++++++++++++++++++++++------------------------
18 1 file changed, 39 insertions(+), 30 deletions(-) 24 1 file changed, 37 insertions(+), 28 deletions(-)
19 25
20diff --git a/setup.py b/setup.py 26diff --git a/setup.py b/setup.py
21index 6fb3751..b13d11c 100644 27index 09204d3..2343bc9 100644
22--- a/setup.py 28--- a/setup.py
23+++ b/setup.py 29+++ b/setup.py
24@@ -225,41 +225,50 @@ shutil.copytree('src', 'staging') 30@@ -246,41 +246,50 @@ shutil.copytree('src', 'staging')
25 os.unlink(os.path.join('staging', 'ufw-init')) 31 os.unlink(os.path.join('staging', 'ufw-init'))
26 os.unlink(os.path.join('staging', 'ufw-init-functions')) 32 os.unlink(os.path.join('staging', 'ufw-init-functions'))
27 33
@@ -43,14 +49,6 @@ index 6fb3751..b13d11c 100644
43- if iptables_exe != "": 49- if iptables_exe != "":
44- break 50- break
45- 51-
46-
47-if iptables_exe == '':
48- print("ERROR: could not find required binary 'iptables'", file=sys.stderr)
49- sys.exit(1)
50-
51-for e in ['ip6tables', 'iptables-restore', 'ip6tables-restore']:
52- if not os.path.exists(os.path.join(iptables_dir, e)):
53- print("ERROR: could not find required binary '%s'" % (e), file=sys.stderr)
54+if "--iptables-dir" in sys.argv: 52+if "--iptables-dir" in sys.argv:
55+ iptables_dir = sys.argv[sys.argv.index("--iptables-dir") + 1] 53+ iptables_dir = sys.argv[sys.argv.index("--iptables-dir") + 1]
56+ iptables_exe = os.path.join(iptables_dir, "iptables") 54+ iptables_exe = os.path.join(iptables_dir, "iptables")
@@ -70,10 +68,16 @@ index 6fb3751..b13d11c 100644
70+ print("Found '%s'" % iptables_exe) 68+ print("Found '%s'" % iptables_exe)
71+ else: 69+ else:
72+ continue 70+ continue
73+ 71
72-if iptables_exe == '':
73- print("ERROR: could not find required binary 'iptables'", file=sys.stderr)
74- sys.exit(1)
74+ if iptables_exe != "": 75+ if iptables_exe != "":
75+ break 76+ break
76+ 77
78-for e in ['ip6tables', 'iptables-restore', 'ip6tables-restore']:
79- if not os.path.exists(os.path.join(iptables_dir, e)):
80- print("ERROR: could not find required binary '%s'" % (e), file=sys.stderr)
77+ if iptables_exe == '': 81+ if iptables_exe == '':
78+ print("ERROR: could not find required binary 'iptables'", file=sys.stderr) 82+ print("ERROR: could not find required binary 'iptables'", file=sys.stderr)
79 sys.exit(1) 83 sys.exit(1)
@@ -102,6 +106,3 @@ index 6fb3751..b13d11c 100644
102 106
103 setup (name='ufw', 107 setup (name='ufw',
104 version=ufw_version, 108 version=ufw_version,
105--
1061.9.1
107
diff --git a/meta-networking/recipes-connectivity/ufw/ufw/0002-lp1044361.patch b/meta-networking/recipes-connectivity/ufw/ufw/0002-lp1044361.patch
deleted file mode 100644
index 804c18bc9e..0000000000
--- a/meta-networking/recipes-connectivity/ufw/ufw/0002-lp1044361.patch
+++ /dev/null
@@ -1,118 +0,0 @@
1Origin: r795, r796
2Description: move netfilter capabilities checking into initcaps(), and call
3 initcaps() only when we need it.
4Bug-Ubuntu: https://launchpad.net/bugs/1044361
5
6Upstream-Status: Inappropriate [ not author ]
7
8Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
9
10Index: ufw-0.33/src/backend_iptables.py
11===================================================================
12--- ufw-0.33.orig/src/backend_iptables.py 2012-09-23 09:58:34.000000000 -0500
13+++ ufw-0.33/src/backend_iptables.py 2012-09-23 09:58:36.000000000 -0500
14@@ -160,6 +160,9 @@
15 out += "> " + _("Checking raw ip6tables\n")
16 return out
17
18+ # Initialize the capabilities database
19+ self.initcaps()
20+
21 args = ['-n', '-v', '-x', '-L']
22 items = []
23 items6 = []
24@@ -470,6 +473,9 @@
25 if self.dryrun:
26 return False
27
28+ # Initialize the capabilities database
29+ self.initcaps()
30+
31 prefix = "ufw"
32 exe = self.iptables
33 if v6:
34@@ -684,6 +690,9 @@
35 except Exception:
36 raise
37
38+ # Initialize the capabilities database
39+ self.initcaps()
40+
41 chain_prefix = "ufw"
42 rules = self.rules
43 if v6:
44@@ -830,6 +839,10 @@
45 * updating user rules file
46 * reloading the user rules file if rule is modified
47 '''
48+
49+ # Initialize the capabilities database
50+ self.initcaps()
51+
52 rstr = ""
53
54 if rule.v6:
55@@ -1073,6 +1086,9 @@
56 if self.dryrun:
57 return
58
59+ # Initialize the capabilities database
60+ self.initcaps()
61+
62 rules_t = []
63 try:
64 rules_t = self._get_logging_rules(level)
65Index: ufw-0.33/src/backend.py
66===================================================================
67--- ufw-0.33.orig/src/backend.py 2012-09-23 09:58:34.000000000 -0500
68+++ ufw-0.33/src/backend.py 2012-09-23 09:59:03.000000000 -0500
69@@ -21,7 +21,7 @@
70 import stat
71 import sys
72 import ufw.util
73-from ufw.util import warn, debug
74+from ufw.util import error, warn, debug
75 from ufw.common import UFWError, config_dir, iptables_dir, UFWRule
76 import ufw.applications
77
78@@ -68,6 +68,17 @@
79 err_msg = _("Couldn't determine iptables version")
80 raise UFWError(err_msg)
81
82+ # Initialize via initcaps only when we need it (LP: #1044361)
83+ self.caps = None
84+
85+ def initcaps(self):
86+ '''Initialize the capabilities database. This needs to be called
87+ before accessing the database.'''
88+
89+ # Only initialize if not initialized already
90+ if self.caps != None:
91+ return
92+
93 self.caps = {}
94 self.caps['limit'] = {}
95
96@@ -78,14 +89,20 @@
97 # Try to get capabilities from the running system if root
98 if self.do_checks and os.getuid() == 0 and not self.dryrun:
99 # v4
100- nf_caps = ufw.util.get_netfilter_capabilities(self.iptables)
101+ try:
102+ nf_caps = ufw.util.get_netfilter_capabilities(self.iptables)
103+ except OSError as e:
104+ error("initcaps\n%s" % e)
105 if 'recent-set' in nf_caps and 'recent-update' in nf_caps:
106 self.caps['limit']['4'] = True
107 else:
108 self.caps['limit']['4'] = False
109
110 # v6
111- nf_caps = ufw.util.get_netfilter_capabilities(self.ip6tables)
112+ try:
113+ nf_caps = ufw.util.get_netfilter_capabilities(self.ip6tables)
114+ except OSError as e:
115+ error("initcaps\n%s" % e)
116 if 'recent-set' in nf_caps and 'recent-update' in nf_caps:
117 self.caps['limit']['6'] = True
118 else:
diff --git a/meta-networking/recipes-connectivity/ufw/ufw/0003-fix-typeerror-on-error.patch b/meta-networking/recipes-connectivity/ufw/ufw/0003-fix-typeerror-on-error.patch
deleted file mode 100644
index b259fdf781..0000000000
--- a/meta-networking/recipes-connectivity/ufw/ufw/0003-fix-typeerror-on-error.patch
+++ /dev/null
@@ -1,20 +0,0 @@
1Origin: r797
2Description: src/backend_iptables.py: fix misplaced parenthesis
3
4Upstream-Status: Inappropriate [ not author ]
5
6Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
7
8Index: ufw-0.33/src/backend_iptables.py
9===================================================================
10--- ufw-0.33.orig/src/backend_iptables.py 2012-09-24 08:51:13.000000000 -0500
11+++ ufw-0.33/src/backend_iptables.py 2012-09-24 08:52:00.000000000 -0500
12@@ -1075,7 +1075,7 @@
13 exe = self.ip6tables
14 (rc, out) = cmd([exe] + args)
15 if rc != 0:
16- err_msg = _("Could not perform '%s'") % (args)
17+ err_msg = _("Could not perform '%s'" % (args))
18 if fail_ok:
19 debug("FAILOK: " + err_msg)
20 else:
diff --git a/meta-networking/recipes-connectivity/ufw/ufw/0003-only-make-one-reference-to-env.patch b/meta-networking/recipes-connectivity/ufw/ufw/0003-only-make-one-reference-to-env.patch
new file mode 100644
index 0000000000..556d4459d0
--- /dev/null
+++ b/meta-networking/recipes-connectivity/ufw/ufw/0003-only-make-one-reference-to-env.patch
@@ -0,0 +1,73 @@
1From 42170d379eddc12bd2d1fe84dc268882d8eb4d64 Mon Sep 17 00:00:00 2001
2From: Silcet <camorga1@gmail.com>
3Date: Mon, 3 May 2021 08:59:28 +0000
4Subject: [PATCH] setup: only make one reference to env
5
6If sys.executable happens to be '/usr/bin/env python' or something
7similar, the setup script will result in 'ufw' getting /usr/bin/env
8repeated on the top line. This causes an error at runtime. Perform a
9quick sanity check on sys.executable before doing the substitution.
10
11While we're at it, change the default value of 'exe' to the one we either
12detected or specified on the build line.
13
14Upstream-Status: Inappropriate [ embedded specific ]
15
16Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
17
18The patch was imported from the OpenEmbedded git server
19(git://git.openembedded.org/openembedded) as of commit id
202cc1bd9dd060f5002c2fde7aacba86fe230c12af.
21
22A previous change had modified the way the python shebang was updated to
23follow the same version as the one used to call setup.py. However, it
24used a regex that was not matching anymore. To fix this, the regex
25condition is removed so the shebang line is substituted with the sys.executable
26value. Later in the installation distutils finds the string with the path
27of sys.executable and replaces it with "#! /usr/bin/env python3".
28
29Signed-off-by: Silcet <camorga1@gmail.com>
30---
31 setup.py | 12 ++++++++++--
32 1 file changed, 10 insertions(+), 2 deletions(-)
33
34diff --git a/setup.py b/setup.py
35index 2343bc9..f8a638b 100644
36--- a/setup.py
37+++ b/setup.py
38@@ -64,7 +64,7 @@ class Install(_install, object):
39 real_sharedir = os.path.join(real_prefix, 'share', 'ufw')
40
41 # Update the modules' paths
42- for fn in [ 'common.py' ]:
43+ for fn in [ 'common.py', 'util.py' ]:
44 # 'staging' is used with just 'install' but build_lib is used when
45 # using 'build'. We could probably override 'def build()' but this
46 # at least works
47@@ -97,6 +97,12 @@ class Install(_install, object):
48 "-i",
49 "s%#SHARE_DIR#%" + real_sharedir + "%g",
50 f])
51+
52+ subprocess.call(["sed",
53+ "-i.jjm",
54+ "s%/sbin/iptables%" + iptables_exe + "%g",
55+ f])
56+
57
58 if fn == 'common.py' and 'UFW_SKIP_CHECKS' in os.environ and \
59 os.environ['UFW_SKIP_CHECKS'] != '':
60@@ -123,10 +129,12 @@ class Install(_install, object):
61 self.mkpath(os.path.dirname(f))
62
63 # update the interpreter to that of the one the user specified for setup
64+ # Distutils searches for the string of sys.executable and replaces it
65+ # with the "#! /usr/bin/env pythonX" shebang on a later step
66 print("Updating staging/ufw to use %s" % (sys.executable))
67 subprocess.call(["sed",
68 "-i",
69- "1s%^#.*python.*%#! /usr/bin/env " + sys.executable + "%g",
70+ "1s%/.*python.*%" + sys.executable + "%g",
71 'staging/ufw'])
72 self.copy_file('staging/ufw', script)
73 self.copy_file('doc/ufw.8', manpage)
diff --git a/meta-networking/recipes-connectivity/ufw/ufw/0004-lp1039729.patch b/meta-networking/recipes-connectivity/ufw/ufw/0004-lp1039729.patch
deleted file mode 100644
index 695b265671..0000000000
--- a/meta-networking/recipes-connectivity/ufw/ufw/0004-lp1039729.patch
+++ /dev/null
@@ -1,40 +0,0 @@
1Origin: r803, r804
2Description: Don't call get_netfilter_capabilities() with ipv6 if ipv6 is
3 disabled.
4Bug-Ubuntu: https://launchpad.net/ufw/bugs/1039729
5
6Upstream-Status: Inappropriate [ not author ]
7
8Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
9
10Index: ufw-0.33/src/backend.py
11===================================================================
12--- ufw-0.33.orig/src/backend.py 2012-12-04 09:21:57.000000000 -0600
13+++ ufw-0.33/src/backend.py 2012-12-04 09:22:40.000000000 -0600
14@@ -98,15 +98,17 @@
15 else:
16 self.caps['limit']['4'] = False
17
18- # v6
19- try:
20- nf_caps = ufw.util.get_netfilter_capabilities(self.ip6tables)
21- except OSError as e:
22- error("initcaps\n%s" % e)
23- if 'recent-set' in nf_caps and 'recent-update' in nf_caps:
24- self.caps['limit']['6'] = True
25- else:
26- self.caps['limit']['6'] = False
27+ # v6 (skip capabilities check for ipv6 if ipv6 is disabled in ufw
28+ # because the system may not have ipv6 support (LP: #1039729)
29+ if self.use_ipv6():
30+ try:
31+ nf_caps = ufw.util.get_netfilter_capabilities(self.ip6tables)
32+ except OSError as e:
33+ error("initcaps\n%s" % e)
34+ if 'recent-set' in nf_caps and 'recent-update' in nf_caps:
35+ self.caps['limit']['6'] = True
36+ else:
37+ self.caps['limit']['6'] = False
38
39 def is_enabled(self):
40 '''Is firewall configured as enabled'''
diff --git a/meta-networking/recipes-connectivity/ufw/ufw/0005-lp1191197.patch b/meta-networking/recipes-connectivity/ufw/ufw/0005-lp1191197.patch
deleted file mode 100644
index b760d3fd33..0000000000
--- a/meta-networking/recipes-connectivity/ufw/ufw/0005-lp1191197.patch
+++ /dev/null
@@ -1,32 +0,0 @@
1Origin: r816
2Description: add check for -m rt --rt-type 0
3Bug-Ubuntu: https://launchpad.net/bugs/1191197
4Forwarded: yes
5
6Upstream-Status: Inappropriate [ not author ]
7
8Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
9
10Index: ufw-0.33/tests/check-requirements
11===================================================================
12--- ufw-0.33.orig/tests/check-requirements 2012-08-17 16:12:49.000000000 -0500
13+++ ufw-0.33/tests/check-requirements 2013-06-15 07:47:00.000000000 -0500
14@@ -3,7 +3,7 @@
15 # check-requirements: verify all the required iptables functionality is
16 # available
17 #
18-# Copyright 2008-2012 Canonical Ltd.
19+# Copyright 2008-2013 Canonical Ltd.
20 #
21 # This program is free software: you can redistribute it and/or modify
22 # it under the terms of the GNU General Public License version 3,
23@@ -218,6 +218,9 @@
24 echo -n "icmpv6 with hl ($j): "
25 runcmd $exe -A $c -p icmpv6 --icmpv6-type $j -m hl --hl-eq 255 -j ACCEPT
26 done
27+
28+ echo -n "ipv6 rt: "
29+ runcmd $exe -A $c -m rt --rt-type 0 -j ACCEPT
30 fi
31
32 echo ""
diff --git a/meta-networking/recipes-connectivity/ufw/ufw/fix-dynamic-update-of-python-shebang.patch b/meta-networking/recipes-connectivity/ufw/ufw/fix-dynamic-update-of-python-shebang.patch
deleted file mode 100644
index 0bb0315ccd..0000000000
--- a/meta-networking/recipes-connectivity/ufw/ufw/fix-dynamic-update-of-python-shebang.patch
+++ /dev/null
@@ -1,57 +0,0 @@
1From b961a7fceb5654c283c3f987bee593d52abaf1f5 Mon Sep 17 00:00:00 2001
2From: Silcet <camorga1@gmail.com>
3Date: Mon, 26 Apr 2021 07:47:02 +0000
4Subject: [PATCH] ufw: Fix dynamic update of python shebang
5
6[meta-openembedded ticket #327] -- https://github.com/openembedded/meta-openembedded/issues/327
7
8The python version in the shebang at the begining of the ufw script
9should be the same one as the version the setup.py script was called
10with.
11
12The fix in patch "setup-only-make-one-reference-to-env.patch"
13depends on sys.executable returning "/usr/bin/env pythonX". However,
14it returns "/usr/bin/pythonX". Using sys.version_info we can get the
15major version of the python used to called the script and append
16that to the shebang line so it works as intended.
17
18Upstream-status: Pending
19
20Signed-off-by: Silcet <camorga1@gmail.com>
21---
22 setup.py | 21 ++++++---------------
23 1 file changed, 6 insertions(+), 15 deletions(-)
24
25diff --git a/setup.py b/setup.py
26index ca730b7..941bbf6 100644
27--- a/setup.py
28+++ b/setup.py
29@@ -112,22 +112,13 @@ class Install(_install, object):
30 for f in [ script, manpage, manpage_f ]:
31 self.mkpath(os.path.dirname(f))
32
33- # if sys.executable == /usr/bin/env python* the result will be the top
34- # of ufw getting:
35- #
36- # #! /usr/bin/env /usr/bin/env python
37- #
38- # which is not ideal
39- #
40 # update the interpreter to that of the one the user specified for setup
41- print("Updating staging/ufw to use (%s)" % (sys.executable))
42-
43- if re.search("(/usr/bin/env)", sys.executable):
44- print("found 'env' in sys.executable (%s)" % (sys.executable))
45- subprocess.call(["sed",
46- "-i.jjm",
47- "1s%^#.*python.*%#! " + sys.executable + "%g",
48- 'staging/ufw'])
49+ python_major = sys.version_info.major
50+ print("Updating staging/ufw to use (python%s)" % (python_major))
51+ subprocess.call(["sed",
52+ "-i.jjm",
53+ "1s%^#.*python.*%#! " + sys.executable + "%g",
54+ 'staging/ufw'])
55
56 self.copy_file('staging/ufw', script)
57 self.copy_file('doc/ufw.8', manpage)
diff --git a/meta-networking/recipes-connectivity/ufw/ufw/setup-only-make-one-reference-to-env.patch b/meta-networking/recipes-connectivity/ufw/ufw/setup-only-make-one-reference-to-env.patch
deleted file mode 100644
index ff704b5a46..0000000000
--- a/meta-networking/recipes-connectivity/ufw/ufw/setup-only-make-one-reference-to-env.patch
+++ /dev/null
@@ -1,77 +0,0 @@
1From be53eea06a5655fdc98f47a73be8277b65bb42ed Mon Sep 17 00:00:00 2001
2From: Joe MacDonald <joe_macdonald@mentor.com>
3Date: Tue, 11 Nov 2014 21:41:14 -0500
4Subject: [PATCH] setup: only make one reference to env
5
6If sys.executable happens to be '/usr/bin/env python' or something
7similar, the setup script will result in 'ufw' getting /usr/bin/env
8repeated on the top line. This causes an error at runtime. Perform a
9quick sanity check on sys.executable before doing the substitution.
10
11While we're at it, change the default value of 'exe' to the one we either
12detected or specified on the build line.
13
14Upstream-Status: Inappropriate [ embedded specific ]
15
16Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
17---
18 setup.py | 34 ++++++++++++++++++++++++++++------
19 1 file changed, 28 insertions(+), 6 deletions(-)
20
21diff --git a/setup.py b/setup.py
22index b13d11c..73acdef 100644
23--- a/setup.py
24+++ b/setup.py
25@@ -64,7 +64,7 @@ class Install(_install, object):
26 real_sharedir = os.path.join(real_prefix, 'share', 'ufw')
27
28 # Update the modules' paths
29- for file in [ 'common.py' ]:
30+ for file in [ 'common.py', 'util.py' ]:
31 print("Updating " + file)
32 subprocess.call(["sed",
33 "-i",
34@@ -91,6 +91,11 @@ class Install(_install, object):
35 "s%#SHARE_DIR#%" + real_sharedir + "%g",
36 os.path.join('staging', file)])
37
38+ subprocess.call(["sed",
39+ "-i.jjm",
40+ "s%/sbin/iptables%" + iptables_exe + "%g",
41+ os.path.join('staging', file)])
42+
43 # Now byte-compile everything
44 super(Install, self).run()
45
46@@ -107,12 +112,23 @@ class Install(_install, object):
47 for f in [ script, manpage, manpage_f ]:
48 self.mkpath(os.path.dirname(f))
49
50+ # if sys.executable == /usr/bin/env python* the result will be the top
51+ # of ufw getting:
52+ #
53+ # #! /usr/bin/env /usr/bin/env python
54+ #
55+ # which is not ideal
56+ #
57 # update the interpreter to that of the one the user specified for setup
58- print("Updating staging/ufw to use %s" % (sys.executable))
59- subprocess.call(["sed",
60- "-i",
61- "1s%^#.*python.*%#! /usr/bin/env " + sys.executable + "%g",
62- 'staging/ufw'])
63+ print("Updating staging/ufw to use (%s)" % (sys.executable))
64+
65+ if re.search("(/usr/bin/env)", sys.executable):
66+ print("found 'env' in sys.executable (%s)" % (sys.executable))
67+ subprocess.call(["sed",
68+ "-i.jjm",
69+ "1s%^#.*python.*%#! " + sys.executable + "%g",
70+ 'staging/ufw'])
71+
72 self.copy_file('staging/ufw', script)
73 self.copy_file('doc/ufw.8', manpage)
74 self.copy_file('doc/ufw-framework.8', manpage_f)
75--
761.9.1
77
diff --git a/meta-networking/recipes-connectivity/ufw/ufw_0.33.bb b/meta-networking/recipes-connectivity/ufw/ufw_0.36.bb
index ee366aa665..8e35dc01ed 100644
--- a/meta-networking/recipes-connectivity/ufw/ufw_0.33.bb
+++ b/meta-networking/recipes-connectivity/ufw/ufw_0.36.bb
@@ -1,3 +1,4 @@
1
1SUMMARY = "Uncomplicated Firewall" 2SUMMARY = "Uncomplicated Firewall"
2DESCRIPTION = "UFW stands for Uncomplicated Firewall, and is program for \ 3DESCRIPTION = "UFW stands for Uncomplicated Firewall, and is program for \
3managing a netfilter firewall. It provides a command line interface and aims \ 4managing a netfilter firewall. It provides a command line interface and aims \
@@ -7,24 +8,18 @@ SECTION = "net"
7LICENSE = "GPLv3" 8LICENSE = "GPLv3"
8LIC_FILES_CHKSUM = "file://COPYING;md5=f27defe1e96c2e1ecd4e0c9be8967949" 9LIC_FILES_CHKSUM = "file://COPYING;md5=f27defe1e96c2e1ecd4e0c9be8967949"
9 10
10SRC_URI = " \ 11SRC_URI = "https://launchpad.net/ufw/0.36/0.36/+download/ufw-0.36.tar.gz \
11 https://launchpad.net/ufw/0.33/0.33/+download/ufw-0.33.tar.gz \
12 file://setup-add-an-option-to-specify-iptables-location.patch \
13 file://setup-only-make-one-reference-to-env.patch \
14 file://0001-optimize-boot.patch \ 12 file://0001-optimize-boot.patch \
15 file://0002-lp1044361.patch \ 13 file://0002-add-an-option-to-specify-iptables-location.patch \
16 file://0003-fix-typeerror-on-error.patch \ 14 file://0003-only-make-one-reference-to-env.patch \
17 file://0004-lp1039729.patch \ 15 "
18 file://0005-lp1191197.patch \
19 file://fix-dynamic-update-of-python-shebang.patch \
20"
21 16
22UPSTREAM_CHECK_URI = "https://launchpad.net/ufw" 17UPSTREAM_CHECK_URI = "https://launchpad.net/ufw"
23 18
24SRC_URI[md5sum] = "3747b453d76709e5a99da209fc0bb5f5" 19SRC_URI[md5sum] = "6d8ab1506da21ae003f4628f93d05781"
25SRC_URI[sha256sum] = "5f85a8084ad3539b547bec097286948233188c971f498890316dec170bdd1da8" 20SRC_URI[sha256sum] = "754b22ae5edff0273460ac9f57509c3938187e0cf4fb9692c6a02833fff33cfc"
26 21
27inherit setuptools3 features_check 22inherit setuptools3 features_check systemd update-rc.d
28 23
29RDEPENDS_${PN} = " \ 24RDEPENDS_${PN} = " \
30 iptables \ 25 iptables \
@@ -44,6 +39,19 @@ RRECOMMENDS_${PN} = " \
44 kernel-module-nf-recent \ 39 kernel-module-nf-recent \
45" 40"
46 41
42do_install_append() {
43 install -d ${D}${systemd_unitdir}/system/
44 install -m 0644 ${S}/doc/systemd.example ${D}${systemd_unitdir}/system/ufw.service
45
46 install -d ${D}${sysconfdir}/init.d/
47 install -m 0755 ${S}/doc/initscript.example ${D}${sysconfdir}/init.d/ufw
48}
49
50SYSTEMD_SERVICE_${PN} = "ufw.service"
51
52INITSCRIPT_NAME = "ufw"
53INITSCRIPT_PARAMS = "defaults"
54
47# Certain items are explicitly put under /lib, not base_libdir when installed. 55# Certain items are explicitly put under /lib, not base_libdir when installed.
48# 56#
49FILES_${PN} += " \ 57FILES_${PN} += " \