Accepting request 1248250 from security:apparmor

- add py313-aa-notify.patch to adapt the last bits to python 3.13 (forwarded request 1247658 from mcalabkova)

OBS-URL: https://build.opensuse.org/request/show/1248250
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/apparmor?expand=0&rev=219
This commit is contained in:
Dominique Leuenberger 2025-02-25 15:40:30 +00:00 committed by Git OBS Bridge
commit 3b7ddec02c
3 changed files with 86 additions and 0 deletions

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Fri Feb 21 13:29:19 UTC 2025 - Markéta Machová <mmachova@suse.com>
- add py313-aa-notify.patch to adapt the last bits to python 3.13
-------------------------------------------------------------------
Wed Feb 19 13:36:20 UTC 2025 - Matej Cepl <mcepl@cepl.eu>

View File

@ -88,6 +88,10 @@ Patch10: mesa-cachedir.diff
# add python 3.13 fixes/workarounds
Patch11: python313.patch
# PATCH-FIX-UPSTREAM https://gitlab.com/apparmor/apparmor/-/merge_requests/1495 utils: adjusts aa-notify tests to handle Python 3.13+
# to finish python313 support
Patch12: py313-aa-notify.patch
PreReq: sed
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: autoconf
@ -357,6 +361,7 @@ mv -v profiles/apparmor.d/usr.lib.apache2.mpm-prefork.apache2 profiles/apparmor/
%endif
%patch -p1 -P 10
%patch -p1 -P 11
%patch -p1 -P 12
%build
export SUSE_ASNEEDED=0

76
py313-aa-notify.patch Normal file
View File

@ -0,0 +1,76 @@
From 6336465edfc9eac73f8d28f4b84561b10fcb78aa Mon Sep 17 00:00:00 2001
From: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
Date: Tue, 21 Jan 2025 20:52:36 +0100
Subject: [PATCH] utils: adjusts aa-notify tests to handle Python 3.13+
Python 3.13 changes the formatting of long-short option pairs that use a
meta-variable. Up until 3.13 the meta-variable was repeated. Since
Python change [1] the meta-var is only printed once.
[1] https://github.com/python/cpython/pull/103372
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
---
utils/test/test-aa-notify.py | 31 ++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
Index: apparmor-v4.0.3/utils/test/test-aa-notify.py
===================================================================
--- apparmor-v4.0.3.orig/utils/test/test-aa-notify.py
+++ apparmor-v4.0.3/utils/test/test-aa-notify.py
@@ -14,6 +14,7 @@ import os
import pwd
import signal
import subprocess
+import sys
import time
import unittest
from tempfile import NamedTemporaryFile
@@ -198,14 +199,13 @@ Display AppArmor notifications or messag
-p, --poll poll AppArmor logs and display notifications
--display DISPLAY set the DISPLAY environment variable (might be needed if
sudo resets $DISPLAY)
- -f FILE, --file FILE search FILE for AppArmor messages
+ -f, --file FILE search FILE for AppArmor messages
-l, --since-last display stats since last login
- -s NUM, --since-days NUM
- show stats for last NUM days (can be used alone or with
+ -s, --since-days NUM show stats for last NUM days (can be used alone or with
-p)
-v, --verbose show messages with stats
- -u USER, --user USER user to drop privileges to when not using sudo
- -w NUM, --wait NUM wait NUM seconds before displaying notifications (with
+ -u, --user USER user to drop privileges to when not using sudo
+ -w, --wait NUM wait NUM seconds before displaying notifications (with
-p)
--debug debug mode
@@ -226,6 +226,28 @@ Filtering options:
regular expression to match the network socket type
'''
+ if sys.version_info[:2] < (3, 13):
+ # Python 3.13 tweaked argparse output [1]. When running on older
+ # Python versions, we adapt the expected output to match.
+ #
+ # https://github.com/python/cpython/pull/103372
+ patches = [(
+ ' -f, --file FILE search FILE for AppArmor messages',
+ ' -f FILE, --file FILE search FILE for AppArmor messages',
+ ), (
+ ' -s, --since-days NUM show stats for last NUM days (can be used alone or with',
+ ' -s NUM, --since-days NUM\n'
+ + ' show stats for last NUM days (can be used alone or with',
+ ), (
+ ' -u, --user USER user to drop privileges to when not using sudo',
+ ' -u USER, --user USER user to drop privileges to when not using sudo',
+ ), (
+ ' -w, --wait NUM wait NUM seconds before displaying notifications (with',
+ ' -w NUM, --wait NUM wait NUM seconds before displaying notifications (with',
+ )]
+ for patch in patches:
+ expected_output_2 = expected_output_2.replace(patch[0], patch[1])
+
return_code, output = cmd(aanotify_bin + ['--help'])
result = 'Got return code {}, expected {}\n'.format(return_code, expected_return_code)
self.assertEqual(expected_return_code, return_code, result + output)