Authen::Captcha + mod_perl = not random enough?

keithorama on 2005-09-27T18:36:45

Experienced an odd situation running Authen::Captcha with mod_perl. Authen::Captcha generates images containing a random sequence of letters, somewhat obfuscated to foil OCR. I ran into a problem running it under mod_perl, where rand() was being seeded at compile time (before Apache pre-forks all its children), and each perl interpreter had the same seed, and thus the same "random" sequences would be generated over and over. Authen::Captcha has some code that immediately deletes a captcha image that it thinks is a duplicate of one it already created, and thus I was getting 404s some of the time when I refreshed the page containing the captcha. The solution: call srand() once at runtime. Then all the interpreters have a different seed and the chance of a collision drops to near zero.


gotcha

Qiang on 2005-09-28T16:16:40

i don't use this module, but i think that is something should be mentioned in that module doc.

mod_perl issue...

Matts on 2005-09-28T16:28:18

I thought this was a solved problem in mod_perl - didn't we patch this years ago in the core?