From: Petr Písař Date: Mon, 24 Jul 2023 08:36:43 +0000 (+0200) Subject: Fix "location list-networks-by-as --format ipset" output X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ad076de1c4d6a66a5ed0f7550792be04bf3fa681;p=location%2Ffedora%2Flibloc.git Fix "location list-networks-by-as --format ipset" output --- diff --git a/libloc-0.9.16-export-Raise-an-error-when-trying-to-export-ipset-fo.patch b/libloc-0.9.16-export-Raise-an-error-when-trying-to-export-ipset-fo.patch new file mode 100644 index 0000000..1c49658 --- /dev/null +++ b/libloc-0.9.16-export-Raise-an-error-when-trying-to-export-ipset-fo.patch @@ -0,0 +1,33 @@ +From 1f2ece2868f370bda1c4c01be401bcfb137f383d Mon Sep 17 00:00:00 2001 +From: Michael Tremer +Date: Mon, 3 Jul 2023 15:05:13 +0000 +Subject: [PATCH 2/2] export: Raise an error when trying to export ipset for + both families +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Michael Tremer +Signed-off-by: Petr Písař +--- + src/python/location/export.py | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/python/location/export.py b/src/python/location/export.py +index 25a532e..1d147b1 100644 +--- a/src/python/location/export.py ++++ b/src/python/location/export.py +@@ -147,6 +147,10 @@ class IpsetOutputWriter(OutputWriter): + # Count all networks + self.networks = 0 + ++ # Check that family is being set ++ if not self.family: ++ raise ValueError("%s requires family being set" % self.__class__.__name__) ++ + @property + def hashsize(self): + """ +-- +2.41.0 + diff --git a/libloc-0.9.16-location-Fix-correct-set-name-when-family-is-selecte.patch b/libloc-0.9.16-location-Fix-correct-set-name-when-family-is-selecte.patch new file mode 100644 index 0000000..0605dae --- /dev/null +++ b/libloc-0.9.16-location-Fix-correct-set-name-when-family-is-selecte.patch @@ -0,0 +1,63 @@ +From 76852f60da75827f1296358e6be511a04355d073 Mon Sep 17 00:00:00 2001 +From: Michael Tremer +Date: Mon, 3 Jul 2023 14:53:50 +0000 +Subject: [PATCH 1/2] location: Fix correct set name when family is selected +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This does however not fix the problem if no --family= parameter is being +given because we will then export for multiple families in one file. + +This is for example not supported for ipset. + +Fixes: #12897 +Signed-off-by: Michael Tremer +Signed-off-by: Petr Písař +--- + src/scripts/location.in | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/scripts/location.in b/src/scripts/location.in +index be13156..60b11d6 100644 +--- a/src/scripts/location.in ++++ b/src/scripts/location.in +@@ -514,7 +514,7 @@ class CLI(object): + writer = self.__get_output_formatter(ns) + + for asn in ns.asn: +- f = writer("AS%s" % asn, f=sys.stdout) ++ f = writer("AS%s" % asn, family=ns.family, f=sys.stdout) + + # Print all matching networks + for n in db.search_networks(asns=[asn], family=ns.family): +@@ -527,7 +527,7 @@ class CLI(object): + + for country_code in ns.country_code: + # Open standard output +- f = writer(country_code, f=sys.stdout) ++ f = writer(country_code, family=ns.family, f=sys.stdout) + + # Print all matching networks + for n in db.search_networks(country_codes=[country_code], family=ns.family): +@@ -554,7 +554,7 @@ class CLI(object): + raise ValueError(_("You must at least pass one flag")) + + writer = self.__get_output_formatter(ns) +- f = writer("custom", f=sys.stdout) ++ f = writer("custom", family=ns.family, f=sys.stdout) + + for n in db.search_networks(flags=flags, family=ns.family): + f.write(n) +@@ -563,7 +563,7 @@ class CLI(object): + + def handle_list_bogons(self, db, ns): + writer = self.__get_output_formatter(ns) +- f = writer("bogons", f=sys.stdout) ++ f = writer("bogons", family=ns.family, f=sys.stdout) + + for n in db.list_bogons(family=ns.family): + f.write(n) +-- +2.41.0 + diff --git a/libloc.spec b/libloc.spec index 71738ed..3ced5db 100644 --- a/libloc.spec +++ b/libloc.spec @@ -1,6 +1,6 @@ Name: libloc Version: 0.9.16 -Release: 5%{?dist} +Release: 6%{?dist} Summary: Library to determine a location of an IP address in the Internet # COPYING: LGPL-2.1 text # data/database.db: CC-BY-SA-4.0 @@ -76,6 +76,12 @@ Summary: Library to determine a location of an IP address in the Internet License: LGPL-2.1-or-later URL: https://location.ipfire.org/ Source0: https://source.ipfire.org/releases/%{name}/%{name}-%{version}.tar.gz +# 1/2 Fix "location list-networks-by-as --format ipset" output, +# in upstream after 0.9.16, upstream bug #12897 +Patch0: libloc-0.9.16-location-Fix-correct-set-name-when-family-is-selecte.patch +# 2/2 Fix "location list-networks-by-as --format ipset" output, +# in upstream after 0.9.16, upstream bug #12897 +Patch1: libloc-0.9.16-export-Raise-an-error-when-trying-to-export-ipset-fo.patch BuildRequires: asciidoc BuildRequires: autoconf >= 2.60 # autoconf-archive for unbundled m4/ax_prog_perl_modules.m4 @@ -107,7 +113,7 @@ BuildRequires: pkgconf-m4 BuildRequires: pkgconf-pkg-config BuildRequires: pkgconfig(libsystemd) BuildRequires: pkgconfig(python) >= 3.4 -# pkgconfig(systemd) no needed, we configure a value from systemd-rpm-macros +# pkgconfig(systemd) not needed, we configure a value from systemd-rpm-macros BuildRequires: python3-devel BuildRequires: sed BuildRequires: systemd-rpm-macros @@ -262,6 +268,10 @@ make check %{?_smp_mflags} %{_unitdir}/* %changelog +* Mon Jul 24 2023 Petr Pisar - 0.9.16-6 +- Fix "location list-networks-by-as --format ipset" output + (upstream bug #12897) + * Thu Jul 20 2023 Fedora Release Engineering - 0.9.16-5 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild