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 | |
parent | 18f12f341f86f51a1729b19df2c0b86df8a6282d (diff) | |
download | samba-00583954447ec7af9dbbde183bba12a8711e61d0.tar.gz samba-00583954447ec7af9dbbde183bba12a8711e61d0.tar.bz2 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)
-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 6a609b3670..e9c6093e26 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; } |