summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-10-06 04:56:50 +0000
committerMalcolm Tredinnick <malcolm.tredinnick@gmail.com>2008-10-06 04:56:50 +0000
commitc201d14269204a95c1f95299490430b2d8206341 (patch)
treebb93dbcf1bd4e72e4bd39e5793d7e0a0c5ec2866
parent48f4388c8bbd072db1e7949c7b954ca9ce989f77 (diff)
[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. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9159 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/contrib/auth/management/commands/createsuperuser.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/django/contrib/auth/management/commands/createsuperuser.py b/django/contrib/auth/management/commands/createsuperuser.py
index aaedcab0f4..32d845daef 100644
--- a/django/contrib/auth/management/commands/createsuperuser.py
+++ b/django/contrib/auth/management/commands/createsuperuser.py
@@ -57,10 +57,12 @@ class Command(BaseCommand):
# Try to determine the current system user's username to use as a default.
try:
import pwd
- except ImportError:
- default_username = ''
- else:
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
# it as an option.