Skip to content

Commit

Permalink
ufw: bump version to 0.36 and add services
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Silcet authored and kraj committed May 3, 2021
1 parent 17f4320 commit 0a0894b
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 389 deletions.
Original file line number Diff line number Diff line change
@@ -1,25 +1,38 @@
Author: Jamie Strandboge <jamie@canonical.com>
Description: to improve boot speed when disabled, don't source all of
ufw-init-functions (which also sources in other files).
From 92fcdbc1a57086e4decc1597217c0739dc16342a Mon Sep 17 00:00:00 2001
From: Silcet <camorga1@gmail.com>
Date: Tue, 27 Apr 2021 05:34:59 +0000
Subject: [PATCH] Author: Jamie Strandboge <jamie@canonical.com>
Description:
to improve boot speed when disabled, don't source all of ufw-init-functions
(which also sources in other files).

Upstream-Status: Inappropriate [ not author ]

Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>

Index: ufw-0.31/src/ufw-init
===================================================================
--- ufw-0.31.orig/src/ufw-init 2012-03-09 17:07:11.000000000 -0600
+++ ufw-0.31/src/ufw-init 2012-03-17 09:37:51.000000000 -0500
@@ -18,6 +18,12 @@
#
set -e
The patch was imported from the OpenEmbedded git server
(git://git.openembedded.org/openembedded) as of commit id
2cc1bd9dd060f5002c2fde7aacba86fe230c12af.

Signed-off-by: Silcet <camorga1@gmail.com>
---
src/ufw-init | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/src/ufw-init b/src/ufw-init
index 3505a02..dde37f0 100755
--- a/src/ufw-init
+++ b/src/ufw-init
@@ -31,6 +31,12 @@ if [ "$1" = "--datadir" ] && [ -s "$2" ]; then
fi
export DATA_DIR="$datadir"

+# Debian/Ubuntu: small boot speed improvement
+. "#CONFIG_PREFIX#/ufw/ufw.conf"
+if [ "$1" = "start" ] && [ "$2" = "quiet" ] && [ "$ENABLED" = "no" ]; then
+ exit 0
+fi
+
if [ -s "#STATE_PREFIX#/ufw-init-functions" ]; then
. "#STATE_PREFIX#/ufw-init-functions"
if [ -s "${rootdir}#STATE_PREFIX#/ufw-init-functions" ]; then
. "${rootdir}#STATE_PREFIX#/ufw-init-functions"
else
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
From c54d36d0582a60fd281cd9287077cea205fd849d Mon Sep 17 00:00:00 2001
From: Joe MacDonald <joe_macdonald@mentor.com>
Date: Thu, 27 Nov 2014 15:20:34 -0500
From 808577f8464f542076840d0d93fe168a5f79442c Mon Sep 17 00:00:00 2001
From: Silcet <camorga1@gmail.com>
Date: Tue, 27 Apr 2021 05:40:03 +0000
Subject: [PATCH] setup: add an option to specify iptables location

When cross-compiling it isn't certain that the location of iptables on the
Expand All @@ -13,15 +13,21 @@ version of iptables to be used.
Upstream-Status: Pending

Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>

The patch was imported from the OpenEmbedded git server
(git://git.openembedded.org/openembedded) as of commit id
2cc1bd9dd060f5002c2fde7aacba86fe230c12af.

Signed-off-by: Silcet <camorga1@gmail.com>
---
setup.py | 69 ++++++++++++++++++++++++++++++++++++----------------------------
1 file changed, 39 insertions(+), 30 deletions(-)
setup.py | 65 ++++++++++++++++++++++++++++++++------------------------
1 file changed, 37 insertions(+), 28 deletions(-)

diff --git a/setup.py b/setup.py
index 6fb3751..b13d11c 100644
index 09204d3..2343bc9 100644
--- a/setup.py
+++ b/setup.py
@@ -225,41 +225,50 @@ shutil.copytree('src', 'staging')
@@ -246,41 +246,50 @@ shutil.copytree('src', 'staging')
os.unlink(os.path.join('staging', 'ufw-init'))
os.unlink(os.path.join('staging', 'ufw-init-functions'))

Expand All @@ -43,14 +49,6 @@ index 6fb3751..b13d11c 100644
- if iptables_exe != "":
- break
-
-
-if iptables_exe == '':
- print("ERROR: could not find required binary 'iptables'", file=sys.stderr)
- sys.exit(1)
-
-for e in ['ip6tables', 'iptables-restore', 'ip6tables-restore']:
- if not os.path.exists(os.path.join(iptables_dir, e)):
- print("ERROR: could not find required binary '%s'" % (e), file=sys.stderr)
+if "--iptables-dir" in sys.argv:
+ iptables_dir = sys.argv[sys.argv.index("--iptables-dir") + 1]
+ iptables_exe = os.path.join(iptables_dir, "iptables")
Expand All @@ -70,10 +68,16 @@ index 6fb3751..b13d11c 100644
+ print("Found '%s'" % iptables_exe)
+ else:
+ continue
+

-if iptables_exe == '':
- print("ERROR: could not find required binary 'iptables'", file=sys.stderr)
- sys.exit(1)
+ if iptables_exe != "":
+ break
+

-for e in ['ip6tables', 'iptables-restore', 'ip6tables-restore']:
- if not os.path.exists(os.path.join(iptables_dir, e)):
- print("ERROR: could not find required binary '%s'" % (e), file=sys.stderr)
+ if iptables_exe == '':
+ print("ERROR: could not find required binary 'iptables'", file=sys.stderr)
sys.exit(1)
Expand Down Expand Up @@ -102,6 +106,3 @@ index 6fb3751..b13d11c 100644

setup (name='ufw',
version=ufw_version,
--
1.9.1

118 changes: 0 additions & 118 deletions meta-networking/recipes-connectivity/ufw/ufw/0002-lp1044361.patch

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
From 42170d379eddc12bd2d1fe84dc268882d8eb4d64 Mon Sep 17 00:00:00 2001
From: Silcet <camorga1@gmail.com>
Date: Mon, 3 May 2021 08:59:28 +0000
Subject: [PATCH] setup: only make one reference to env

If sys.executable happens to be '/usr/bin/env python' or something
similar, the setup script will result in 'ufw' getting /usr/bin/env
repeated on the top line. This causes an error at runtime. Perform a
quick sanity check on sys.executable before doing the substitution.

While we're at it, change the default value of 'exe' to the one we either
detected or specified on the build line.

Upstream-Status: Inappropriate [ embedded specific ]

Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>

The patch was imported from the OpenEmbedded git server
(git://git.openembedded.org/openembedded) as of commit id
2cc1bd9dd060f5002c2fde7aacba86fe230c12af.

A previous change had modified the way the python shebang was updated to
follow the same version as the one used to call setup.py. However, it
used a regex that was not matching anymore. To fix this, the regex
condition is removed so the shebang line is substituted with the sys.executable
value. Later in the installation distutils finds the string with the path
of sys.executable and replaces it with "#! /usr/bin/env python3".

Signed-off-by: Silcet <camorga1@gmail.com>
---
setup.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index 2343bc9..f8a638b 100644
--- a/setup.py
+++ b/setup.py
@@ -64,7 +64,7 @@ class Install(_install, object):
real_sharedir = os.path.join(real_prefix, 'share', 'ufw')

# Update the modules' paths
- for fn in [ 'common.py' ]:
+ for fn in [ 'common.py', 'util.py' ]:
# 'staging' is used with just 'install' but build_lib is used when
# using 'build'. We could probably override 'def build()' but this
# at least works
@@ -97,6 +97,12 @@ class Install(_install, object):
"-i",
"s%#SHARE_DIR#%" + real_sharedir + "%g",
f])
+
+ subprocess.call(["sed",
+ "-i.jjm",
+ "s%/sbin/iptables%" + iptables_exe + "%g",
+ f])
+

if fn == 'common.py' and 'UFW_SKIP_CHECKS' in os.environ and \
os.environ['UFW_SKIP_CHECKS'] != '':
@@ -123,10 +129,12 @@ class Install(_install, object):
self.mkpath(os.path.dirname(f))

# update the interpreter to that of the one the user specified for setup
+ # Distutils searches for the string of sys.executable and replaces it
+ # with the "#! /usr/bin/env pythonX" shebang on a later step
print("Updating staging/ufw to use %s" % (sys.executable))
subprocess.call(["sed",
"-i",
- "1s%^#.*python.*%#! /usr/bin/env " + sys.executable + "%g",
+ "1s%/.*python.*%" + sys.executable + "%g",
'staging/ufw'])
self.copy_file('staging/ufw', script)
self.copy_file('doc/ufw.8', manpage)
40 changes: 0 additions & 40 deletions meta-networking/recipes-connectivity/ufw/ufw/0004-lp1039729.patch

This file was deleted.

Loading

0 comments on commit 0a0894b

Please sign in to comment.