mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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>
This commit is contained in:
parent
11266d039f
commit
996a3f6698
@ -24,8 +24,7 @@ import string
|
|||||||
import tempfile
|
import tempfile
|
||||||
import logging
|
import logging
|
||||||
import subprocess
|
import subprocess
|
||||||
from random import Random
|
import random
|
||||||
from time import gmtime
|
|
||||||
import os, sys, traceback, readline
|
import os, sys, traceback, readline
|
||||||
import stat
|
import stat
|
||||||
import shutil
|
import shutil
|
||||||
@ -364,8 +363,7 @@ def parse_generalized_time(timestr):
|
|||||||
|
|
||||||
def ipa_generate_password():
|
def ipa_generate_password():
|
||||||
rndpwd = ''
|
rndpwd = ''
|
||||||
r = Random()
|
r = random.Random()
|
||||||
r.seed(gmtime())
|
|
||||||
for x in range(12):
|
for x in range(12):
|
||||||
# rndpwd += chr(r.randint(32,126))
|
# rndpwd += chr(r.randint(32,126))
|
||||||
rndpwd += chr(r.randint(65,90)) #stricter set for testing
|
rndpwd += chr(r.randint(65,90)) #stricter set for testing
|
||||||
|
Loading…
Reference in New Issue
Block a user