bpo-28503: _crypt: fix implicit declaration of crypt(), use crypt_r() if available.#4691
bpo-28503: _crypt: fix implicit declaration of crypt(), use crypt_r() if available.#4691EdSchouten wants to merge 1 commit into
Conversation
|
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
Sorry, something went wrong.
The '_crypt' module provides a binding to the C crypt(3) function. It is used by the crypt.crypt() function. Looking at the C code, there are a couple of things we can improve: - Because crypt() only depends on primitive C types, we currently get away with calling it without it being declared. Ensure that we include <unistd.h>, which is the POSIX header file declaring this. - The disadvantage of crypt() is that it's thread-unsafe. Systems like Linux and recent versions of FreeBSD nowadays provide crypt_r() as a replacement. This function allows you to pass in a 'crypt_data' object that will hold the resulting string for you. Extend the code to use this function when available. This patch is actually needed to make this module build on CloudABI (https://mail.python.org/pipermail/python-dev/2016-July/145708.html). CloudABI's C library doesn't provide any thread-unsafe functions, meaning that crypt_r() is the only way you can crypt passwords.
c23bc2b to
f8e4237
Compare
December 3, 2017 21:26
|
Any progress on this? It appears to be needed for the latest Fedora, where they switched to gcc 8.1. |
Sorry, something went wrong.
Are you sure? Undeclared functions are assumed a return type of This PR does fix that problem. |
Sorry, something went wrong.
|
Moreover, it's getting urgent, as there are plans to remove Building (on a 64-bit Linux) with Perhaps it makes sense to split this PR into two - one making |
Sorry, something went wrong.
|
Linking with |
Sorry, something went wrong.
|
#11373 is a modern version of this. I'm waiting on the CI over there before merging it, but rather than anyone spending time updating and addressing conflicts in this one I'm just going to close it. Our overall concepts are similar. I did the configure.ac check a bit differently to account for |
Sorry, something went wrong.
The '_crypt' module provides a binding to the C crypt(3) function. It is
used by the crypt.crypt() function.
Looking at the C code, there are a couple of things we can improve:
Because crypt() only depends on primitive C types, we currently get
away with calling it without it being declared. Ensure that we include
<unistd.h>, which is the POSIX header file declaring this.
The disadvantage of crypt() is that it's thread-unsafe. Systems like
Linux and recent versions of FreeBSD nowadays provide crypt_r() as a
replacement. This function allows you to pass in a 'crypt_data' object
that will hold the resulting string for you. Extend the code to use
this function when available.
This patch is actually needed to make this module build on CloudABI
(https://mail.python.org/pipermail/python-dev/2016-July/145708.html).
CloudABI's C library doesn't provide any thread-unsafe functions,
meaning that crypt_r() is the only way you can crypt passwords.
https://bugs.python.org/issue28503