In my opinion fiddling with srand is security-wise a critical issue, as it affects the complete loaded code of an interpreter. Furthermore, the current fiddling with the global seed already introduced security issues when others (puppet plugin writers) relayed on srand() being non-deterministic, as it would be normally if you call it in your MRI code.

In case you haven't yet realized it: If you call currently fqdn_rand() *once* any other calls to rand() (by any puppet plugin) becomes very, very deterministic.

Ruby >= 1.9.2 provides a way to fix that cleanly without affecting anything globally. So this is the safest and hence (as messing around with the global seed is always bad thing!) the best solution, with which we will also never again have any problems, like the current one.

Unfortunately, older rubies do not have such a comfortable way and hence we need to find a solution within the boundaries of an old MRI, that still does not have any affect of any other consumers of rand(). Resetting the global seed() is still not cool, but the best we can do on Ruby < 1.9.2.

As it is a security related code path, I would argue to always choose the best solution available. And this is what this code does.

Additionally, the extra code path is really small and isolated within one method, there are tests for both solutions and whatnot.