1From d6706e827f703c63ab519d104c53833fa5cebe03 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[Daniel: updated for 3.10.7]
20Signed-off-by: Daniel Lang <d.lang@abatec.at>
21---
22 Lib/crypt.py | 4 +++-
23 1 file changed, 3 insertions(+), 1 deletion(-)
24
25diff --git a/Lib/crypt.py b/Lib/crypt.py
26index de4a14a3884..ba482487a7a 100644
27--- a/Lib/crypt.py
28+++ b/Lib/crypt.py
29@@ -98,7 +98,9 @@ def _add_method(name, *args, rounds=None):
30         result = crypt('', salt)
31     except OSError as e:
32         # Not all libc libraries support all encryption methods.
33-        if e.errno in {errno.EINVAL, errno.EPERM, errno.ENOSYS}:
34+        # Not all libc libraries set errno when encryption method is not
35+        # available.
36+        if e.errno in {errno.EINVAL, errno.EPERM, errno.ENOSYS} or e.errno == 0:
37             return False
38         raise
39     if result and len(result) == method.total_size:
40--
412.44.0
42
43