Django

Code

Changeset 9159

Show
Ignore:
Timestamp:
10/05/08 23:56:50 (3 months ago)
Author:
mtredinnick
Message:

[1.0.X] Fixed #5753 -- Allow createsuperuser to work in situations where there
might be a valid password database entry for the current user id.

Backport of r9158 from trunk.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/releases/1.0.X/django/contrib/auth/management/commands/createsuperuser.py

    r8616 r9159  
    5858        try: 
    5959            import pwd 
    60         except ImportError: 
     60            default_username = pwd.getpwuid(os.getuid())[0].replace(' ', '').lower() 
     61        except (ImportError, KeyError): 
     62            # KeyError will be raised by getpwuid() if there is no 
     63            # corresponding entry in the /etc/passwd file (a very restricted 
     64            # chroot environment, for example). 
    6165            default_username = '' 
    62         else: 
    63             default_username = pwd.getpwuid(os.getuid())[0].replace(' ', '').lower() 
    6466 
    6567        # Determine whether the default username is taken, so we don't display