Changeset 1063

Show
Ignore:
Timestamp:
07/26/06 16:25:51 (2 years ago)
Author:
mgood
Message:

AccountManagerPlugin:

add a friendly error message when the Trac user is missing permissions to update the password file (fixes #537)

Files:

Legend:

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

    r1046 r1063  
    1313 
    1414from binascii import hexlify 
     15import errno 
    1516import md5 
    1617import os.path 
     
    9495        filename = self._get_filename() 
    9596        matched = False 
    96         if os.path.exists(filename)
     97        try
    9798            for line in fileinput.input(filename, inplace=True): 
    9899                if line.startswith(prefix): 
     
    102103                else: 
    103104                    print line, 
     105        except EnvironmentError, e: 
     106            if e.errno == errno.ENOENT: 
     107                pass # ignore when file doesn't exist and create it below 
     108            elif e.errno == errno.EACCES: 
     109                raise TracError('The password file could not be updated.  ' 
     110                                'Trac requires read and write access to both ' 
     111                                'the password file and its parent directory.') 
     112            else: 
     113                raise 
    104114        if not matched and userline: 
    105115            f = open(filename, 'a') 
  • accountmanagerplugin/trunk/acct_mgr/htfile.py

    r1048 r1063  
    1313 
    1414from binascii import hexlify 
     15import errno 
    1516import md5 
    1617import os.path 
     
    9596        filename = self.filename 
    9697        matched = False 
    97         if os.path.exists(filename)
     98        try
    9899            for line in fileinput.input(str(filename), inplace=True): 
    99100                if line.startswith(prefix): 
     
    103104                else: 
    104105                    print line, 
     106        except EnvironmentError, e: 
     107            if e.errno == errno.ENOENT: 
     108                pass # ignore when file doesn't exist and create it below 
     109            elif e.errno == errno.EACCES: 
     110                raise TracError('The password file could not be updated.  ' 
     111                                'Trac requires read and write access to both ' 
     112                                'the password file and its parent directory.') 
     113            else: 
     114                raise 
    105115        if not matched and userline: 
    106116            f = open(filename, 'a')