]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 646578: Remove the usage of Math::Random::Secure, as it is too difficult
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Wed, 27 Apr 2011 22:03:41 +0000 (15:03 -0700)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Wed, 27 Apr 2011 22:03:41 +0000 (15:03 -0700)
to install on older branches.
r=LpSolit, a=mkanat

Bugzilla/Install/Requirements.pm
Bugzilla/Util.pm
mod_perl.pl

index 019661f0fa141f277c3d638e26e05629fbce62e8..586ace75023dd57dda9ebac449d4c93cc81a269b 100644 (file)
@@ -289,12 +289,6 @@ sub OPTIONAL_MODULES {
         version => '3.51',
         feature => 'Recommended important security fix'
     },
-    {
-        package => 'Math-Random-Secure',
-        module  => 'Math::Random::Secure',
-        version => '0.05',
-        feature => 'Improve cookie and token security',
-    },
     );
 
     my $all_modules = _get_extension_requirements(
index 552fd7f65d308b6555ab51a0d76a6a233aa4b9fb..c6b3abb31df283f663e7f418626feaeb1ecd04b5 100644 (file)
@@ -584,24 +584,16 @@ sub bz_crypt {
 # strength of the string in bits.
 sub generate_random_password {
     my $size = shift || 10; # default to 10 chars if nothing specified
-    my $rand;
-    if (eval { require Math::Random::Secure; 1; }) {
-        $rand = \&Math::Random::Secure::irand;
-    }
-    else {
-        # For details on why this block works the way it does, see bug 619594.
-        # (Note that we don't do this if Math::Random::Secure is installed,
-        # because we don't need to.)
-        my $counter = 0;
-        $rand = sub {
-            # If we regenerate the seed every 5 characters, our seed is roughly
-            # as strong (in terms of bit size) as our randomly-generated
-            # string itself.
-            _do_srand() if ($counter % 5) == 0;
-            $counter++;
-            return int(rand $_[0]);
-        };
-    }
+    my $counter = 0;
+    # For details on why this block works the way it does, see bug 619594.
+    my $rand = sub {
+        # If we regenerate the seed every 5 characters, our seed is roughly
+        # as strong (in terms of bit size) as our randomly-generated
+        # string itself.
+        _do_srand() if ($counter % 5) == 0;
+        $counter++;
+        return int(rand $_[0]);
+    };
     return join("", map{ ('0'..'9','a'..'z','A'..'Z')[$rand->(62)] } 
                        (1..$size));
 }
index f4192ec7f7b4bb76aa085aa6fd0d6001b3e43ca1..207430d6ebc75c4e35c2ab46a07bc06173f96fcb 100644 (file)
@@ -44,9 +44,6 @@ use Bugzilla::Mailer ();
 use Bugzilla::Template ();
 use Bugzilla::Util ();
 
-# For PerlChildInitHandler
-eval { require Math::Random::Secure };
-
 # This means that every httpd child will die after processing
 # a CGI if it is taking up more than 70MB of RAM all by itself.
 $Apache2::SizeLimit::MAX_UNSHARED_SIZE = 70000;
@@ -57,13 +54,7 @@ my $cgi_path = Bugzilla::Constants::bz_locations()->{'cgi_path'};
 my $server = Apache2::ServerUtil->server;
 my $conf = <<EOT;
 # Make sure each httpd child receives a different random seed (bug 476622).
-# Math::Random::Secure has one srand that needs to be called for
-# every process, and Perl has another. (Various Perl modules still use
-# the built-in rand(), even though we only use Math::Random::Secure in
-# Bugzilla itself, so we need to srand() both of them.) However, 
-# Math::Random::Secure may not be installed, so we call its srand in an
-# eval.
-PerlChildInitHandler "sub { eval { Math::Random::Secure::srand() }; srand(); }"
+PerlChildInitHandler "sub { srand(); }"
 <Directory "$cgi_path">
     AddHandler perl-script .cgi
     # No need to PerlModule these because they're already defined in mod_perl.pl