summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2008-08-07 09:21:32 -0400
committerSimo Sorce <ssorce@redhat.com>2008-08-11 18:30:40 -0400
commit599fe1a0f5c046da6f99448ac43599b2681069d5 (patch)
treec94fdad3fe848ad77b01401940e43410340c0a52
parent1b613fafa6f6e52bc888fcccdd25c7f607967959 (diff)
downloadfreeipa.git-599fe1a0f5c046da6f99448ac43599b2681069d5.tar.gz
freeipa.git-599fe1a0f5c046da6f99448ac43599b2681069d5.tar.xz
freeipa.git-599fe1a0f5c046da6f99448ac43599b2681069d5.zip
Use larger set from which to choose chars for random passwords.
Use SystemRandom() instead of Random() so that the randomicity is non-deterministic.
-rw-r--r--ipa-python/ipautil.py5
-rw-r--r--ipa-server/ipa-gui/ipagui/subcontrollers/user.py3
2 files changed, 3 insertions, 5 deletions
diff --git a/ipa-python/ipautil.py b/ipa-python/ipautil.py
index f3018ed0..117171c4 100644
--- a/ipa-python/ipautil.py
+++ b/ipa-python/ipautil.py
@@ -365,10 +365,9 @@ def parse_generalized_time(timestr):
def ipa_generate_password():
rndpwd = ''
- r = random.Random()
+ r = random.SystemRandom()
for x in range(12):
-# rndpwd += chr(r.randint(32,126))
- rndpwd += chr(r.randint(65,90)) #stricter set for testing
+ rndpwd += chr(r.randint(32,126))
return rndpwd
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/user.py b/ipa-server/ipa-gui/ipagui/subcontrollers/user.py
index 734d867f..d8fabb6b 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/user.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/user.py
@@ -744,8 +744,7 @@ class UserController(IPAController):
password = ""
generator = random.SystemRandom()
for char in range(8):
- index = generator.randint(0, len(password_chars) - 1)
- password += password_chars[index]
+ password += generator.choice(password_chars)
return password