Changeset 1042

Show
Ignore:
Timestamp:
07/19/06 20:12:16 (2 years ago)
Author:
mgood
Message:

AccountManagerPlugin:

merge r1041 to 0.9 branch

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • accountmanagerplugin/0.9/acct_mgr/htfile.py

    r963 r1042  
    2121 
    2222from api import IPasswordStore 
     23 
     24# check for the availability of the "crypt" module for checking passwords on 
     25# Unix-like platforms 
     26# MD5 is still used when adding/updating passwords 
     27try: 
     28    from crypt import crypt 
     29except ImportError: 
     30    def crypt(password, salt): 
     31        raise NotImplementedError('The "crypt" module is unavailable on this ' 
     32                                  'platform.  Only MD5 passwords (starting ' 
     33                                  'with "$apr1$") are supported in the ' 
     34                                  'htpasswd file.') 
    2335 
    2436# os.urandom was added in Python 2.4 
     
    123135 
    124136    def _check_userline(self, password, prefix, suffix): 
    125         if not suffix.startswith('$apr1$'): 
    126             return False 
    127         return suffix == md5crypt(password, suffix[6:].split('$')[0], '$apr1$') 
     137        if suffix.startswith('$apr1$'): 
     138            return suffix == md5crypt(password, suffix[6:].split('$')[0], 
     139                                      '$apr1$') 
     140        else: 
     141            # crypt passwords are only supported on Unix-like systems 
     142            # a dummy crypt implementation is provided above that throws 
     143            # a NotImplementedError if the crypt module is unavailable 
     144            return suffix == crypt(password, suffix[:2]) 
    128145 
    129146    def _get_users(self, filename):