initial commit of file from CVS for smeserver-sogo on Sat Sep 7 16:42:51 AEST 2024
This commit is contained in:
33
root/etc/e-smith/db/configuration/migrate/SOGoPassword
Normal file
33
root/etc/e-smith/db/configuration/migrate/SOGoPassword
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
my $sogodrec = $DB->get('sogod')
|
||||
|| $DB->new_record('sogod', {type => 'service'});
|
||||
my $sogod_pw = $sogodrec->prop('DbPassword');
|
||||
if (not $sogod_pw or length($sogod_pw) < 57)
|
||||
{
|
||||
use MIME::Base64 qw(encode_base64);
|
||||
|
||||
$sogod_pw = "not set due to error";
|
||||
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
|
||||
{
|
||||
$sogod_pw = encode_base64($buf);
|
||||
chomp $sogod_pw;
|
||||
$sogod_pw =~ s/\//\./g; # SOGo hates passwords with slashes
|
||||
}
|
||||
close RANDOM;
|
||||
}
|
||||
else
|
||||
{
|
||||
warn "Could not open /dev/urandom: $!";
|
||||
}
|
||||
$sogodrec->set_prop('DbPassword', $sogod_pw);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user