1From 3c83eedcc2df3ecf6c4a17953ca24dff60c1378e Mon Sep 17 00:00:00 2001
2From: Romain Naour <romain.naour@gmail.com>
3Date: Thu, 12 Nov 2020 00:16:18 +0100
4Subject: [PATCH] lib/crypt: uClibc-ng doesn't set errno when encryption method
5 is not available
6
7Since commit [1] in cpython, an exception is raised when an encryption method
8is not available. This eception is handled only if errno is set to EINVAL by
9crypt() but uClibc-ng doesn't set errno in crypt() [2].
10
11Fixes:
12https://gitlab.com/buildroot.org/buildroot/-/jobs/830981961
13https://gitlab.com/buildroot.org/buildroot/-/jobs/830981979
14
15[1] https://github.com/python/cpython/commit/0d3fe8ae4961bf551e7d5e42559e2ede1a08fd7c
16[2] https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/libcrypt/crypt.c?h=v1.0.36#n29
17
18Signed-off-by: Romain Naour <romain.naour@gmail.com>
19---
20 Lib/crypt.py | 4 +++-
21 1 file changed, 3 insertions(+), 1 deletion(-)
22
23diff --git a/Lib/crypt.py b/Lib/crypt.py
24index 33dbc46bb3..4692a5270c 100644
25--- a/Lib/crypt.py
26+++ b/Lib/crypt.py
27@@ -94,7 +94,9 @@ def _add_method(name, *args, rounds=None):
28         result = crypt('', salt)
29     except OSError as e:
30         # Not all libc libraries support all encryption methods.
31-        if e.errno == errno.EINVAL:
32+        # Not all libc libraries set errno when encryption method is not
33+        # available.
34+        if e.errno == errno.EINVAL or e.errno == 0:
35             return False
36         raise
37     if result and len(result) == method.total_size:
38--
392.25.4
40
41