For those interested I wrote this simple little password generator in perl to take place of the RandomPassword java class which seems to take its sweet time on random occassions. The code in part is originally from
http://www.cgi-interactive-uk.com/ra...generator.html. I placed it in /opt/zimbra/bin and called it from zmsetup when needed. Works like a champ. There shouldn't be any problems with security. Although the password isn't truly random. Its pretty close though as the salt is never used twice, at least it shouldn't be since time is always increasing. On a side note, I have all services except tomcat running in gentoo. On a side, side note, if you ever do a cvs build use the default versions for third party apps... It’s a pain in the butt upgrading all the scripts for the new versions.
Ben
Code:
#!/usr/bin/perl -w
sub genRandomPass {
my $password;
my $_rand;
my $password_min = $_[0];
my $password_max = $_[1];
if (!$password_min) {
$password_min = 8;
}
if (!$password_max) {
$password_max = 10;
}
if ( $password_max <= $password_min ) {
print "Error: The password max length must be greater then the password min length\nUsage: zmpassgen <Max Length> <Min Length>";
exit 1;
}
$range = $password_max - $password_min;
srand(time() ^($$ + ($$ <<25)));
my $password_length = int(rand($range)) + $password_min;
my @chars = split(" ", "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z _ . 0 1 2 3 4 5 6 7 8 9");
srand(time() ^($$ + ($$ <<25)));
for (my $i=0; $i <= $password_length ;$i++) {
$_rand = int(rand 64);
$password .= $chars[$_rand];
}
return $password;
}
print genRandomPass($ARGV[0],$ARGV[1]);