From: David Schmitt Date: Tue, 12 May 2015 14:01:55 +0000 (+0100) Subject: fqdn_rotate: reset srand seed correctly on old ruby versions X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=0dc0e0dbcf9574ed1515cf6cfe2800f06d8c1d0e;p=puppet-stdlib.git fqdn_rotate: reset srand seed correctly on old ruby versions Without this, the global seed is reseeded on every use of fqdn_rotate, which is a waste. Older rubies might even use a time-base seed which adversly impacts the quality of the RNG. --- diff --git a/lib/puppet/parser/functions/fqdn_rotate.rb b/lib/puppet/parser/functions/fqdn_rotate.rb index cf22d36..d9741a0 100644 --- a/lib/puppet/parser/functions/fqdn_rotate.rb +++ b/lib/puppet/parser/functions/fqdn_rotate.rb @@ -39,9 +39,9 @@ Rotates an array a random number of times based on a nodes fqdn. if defined?(Random) == 'constant' && Random.class == Class offset = Random.new(seed).rand(elements) else - srand(seed) + old_seed = srand(seed) offset = rand(elements) - srand() + srand(old_seed) end end offset.times {