Skip to content

Commit

Permalink
Fixed #5753 -- Allow createsuperuser to work in situations where there
Browse files Browse the repository at this point in the history
might be a valid password database entry for the current user id.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@9158 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
malcolmt committed Oct 6, 2008
1 parent e2b02ea commit c58c1f4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions django/contrib/auth/management/commands/createsuperuser.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ def handle(self, *args, **options):
# Try to determine the current system user's username to use as a default. # Try to determine the current system user's username to use as a default.
try: try:
import pwd import pwd
except ImportError:
default_username = ''
else:
default_username = pwd.getpwuid(os.getuid())[0].replace(' ', '').lower() default_username = pwd.getpwuid(os.getuid())[0].replace(' ', '').lower()
except (ImportError, KeyError):
# KeyError will be raised by getpwuid() if there is no
# corresponding entry in the /etc/passwd file (a very restricted
# chroot environment, for example).
default_username = ''


# Determine whether the default username is taken, so we don't display # Determine whether the default username is taken, so we don't display
# it as an option. # it as an option.
Expand Down

0 comments on commit c58c1f4

Please sign in to comment.