From 4ff57fb387f5d4bfdbdefab203b36f80fc510660 Mon Sep 17 00:00:00 2001 From: Thomas Andrejak Date: Sat, 14 Aug 2021 00:52:08 +0200 Subject: [PATCH] Fix BZ 1973946 --- libprelude-5.2.0-fix-PyIOBase_Type.patch | 53 ++++++++++++++++++++++++ libprelude.spec | 7 +++- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 libprelude-5.2.0-fix-PyIOBase_Type.patch diff --git a/libprelude-5.2.0-fix-PyIOBase_Type.patch b/libprelude-5.2.0-fix-PyIOBase_Type.patch new file mode 100644 index 0000000..fba6213 --- /dev/null +++ b/libprelude-5.2.0-fix-PyIOBase_Type.patch @@ -0,0 +1,53 @@ +Description: Fix PyIOBase_Type +Author: Thomas Andrejak +Last-Update: 2021-08-13 + +--- libprelude-5.2.0/bindings/python/libpreludecpp-python.i 2020-09-09 16:30:32.510000000 +0200 ++++ libprelude-5.2.0/bindings/python/libpreludecpp-python.i 2021-08-13 23:20:11.672221930 +0200 +@@ -163,6 +163,26 @@ + $1 = _cb_python_log; + }; + ++%{ ++static PyObject *PyIOBase_TypeObj; ++ ++static int init_file_emulator(void) ++{ ++ PyObject *io = PyImport_ImportModule("_io"); ++ if (io == NULL) ++ return -1; ++ PyIOBase_TypeObj = PyObject_GetAttrString(io, "_IOBase"); ++ if (PyIOBase_TypeObj == NULL) ++ return -1; ++ return 0; ++} ++%} ++ ++%init %{ ++if (init_file_emulator() < 0) { ++ return NULL; ++} ++%} + + /* tell swig not to cast void * value */ + %typemap(in) void *nocast_file_p %{ +@@ -172,8 +192,7 @@ + + } + #else +- extern PyTypeObject PyIOBase_Type; +- if ( ! PyObject_IsInstance((PyObject *) $input, (PyObject *) &PyIOBase_Type) ) { ++ if ( ! PyObject_IsInstance((PyObject *) $input, PyIOBase_TypeObj) ) { + SWIG_exception_fail(SWIG_RuntimeError, "Argument is not a file object"); + } + #endif +@@ -186,8 +205,7 @@ + #if PY_VERSION_HEX < 0x03000000 + $1 = PyFile_Check((PyObject *) $input); + #else +- extern PyTypeObject PyIOBase_Type; +- $1 = PyObject_IsInstance((PyObject *) $input, (PyObject *) &PyIOBase_Type); ++ $1 = PyObject_IsInstance((PyObject *) $input, PyIOBase_TypeObj); + #endif + %} + diff --git a/libprelude.spec b/libprelude.spec index 4ef49cf..ad5ca39 100644 --- a/libprelude.spec +++ b/libprelude.spec @@ -7,7 +7,7 @@ Name: libprelude Version: 5.2.0 -Release: 8%{?dist} +Release: 9%{?dist} Summary: Secure Connections between all Sensors and the Prelude Manager License: LGPL-2.1+ URL: https://www.prelude-siem.org/ @@ -37,6 +37,8 @@ Patch10: libprelude-5.2.0-fix-test_rwlock1.patch Patch11: libprelude-5.2.0-ruby27.patch # Remove unneded libraries from libprelude-config --libs (bz#1830473) Patch12: libprelude-5.2.0-clean_libprelude-config.patch +# #1973946 +Patch13: libprelude-5.2.0-fix-PyIOBase_Type.patch BuildRequires: make BuildRequires: gcc BuildRequires: gcc-c++ @@ -239,6 +241,9 @@ patch -d %{buildroot}%{_includedir}/libprelude/ -p0 < %SOURCE1 %doc AUTHORS ChangeLog README NEWS %changelog +* Fri Aug 13 2021 Thomas Andrejak - 5.2.0-9 +- Fix BZ 1973946 + * Thu Aug 05 2021 Gwyn Ciesla - 5.2.0-8 - Fix BZ 1908783