#5753 closed (fixed)
manage syncdb (first time) in a small chrooted environment for example don't give defaultuser...
Reported by: | ClaesBas | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | dev |
Severity: | Keywords: | syncdb superuser | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
What a about this patch?
Index: django/contrib/auth/create_superuser.py =================================================================== --- django/contrib/auth/create_superuser.py (revision 6507) +++ django/contrib/auth/create_superuser.py (working copy) @@ -22,7 +22,10 @@ default_username = '' else: # Determine the current system user's username, to use as a default. - default_username = pwd.getpwuid(os.getuid())[0].replace(' ', '').lower() + try: + default_username = pwd.getpwuid(os.getuid())[0].replace(' ', '').lower() + except KeyError: + default_username = 'admin' # Determine whether the default username is taken, so we don't display # it as an option.
Change History (4)
comment:1 by , 17 years ago
Has patch: | unset |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
comment:3 by , 16 years ago
comment:4 by , 16 years ago
Since there are situations where normal usage or Django (using "createsuperuser") could lead to a crash before this change, I decided to also commit it on the branch. If it causes any trouble, though, we could safely remove it from there. It's pretty borderline, as indicated in my first comment on this ticket.
Note:
See TracTickets
for help on using tickets.
[For other readers wondering what this is about: if you have a really minimal environ with no auth support, then getuid() may fail to return a username. This usually means you need at least /etc/passwd.]
I would think there's going to be a fair bit of stuff that will cause problems if there's no /etc/passwd or other way for things like getuid() to work, so you're not really solving the root problem here. Still, it's probably a relatively harmless fix, but it needs a comment about why it can fail.
I'd probably prefer that we just didn't display a default username in this case, too, if we go down this path.
In future, please give an explanation of what you're trying to fix. I've had enough experience with setting up chroot environments to recognise the problem, but not everybody is going to have been that unlucky in the past and you really are talking about a far-out edge case here.