<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>15189</bug_id>
          
          <creation_ts>2023-08-11 12:52:53 +0000</creation_ts>
          <short_desc>[python3-fail2ban] PY_SSIZE_T_CLEAN macro must be defined for &apos;#&apos; formats&quot; with python3</short_desc>
          <delta_ts>2023-08-18 13:53:15 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>Other YP Layers</product>
          <component>meta-security</component>
          <version>4.0</version>
          <rep_platform>Other</rep_platform>
          <op_sys>arm</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Undecided</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>4.0.10</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="SAHEERK">saheer.kottakkadan</reporter>
          <assigned_to name="akuster">akuster808</assigned_to>
          <cc>randy.macleod</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>96244</commentid>
    <comment_count>0</comment_count>
    <who name="SAHEERK">saheer.kottakkadan</who>
    <bug_when>2023-08-11 12:52:53 +0000</bug_when>
    <thetext>I&apos;m trying to run the python3-fail2ban component built by yocto, but I&apos;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 &apos;#&apos; formats.

I have no issues with &apos;python&apos; dependent fail2ban, issues observed only with &apos;python3&apos; dependent fail2ban

I&apos;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&apos;s mentioned that,

&quot;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&quot;

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 &quot;Python.h&quot;

Also included CFLAGS += &quot;PY_SSIZE_T_CLEAN &quot; 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/
*) 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: (&quot;PY_SSIZE_T_CLEAN macro must be defined for &apos;#&apos; formats&quot;,)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96245</commentid>
    <comment_count>1</comment_count>
    <who name="SAHEERK">saheer.kottakkadan</who>
    <bug_when>2023-08-11 13:51:14 +0000</bug_when>
    <thetext>Environment Info addition: poky version 4.0.4</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96266</commentid>
    <comment_count>2</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2023-08-17 14:36:57 +0000</bug_when>
    <thetext>This isn&apos;t an oe-core/bitbake bug, please talk with the meta-security maintainers. See the meta-security README</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96282</commentid>
    <comment_count>3</comment_count>
    <who name="SAHEERK">saheer.kottakkadan</who>
    <bug_when>2023-08-18 11:35:56 +0000</bug_when>
    <thetext>Created a ticket under meta-security: https://bugzilla.yoctoproject.org/show_bug.cgi?id=15198</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96284</commentid>
    <comment_count>4</comment_count>
    <who name="SAHEERK">saheer.kottakkadan</who>
    <bug_when>2023-08-18 11:36:53 +0000</bug_when>
    <thetext>*** Bug 15198 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96285</commentid>
    <comment_count>5</comment_count>
    <who name="SAHEERK">saheer.kottakkadan</who>
    <bug_when>2023-08-18 11:38:29 +0000</bug_when>
    <thetext>This bug is the active ticket. Duplicate ticket closed</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>96288</commentid>
    <comment_count>6</comment_count>
    <who name="SAHEERK">saheer.kottakkadan</who>
    <bug_when>2023-08-18 13:53:15 +0000</bug_when>
    <thetext>This link: https://github.com/systemd/python-systemd/issues/107,  helped me to resolve this issue.

So ticket closing</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>