diff options
author | Armin Rigo <arigo@tunes.org> | 2020-10-05 22:14:31 +0200 |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2020-10-05 22:14:31 +0200 |
commit | 2f6629b07b8b2ad645e09eda49917be0fd662932 (patch) | |
tree | bb8277f497e73d58a6340098c7324d2ee80b6d61 /lib_pypy | |
parent | improve the fake objspace so that it fails if you pass a resizable list to ne... (diff) | |
download | pypy-2f6629b07b8b2ad645e09eda49917be0fd662932.tar.gz pypy-2f6629b07b8b2ad645e09eda49917be0fd662932.tar.bz2 pypy-2f6629b07b8b2ad645e09eda49917be0fd662932.zip |
Fix crypt with a multithread protection lock, similar to the one in grp.py
Diffstat (limited to 'lib_pypy')
-rw-r--r-- | lib_pypy/crypt/__init__.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib_pypy/crypt/__init__.py b/lib_pypy/crypt/__init__.py index a5790e83ad..83e516011f 100644 --- a/lib_pypy/crypt/__init__.py +++ b/lib_pypy/crypt/__init__.py @@ -4,6 +4,12 @@ CFFI based implementation of the crypt module import sys import cffi +import thread +_lock = thread.allocate_lock() + +try: from __pypy__ import builtinify +except ImportError: builtinify = lambda f: f + ffi = cffi.FFI() ffi.cdef('char *crypt(char *word, char *salt);') @@ -14,8 +20,10 @@ except OSError: raise ImportError('crypt not available') +@builtinify def crypt(word, salt): - res = lib.crypt(word, salt) - if not res: - return None - return ffi.string(res) + with _lock: + res = lib.crypt(word, salt) + if not res: + return None + return ffi.string(res) |