summaryrefslogtreecommitdiffstats
path: root/ipa-python/ipautil.py
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2008-01-22 16:42:45 +0000
committerMark McLoughlin <markmc@redhat.com>2008-01-22 16:42:45 +0000
commit996a3f669898e4fc764867c63d9da87aa3b35854 (patch)
treec80da4f13882fce1b10468afb55d77f66aa0ff07 /ipa-python/ipautil.py
parent11266d039f6c59be1bf8ce888972d012ce49ddf6 (diff)
downloadfreeipa-996a3f669898e4fc764867c63d9da87aa3b35854.tar.gz
freeipa-996a3f669898e4fc764867c63d9da87aa3b35854.tar.xz
freeipa-996a3f669898e4fc764867c63d9da87aa3b35854.zip
Fix not so random random passwords
If you run ipa_generate_password() multiple times, one after the other, then you get the same password each time. This is because it uses the current time to seed the pseudo random number generator. The easiest solution is to just use the default method which seeds itself from /dev/urandom if available, and uses a fractional time value otherwise. Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Diffstat (limited to 'ipa-python/ipautil.py')
-rw-r--r--ipa-python/ipautil.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/ipa-python/ipautil.py b/ipa-python/ipautil.py
index 32faabeab..ba12f3948 100644
--- a/ipa-python/ipautil.py
+++ b/ipa-python/ipautil.py
@@ -24,8 +24,7 @@ import string
import tempfile
import logging
import subprocess
-from random import Random
-from time import gmtime
+import random
import os, sys, traceback, readline
import stat
import shutil
@@ -364,8 +363,7 @@ def parse_generalized_time(timestr):
def ipa_generate_password():
rndpwd = ''
- r = Random()
- r.seed(gmtime())
+ r = random.Random()
for x in range(12):
# rndpwd += chr(r.randint(32,126))
rndpwd += chr(r.randint(65,90)) #stricter set for testing