This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: function crypt not working on OSX
Type: behavior Stage: resolved
Components: macOS Versions: Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: ronaldoussoren Nosy List: geoffreyspear, lunokhod, r.david.murray, ronaldoussoren
Priority: normal Keywords:

Created on 2014-09-17 14:11 by lunokhod, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (4)
msg227002 - (view) Author: Mark Wieczorek (lunokhod) Date: 2014-09-17 14:11
Hi, 

I just wanted to let you know of a bug that is related to the function "crypt" in osx (10.9.4). I have tried the default osx version of python (2.75), the brew version (2.7.8), and the macports version (2.7.7).

In short, the command

python -c 'import crypt; print crypt.crypt("test12345", "$6$salt")'

produces the output : $6n8sgZJBMh4U

The correct output should be 

$6$salt$omHbK1V1Alwa0VKXqLaW38vdS1uUhfx8GTj7XXCJcNUJxABwmYe8Vhpyt2tnnaAFC6UTI7PNk9sTtSGWGnYop.

I have no idea what the problem is.
msg227003 - (view) Author: Geoffrey Spear (geoffreyspear) * Date: 2014-09-17 14:23
The same behavior exists in Python 3, however, I'm not sure it's a bug. The documentation says "The characters in salt must be in the set [./a-zA-Z0-9]." Presumably the behavior when there is a $ in the salt is undefined by Python, and different on different platforms.
msg227004 - (view) Author: Mark Wieczorek (lunokhod) Date: 2014-09-17 14:25
It actually doesn't even matter what you use for salt. If you change "salt", you get the same hash. That is bug #2 !
msg227005 - (view) Author: Geoffrey Spear (geoffreyspear) * Date: 2014-09-17 14:41
This is actually the expected behavior of crypt(3) on OS X. It doesn't support the $id$ modular format, and if the salt does not begin with an underscore only the first 2 bytes are used (presumably in your "bug #2" you're changing parts of the salt beyond the first 2 bytes.)

Python's behavior differing based on the underlying C library on the system is documented; this is neither a bug in Python or in OS X crypt (although it could be argued that OS X crypt is kind of useless and insecure...)
History
Date User Action Args
2022-04-11 14:58:08adminsetgithub: 66622
2014-09-17 15:01:07r.david.murraysetstatus: open -> closed
nosy: + r.david.murray

resolution: not a bug
stage: resolved
2014-09-17 14:41:01geoffreyspearsetmessages: + msg227005
2014-09-17 14:25:56lunokhodsetmessages: + msg227004
2014-09-17 14:23:10geoffreyspearsetnosy: + geoffreyspear
messages: + msg227003
2014-09-17 14:11:23lunokhodcreate