735: NIS backend doesn't support MD5 passwords

Will.*****@gmai***** (Google Code) (Is this you? Claim this profile.)
April 21, 2009
What's the URL of the page containing the problem?
login page

What steps will reproduce the problem?
1. For a user with an MD5 password (instead of the more standard DES
password), try to login using the NIS backend
2.
3.

What is the expected output? What do you see instead?
The user should be able to login with a DES or MD5 password

What operating system are you using? What browser?
Running on Linux

Please provide any additional information below.
Here's a patch to accounts/backends.py that fixes the problem:

Index: backends.py
===================================================================
--- backends.py (revision 1571)
+++ backends.py (working copy)
@@ -15,7 +15,12 @@
         try:
             passwd = nis.match(username, 'passwd').split(':')
             original_crypted = passwd[1]
-            new_crypted = crypt.crypt(password, original_crypted[:2])
+            salt = original_crypted[:2]
+            if( original_crypted[0:3] == '$1$' ):
+                # Get MD5 salt
+                salt = '$1$' + original_crypted.split('$')[2]
+
+            new_crypted = crypt.crypt(password, salt)

             if original_crypted == new_crypted:
                 return self.get_or_create_user(username, passwd)
chipx86
#1 chipx86
Would you mind posting this to http://reviews.review-board.org/
  • +Confirmed
  • +Component-Accounts
#2 Will.*****@gmai***** (Google Code) (Is this you? Claim this profile.)
ok - posted.
chipx86
#3 chipx86
Pretty sure we committed this.
  • -Confirmed
    +Fixed
  • +Milestone-Release1.0