diff options
author | Andrew Bartlett <abartlet@samba.org> | 2003-05-11 02:26:53 +0000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2003-05-11 02:26:53 +0000 |
commit | 00583954447ec7af9dbbde183bba12a8711e61d0 (patch) | |
tree | 6a9c2c84ae9033aa30ba7060c8523969c4ef1c65 /source3/passdb | |
parent | 18f12f341f86f51a1729b19df2c0b86df8a6282d (diff) | |
download | samba-00583954447ec7af9dbbde183bba12a8711e61d0.tar.gz samba-00583954447ec7af9dbbde183bba12a8711e61d0.tar.xz samba-00583954447ec7af9dbbde183bba12a8711e61d0.zip |
Using /dev/urandom for determining an ldap server backoff is a waste of system
entropy - use sys_random() instead.
Andrew Bartlett
(This used to be commit 640462a365235aa7ce6f817778f022530a25d909)
Diffstat (limited to 'source3/passdb')
-rw-r--r-- | source3/passdb/pdb_ldap.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/source3/passdb/pdb_ldap.c b/source3/passdb/pdb_ldap.c index 6a609b36704..e9c6093e26a 100644 --- a/source3/passdb/pdb_ldap.c +++ b/source3/passdb/pdb_ldap.c @@ -519,9 +519,10 @@ static int ldapsam_retry_open(struct ldapsam_privates *ldap_state, int *attempts if (*attempts != 0) { unsigned int sleep_time; - uint8 rand_byte = 128; /* a reasonable place to start */ + uint8 rand_byte; - generate_random_buffer(&rand_byte, 1, False); + /* Sleep for a random timeout */ + rand_byte = (char)(sys_random()); sleep_time = (((*attempts)*(*attempts))/2)*rand_byte*2; /* we retry after (0.5, 1, 2, 3, 4.5, 6) seconds @@ -3157,6 +3158,9 @@ static NTSTATUS pdb_init_ldapsam(PDB_CONTEXT *pdb_context, PDB_METHODS **pdb_met (*pdb_method)->free_private_data = free_private_data; + /* setup random, for our backoffs */ + sys_srandom(sys_getpid() ^ time(NULL)); + return NT_STATUS_OK; } |