Bug 15198 - [python3-fail2ban] PY_SSIZE_T_CLEAN macro must be defined for '#' formats" with python3
Summary: [python3-fail2ban] PY_SSIZE_T_CLEAN macro must be defined for '#' formats" wi...
Status: RESOLVED DUPLICATE of bug 15189
Alias: None
Product: Other YP Layers
Classification: Build System, Metadata & Runtime
Component: meta-security (show other bugs)
Version: 4.0
Hardware: Other arm
: Undecided critical
Target Milestone: 0.0.0
Assignee: akuster
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2023-08-18 11:34 UTC by SAHEERK
Modified: 2023-08-18 11:36 UTC (History)
0 users

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description SAHEERK 2023-08-18 11:34:31 UTC
I'm trying to run the python3-fail2ban component built by yocto, but I'm encountering an error related to the PY_SSIZE_T_CLEAN macro. The error message is PY_SSIZE_T_CLEAN macro must be defined for '#' formats.

I have no issues with 'python' dependent fail2ban, issues observed only with 'python3' dependent fail2ban

I've looked into the issue and found that in the Python 3.10 C-API documentation https://docs.python.org/3.10/c-api/arg.html#arg-parsing, it's mentioned that,

"Note:  For all # variants of formats (s#, y#, etc.), the macro PY_SSIZE_T_CLEAN must be defined before including Python.h. On Python 3.9 and older, the type of the length argument is [Py_ssize_t] if the PY_SSIZE_T_CLEAN macro is defined, or int otherwise"

I tried to resolve this issue by defining the PY_SSIZE_T_CLEAN macro before including Python.h. But the issue was not resolved, patch snippet here,
+#ifndef PY_SSIZE_T_CLEAN
+#define PY_SSIZE_T_CLEAN 1
+#endif
#include "Python.h"

Also included CFLAGS += "PY_SSIZE_T_CLEAN " in the python3-fail2ban component. No impact on observation

-------Environment---------------------
*) Fail2Ban version : python3-fail2ban 0.11.2 : https://layers.openembedded.org/layerindex/recipe/304629/
*) OS, including release name/version : Linux built by yocto kirkstone (Yocto Project 4.0)
*) Python dependency: python3 3.10.12 https://layers.openembedded.org/layerindex/recipe/300253/
*) poky version 4.0.4
*) No additional patches or changes
*) No other customization

----------Steps to reproduce----------
1. Created a jail /etc/fail2ban/jail.local with the below data,
[sshd]
enabled = yes
port    = ssh
backend = systemd

2. restarted fail2ban services: sudo systemctl restart fail2ban.service

3. Relevant parts of /var/log/fail2ban.log file:
fail2ban-server[11527]: fail2ban                [11527]: ERROR   NOK: ("PY_SSIZE_T_CLEAN macro must be defined for '#' formats",)
Comment 1 SAHEERK 2023-08-18 11:36:52 UTC
duplicate of https://bugzilla.yoctoproject.org/show_bug.cgi?id=15189

*** This bug has been marked as a duplicate of bug 15189 ***