package/firewalld: new package
PATCH v2 1/1 package/firewalld: new package
Firewalld provides a dynamically managed firewall with
support for network or firewall zones to define the trust level of network connections or interfaces.
Items of note:
- Setting PYTHON="/usr/bin/env python$(PYTHON3_VERSION_MAJOR)" prevents Firewalld from setting the shebang in the installed python files to the full path to the python interpreter used when building.
- The bundled provided SYSV init file has several bashisms and requires /etc/init.d/functions which buildroot doesn't provide. So instead, a more simple init.d file is provided in the package directory, which does not require bash.
- Firewalld >= 1.0.0 requires a linux kernel version of 5.3 or later. Because Buildroot does not have a mechanism to detect what version a user is compiling if the kernel is external, there is no way to prevent a user with an external kernel older than 5.3 to select this package.
- To run, Firewalld requires enabling almost every single nftables option in the kernel menuconfig. Indeed for a regular user, this task is quite a time-consuming operation, and missing even one required nftables option results in firewalld failing to start.
Through a mix of trial and error and talking to the upstream developers, the package selects the minimum amount of kernel options required for runtime. Understandably the list is daunting. However, these options have passed run-time tests with kernel 5.3 (the minimum kernel version required) and kernel 6.2.10 (the latest kernel version as of this commit log.)
As such, it is safe to say these options will work for anybody wanting to use firewalld with a supported kernel version of 5.3 or higher.
---
Changes v1 -> v2:
- Fix verbage in Config.in
- Bump to version 1.3.2
package/Config.in | 1 + package/firewalld/Config.in | 43 ++++++ package/firewalld/S46firewalld | 66 ++++++++ package/firewalld/firewalld.hash | 3 + package/firewalld/firewalld.mk | 257 +++++++++++++++++++++++++++++++ 5 files changed, 370 insertions(+) create mode 100644 package/firewalld/Config.in create mode 100644 package/firewalld/S46firewalld create mode 100644 package/firewalld/firewalld.hash create mode 100644 package/firewalld/firewalld.mk
package/Config.in +1 -0
@@ -2315,6 +2315,7 @@ endif source "package/fail2ban/Config.in" source "package/fastd/Config.in" source "package/fcgiwrap/Config.in" + source "package/firewalld/Config.in" source "package/flannel/Config.in" source "package/fmc/Config.in" source "package/fping/Config.in"
package/firewalld/Config.in new file +43 -0
43 lines not on this page · raw message
package/firewalld/S46firewalld new file +66 -0
66 lines not on this page · raw message
package/firewalld/firewalld.hash new file +3 -0
@@ -0,0 +1,3 @@ +# Locally computed +sha256 3be5a3caa36d1026c5b72d3f61dd963dccd953791b04af03d9946b24bef8391e firewalld-1.3.2.tar.gz +sha256 8177f97513213526df2cf6184d8ff986c675afb514d4e68a404010521b880643 COPYING
package/firewalld/firewalld.mk new file +257 -0
257 lines not on this page · raw message
Signature · 6 lines
2.40.1 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Adam,
Quoted 3 lines · On Sat, 3 Jun 2023 19:52:04 -0700 Adam Duskett <[email protected]> wrote:
Firewalld provides a dynamically managed firewall with
support for network or firewall zones to define the trust level of network connections or interfaces.
Thanks for the patch, which I have applied to our next branch, with a few small changes. See below.
Quoted 6 lines
package/Config.in | 1 + package/firewalld/Config.in | 43 ++++++ package/firewalld/S46firewalld | 66 ++++++++ package/firewalld/firewalld.hash | 3 + package/firewalld/firewalld.mk | 257 +++++++++++++++++++++++++++++++ 5 files changed, 370 insertions(+)
An entry in the DEVELOPERS file was missing, so I've added that.
Quoted 7 lines
package/firewalld/Config.in new file +1
-0@@ -0,0 +1,43 @@ +config BR2_PACKAGE_FIREWALLD
package/firewalld/Config.in line 11
Quoted 10 lines
package/firewalld/Config.in new file +10
-0+ bool "firewalld" + depends on BR2_USE_MMU # gobject-introspection, python-gobject + depends on BR2_PACKAGE_GOBJECT_INTROSPECTION_ARCH_SUPPORTS + depends on BR2_USE_WCHAR # glib2, dbus-python, nftables + depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 # gobject-introspection + depends on BR2_TOOLCHAIN_HAS_THREADS # dbus-python + depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_12 + depends on BR2_TOOLCHAIN_USES_GLIBC # gobject-introspection + depends on BR2_HOST_GCC_AT_LEAST_8 # gobject-introspection -> host-qemu + depends on BR2_PACKAGE_PYTHON3 # dbus-python, gobject-introspection
I think for a package like this a "select BR2_PACKAGE_PYTHON3" made more sense than "depends on BR2_PACKAGE_PYTHON3", so I've changed that and of course propagated the reverse dependencies as needed.
Quoted 13 lines
package/firewalld/Config.in new file +13
-0+ select BR2_PACKAGE_DBUS # dbus-python + select BR2_PACKAGE_DBUS_PYTHON + select BR2_PACKAGE_GOBJECT_INTROSPECTION + select BR2_PACKAGE_JANSSON # Uses the nftables json interface + select BR2_PACKAGE_NFTABLES + select BR2_PACKAGE_PYTHON_GOBJECT + help + Firewalld provides a dynamically managed firewall with + support for network or firewall zones to define the trust + level of network connections or interfaces. It has support + for IPv4, IPv6 firewall settings and for ethernet bridges and + a separation of runtime and permanent configuration options. + It also provides an interface for services or applications to
package/firewalld/Config.in line 34
Quoted 10 lines
package/firewalld/Config.in new file +10
-0+ add ip*tables and ebtables rules directly. + + Note: Firewalld uses nftables as the backend and requires + kernel version >= 5.3. + + https://github.com/firewalld/firewalld + +comment "firewalld needs python3" + depends on !BR2_PACKAGE_PYTHON3 + depends on BR2_PACKAGE_GOBJECT_INTROSPECTION_ARCH_SUPPORTS
So I dropped this comment.
package/firewalld/Config.in line 36
Quoted 2 lines
package/firewalld/Config.in new file +2
-0+ +comment "firewalld needs a glibc toolchain w/ wchar, dynamic library, headers >= 3.12, gcc >= 4.9, host gcc >= 8"
Interestingly, you mentioned "dynamic library" here, but there was nothing related to BR2_STATIC_LIBS. Turned out that with Python3 being selected, in fact !BR2_STATIC_LIBS has been added in the dependencies, and therefore "needs [...] dynamic library" is indeed correct.
package/firewalld/Config.in
Quoted 10 lines
package/firewalld/Config.in new file +10
-0+ depends on BR2_USE_MMU + depends on BR2_PACKAGE_GOBJECT_INTROSPECTION_ARCH_SUPPORTS + depends on !BR2_TOOLCHAIN_USES_GLIBC || \ + !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_12 || \ + !BR2_USE_WCHAR || BR2_STATIC_LIBS || \ + !BR2_TOOLCHAIN_GCC_AT_LEAST_4_9 || \ + !BR2_HOST_GCC_AT_LEAST_8 +ifeq ($(BR2_SYSTEM_ENABLE_NLS),y) +FIREWALLD_CONF_OPTS += --enable-nls +endif
This NLS option is already handled in a generic way by the autotools-package infrastructure, so it is not necessary to do it here.
I did a build, which went well, so I've pushed your patch with the above changes.
Thanks for this contribution!
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 3 lines · On Sat, 3 Jun 2023 19:52:04 -0700 Adam Duskett <[email protected]> wrote:
Firewalld provides a dynamically managed firewall with
support for network or firewall zones to define the trust level of network connections or interfaces.
One thing that would be really nice as a follow-up patch would be a test case for the runtime test infrastructure. This is especially relevant as it is Python based, so it is easy to miss runtime dependencies that might be needed. I've added Julien Olivain in Cc, who can provide guidance on that, as he has probably written some of the most complex/elaborate test cases we gave in our runtime infrastructure.
Thomas
Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training https://bootlin.com _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Thomas, Adam, all,
I'm adding Yegor Yefremov in CC, since he is registered as a nftables developer.
Quoted 7 lines · Thomas Petazzoni
Quoted 3 lines · On Sat, 3 Jun 2023 19:52:04 -0700 Adam Duskett <[email protected]> wrote:
Firewalld provides a dynamically managed firewall with
support for network or firewall zones to define the trust level of network connections or interfaces.
Quoted 6 lines
One thing that would be really nice as a follow-up patch would be a test case for the runtime test infrastructure. This is especially relevant as it is Python based, so it is easy to miss runtime dependencies that might be needed. I've added Julien Olivain in Cc, who can provide guidance on that, as he has probably written some of the most complex/elaborate test cases we gave in our runtime infrastructure.
I'll be happy to write such a firewalld runtime test.
When trying to do it, on branch next at commit eea0c9f, I was not able to run any of the simplest firwalld command (Python nftables module cannot load).
With a configuration such as:
make qemu_aarch64_virt_defconfig
utils/config \
-e BR2_PACKAGE_FIREWALLD \
--set-str BR2_TARGET_ROOTFS_EXT2_SIZE 200M
make olddefconfig
make
output/images/start-qemu.shRunning simple commands, logged as root on qemu target, such as:
firewall-offline-cmd --version
firewalld --nofork --nopid
python -c 'import nftables'All fail with output such as:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'nftables'
I quickly tried with updated version of libnftnl and nftables proposed at [1] but did not helped.
Upstream nftables reworked Python integration in commits [2] [3] but are not yet in a release.
So I believe the nftables package needs a rework, at least for its python support. We should first write a runtime test for it (including its Python support). Only then, we should be able to write a runtime test for firewalld.
Best regards,
Julien.
[1] https://patchwork.ozlabs.org/project/buildroot/list/?series=368887
[2] https://git.netfilter.org/nftables/commit/?id=b3def33efecb2f7be39fc9aefc9546907202056c
[3] https://git.netfilter.org/nftables/commit/?id=8e603e0f7eec7c0000344a004228a30fbf0ece5c
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Julien, All,
On 2023-08-15 17:00 +0200, Julien Olivain spake thusly:
Quoted 30 lines · Thomas Petazzoni
Quoted 6 lines
Quoted 4 lines · On Sat, 3 Jun 2023 19:52:04 -0700 Adam Duskett <[email protected]> wrote:
Firewalld provides a dynamically managed firewall with support for network or firewall zones to define the trust level of network
connections or interfaces.Quoted 6 lines
One thing that would be really nice as a follow-up patch would be a test case for the runtime test infrastructure. This is especially relevant as it is Python based, so it is easy to miss runtime dependencies that might be needed. I've added Julien Olivain in Cc, who can provide guidance on that, as he has probably written some of the most complex/elaborate test cases we gave in our runtime infrastructure.
I'll be happy to write such a firewalld runtime test.
When trying to do it, on branch next at commit eea0c9f, I was not able to run any of the simplest firwalld command (Python nftables module cannot load).
With a configuration such as:
make qemu_aarch64_virt_defconfig utils/config \ -e BR2_PACKAGE_FIREWALLD \ --set-str BR2_TARGET_ROOTFS_EXT2_SIZE 200M make olddefconfig make output/images/start-qemu.sh
Quoted 5 lines
Running simple commands, logged as root on qemu target, such as:
firewall-offline-cmd --version firewalld --nofork --nopid python -c 'import nftables'
I did about the same, starting off with qemu_aarch64_virt_defconfig, but manually tweaked the configuration to switch to a bootlin glibc toolchain, and manually enable firewall. And it works:
# firewalld --version
usage: firewalld [-h] [--debug [level]] [--debug-gc] [--nofork] [--nopid]
[--system-config path] [--default-config path]
[--log-target {mixed,syslog,file,console}] [--log-file path]
firewalld: error: unrecognized arguments: --version
# firewall-offline-cmd --version
1.3.2
# firewalld --nofork --nopid
2023-08-15 16:24:04 ipset not usable, disabling ipset usage in firewall. Other set backends (nftables) remain usable.
2023-08-15 16:24:04 iptables-restore and iptables are missing, IPv4 direct rules won't be usable.
2023-08-15 16:24:04 ip6tables-restore and ip6tables are missing, IPv6 direct rules won't be usable.
2023-08-15 16:24:04 ebtables-restore and ebtables are missing, eb direct rules won't be usable.
^C#
# python -c 'import nftables'
#Regards,
Yann E. MORIN.
Quoted 29 lines
All fail with output such as:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'nftables'I quickly tried with updated version of libnftnl and nftables proposed at [1] but did not helped.
Upstream nftables reworked Python integration in commits [2] [3] but are not yet in a release.
So I believe the nftables package needs a rework, at least for its python support. We should first write a runtime test for it (including its Python support). Only then, we should be able to write a runtime test for firewalld.
Best regards,
Julien.
[1] https://patchwork.ozlabs.org/project/buildroot/list/?series=368887
[2] https://git.netfilter.org/nftables/commit/?id=b3def33efecb2f7be39fc9aefc9546907202056c
[3] https://git.netfilter.org/nftables/commit/?id=8e603e0f7eec7c0000344a004228a30fbf0ece5c_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------' _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot