Skip to content

closes bpo-44751: Move crypt.h include from public header to _cryptmodule #27394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions Include/Python.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@
#ifndef MS_WINDOWS
#include <unistd.h>
#endif
#ifdef HAVE_CRYPT_H
#if defined(HAVE_CRYPT_R) && !defined(_GNU_SOURCE)
/* Required for glibc to expose the crypt_r() function prototype. */
# define _GNU_SOURCE
# define _Py_GNU_SOURCE_FOR_CRYPT
#endif
#include <crypt.h>
#ifdef _Py_GNU_SOURCE_FOR_CRYPT
/* Don't leak the _GNU_SOURCE define to other headers. */
# undef _GNU_SOURCE
# undef _Py_GNU_SOURCE_FOR_CRYPT
#endif
#endif

/* For size_t? */
#ifdef HAVE_STDDEF_H
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove ``crypt.h`` include from the public ``Python.h`` header.
3 changes: 3 additions & 0 deletions Modules/_cryptmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#include "Python.h"

#include <sys/types.h>
#ifdef HAVE_CRYPT_H
#include <crypt.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to #define _GNU_SOURCE here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think no because it's defined by pyconfig.h which is included by Python.h. I'm going to try a build on my Linux box to confirm.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I compiled Python 3.7 on my Debian 9 box with this patch (because that was easiest), and crypt.crypt() works without segfaulting and links crypt_r and there are no warnings in the build log. From inspection, pyconfig.h does define _GNU_SOURCE and does get pulled in by Python.h.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, great.

#endif

/* Module crypt */

Expand Down