Skip to content

Commit

Permalink
Enable the '_crypt' module.
Browse files Browse the repository at this point in the history
As we now have a C library that provides crypt_r(), let's patch up
Python to make use of it. The existing '_crypt' module that provides the
native binding for crypt.crypt() still uses the thread-unsafe C library
function, so patch it up to make use of crypt_r().

We also need to patch up this module to properly include <unistd.h>. It
normally gets away with an implicit prototype, but because it needs to
make use of a 'struct crypt_data' now, it now needs the header
explicitly.

Still disable the call to crypt() when doing the bootstrap build, as on
most systems, crypt() is provided by an external libcrypt. This
contradicts POSIX, which requires that crypt() is part of the C library.
  • Loading branch information
EdSchouten committed Jul 24, 2016
1 parent c7059cd commit 84fb366
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
26 changes: 26 additions & 0 deletions packages/python/patch-crypt_r
@@ -0,0 +1,26 @@
--- Modules/_cryptmodule.c
+++ Modules/_cryptmodule.c
@@ -5,6 +5,8 @@

#include <sys/types.h>

+#include <unistd.h>
+
/* Module crypt */

/*[clinic input]
@@ -36,7 +38,13 @@
{
/* On some platforms (AtheOS) crypt returns NULL for an invalid
salt. Return None in that case. XXX Maybe raise an exception? */
- return Py_BuildValue("s", crypt(word, salt));
+#ifdef __CloudABI__
+ struct crypt_data data;
+ data.initialized = 0;
+ return Py_BuildValue("s", crypt_r(word, salt, &data));
+#else
+ return Py_BuildValue("s", "crypt() not available during bootstrap");
+#endif
}


9 changes: 9 additions & 0 deletions packages/python/patch-modules-setup_dist
Expand Up @@ -65,6 +65,15 @@

# Socket module helper for SSL support; you must comment out the other
# socket line above, and possibly edit the SSL variable:
@@ -214,7 +214,7 @@
#
# First, look at Setup.config; configure may have set this for you.

-#_crypt _cryptmodule.c # -lcrypt # crypt(3); needs -lcrypt on some systems
+_crypt _cryptmodule.c # -lcrypt # crypt(3); needs -lcrypt on some systems


# Some more UNIX dependent modules -- off by default, since these
@@ -222,9 +222,9 @@

#nis nismodule.c -lnsl # Sun yellow pages -- not everywhere
Expand Down
15 changes: 0 additions & 15 deletions packages/python/patch-no-crypt

This file was deleted.

0 comments on commit 84fb366

Please sign in to comment.