From 599fe1a0f5c046da6f99448ac43599b2681069d5 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 7 Aug 2008 09:21:32 -0400 Subject: [PATCH] Use larger set from which to choose chars for random passwords. Use SystemRandom() instead of Random() so that the randomicity is non-deterministic. --- ipa-python/ipautil.py | 5 ++--- ipa-server/ipa-gui/ipagui/subcontrollers/user.py | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/ipa-python/ipautil.py b/ipa-python/ipautil.py index f3018ed09..117171c4c 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 734d867fb..d8fabb6b5 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