diff options
Diffstat (limited to 'recipes-mac/AppArmor/files/0001-fail.py-handle-missing-cgitb.patch')
-rw-r--r-- | recipes-mac/AppArmor/files/0001-fail.py-handle-missing-cgitb.patch | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/recipes-mac/AppArmor/files/0001-fail.py-handle-missing-cgitb.patch b/recipes-mac/AppArmor/files/0001-fail.py-handle-missing-cgitb.patch new file mode 100644 index 0000000..28c1d9e --- /dev/null +++ b/recipes-mac/AppArmor/files/0001-fail.py-handle-missing-cgitb.patch | |||
@@ -0,0 +1,74 @@ | |||
1 | From 434e34bb510b4cab04e64cd5b21d635c6be8c8ea Mon Sep 17 00:00:00 2001 | ||
2 | From: Mikko Rapeli <mikko.rapeli@linaro.org> | ||
3 | Date: Fri, 29 Nov 2024 13:46:32 +0000 | ||
4 | Subject: [PATCH] fail.py: handle missing cgitb | ||
5 | |||
6 | It's no longer in python standard library starting | ||
7 | at version 3.13. Fixes: | ||
8 | |||
9 | root@qemuarm64:~# aa-complain /etc/apparmor.d/* | ||
10 | Traceback (most recent call last): | ||
11 | File "/usr/sbin/aa-complain", line 18, in <module> | ||
12 | from apparmor.fail import enable_aa_exception_handler | ||
13 | File "/usr/lib/python3.13/site-packages/apparmor/fail.py", line 12, in <module> | ||
14 | import cgitb | ||
15 | ModuleNotFoundError: No module named 'cgitb' | ||
16 | |||
17 | Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org> | ||
18 | --- | ||
19 | utils/apparmor/fail.py | 25 +++++++++++++++---------- | ||
20 | 1 file changed, 15 insertions(+), 10 deletions(-) | ||
21 | |||
22 | Upstream-Status: Backport | ||
23 | |||
24 | diff --git a/utils/apparmor/fail.py b/utils/apparmor/fail.py | ||
25 | index ece6efc4..a71ceb66 100644 | ||
26 | --- a/utils/apparmor/fail.py | ||
27 | +++ b/utils/apparmor/fail.py | ||
28 | @@ -8,7 +8,11 @@ | ||
29 | # | ||
30 | # ------------------------------------------------------------------ | ||
31 | |||
32 | -import cgitb | ||
33 | +try: | ||
34 | + import cgitb | ||
35 | +except ImportError: | ||
36 | + cgitb = None | ||
37 | + pass | ||
38 | import sys | ||
39 | import traceback | ||
40 | from tempfile import NamedTemporaryFile | ||
41 | @@ -32,20 +36,21 @@ def handle_exception(*exc_info): | ||
42 | print('', file=sys.stderr) | ||
43 | error(ex.value) | ||
44 | else: | ||
45 | - with NamedTemporaryFile('w', prefix='apparmor-bugreport-', suffix='.txt', delete=False) as file: | ||
46 | - cgitb_hook = cgitb.Hook(display=1, file=file, format='text', context=10) | ||
47 | - cgitb_hook.handle(exc_info) | ||
48 | - | ||
49 | - file.write('Please consider reporting a bug at https://gitlab.com/apparmor/apparmor/-/issues\n') | ||
50 | - file.write('and attach this file.\n') | ||
51 | + if cgitb: | ||
52 | + with NamedTemporaryFile('w', prefix='apparmor-bugreport-', suffix='.txt', delete=False) as file: | ||
53 | + cgitb_hook = cgitb.Hook(display=1, file=file, format='text', context=10) | ||
54 | + cgitb_hook.handle(exc_info) | ||
55 | + file.write('Please consider reporting a bug at https://gitlab.com/apparmor/apparmor/-/issues\n') | ||
56 | + file.write('and attach this file.\n') | ||
57 | |||
58 | print(''.join(traceback.format_exception(*exc_info)), file=sys.stderr) | ||
59 | - print('', file=sys.stderr) | ||
60 | print('An unexpected error occurred!', file=sys.stderr) | ||
61 | print('', file=sys.stderr) | ||
62 | - print('For details, see %s' % file.name, file=sys.stderr) | ||
63 | + if cgitb: | ||
64 | + print('For details, see %s' % file.name, file=sys.stderr) | ||
65 | print('Please consider reporting a bug at https://gitlab.com/apparmor/apparmor/-/issues', file=sys.stderr) | ||
66 | - print('and attach this file.', file=sys.stderr) | ||
67 | + if cgitb: | ||
68 | + print('and attach this file.', file=sys.stderr) | ||
69 | |||
70 | |||
71 | def enable_aa_exception_handler(): | ||
72 | -- | ||
73 | 2.43.0 | ||
74 | |||