diff -up smeserver-bugzilla-0.1/root/etc/e-smith/db/configuration/migrate/80bugzilla.strong-pwd smeserver-bugzilla-0.1/root/etc/e-smith/db/configuration/migrate/80bugzilla --- smeserver-bugzilla-0.1/root/etc/e-smith/db/configuration/migrate/80bugzilla.strong-pwd 2010-03-05 18:24:27.000000000 +0100 +++ smeserver-bugzilla-0.1/root/etc/e-smith/db/configuration/migrate/80bugzilla 2010-03-05 18:54:17.000000000 +0100 @@ -1,9 +1,9 @@ { use MIME::Base64 qw(encode_base64); - my $service; - my $rec; - my $pw; + my $service; + my $rec; + my $pw; # Enable InnoDB (needed for Bugzilla) $service = 'mysqld'; @@ -19,5 +19,27 @@ $pw = $rec->prop('DbPassword'); return "" if $pw; - $rec->set_prop('DbPassword', sprintf("%.15s", MIME::Base64::encode(int( (1000000000000000) * rand() )))); + if ( open( RANDOM, "/dev/urandom" ) ) + { + my $buf; + # 57 bytes is a full line of Base64 coding, and contains + # 456 bits of randomness - given a perfectly random /dev/random + if ( read( RANDOM, $buf, 57 ) != 57 ) + { + warn("Short read from /dev/random: $!"); + } + else + { + $pw = encode_base64($buf); + chomp $pw; + } + close RANDOM; + } + else + { + warn "Could not open /dev/urandom: $!"; + } + + $rec->set_prop('DbPassword', $pw); + }