summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorThomas Arendsen Hein <thomas@intevation.de>2009-03-16 17:17:35 (GMT)
committerThomas Arendsen Hein <thomas@intevation.de>2009-03-16 17:17:35 (GMT)
commit0af8aa6851634d07afd6e30083f805fd493a46b4 (patch)
tree01fe3f8e92797e0b980476627e57613b05f0ae1d /lib
parent65bb9c810ab8639624e9f5b9e880fa7d4e19c53c (diff)
downloadperl-Kolab-0af8aa6851634d07afd6e30083f805fd493a46b4.tar.gz
Select random imap partition when creating new user mailboxes.
The behavior can be modified by setting a different imappartitions_script in kolab.conf or disabled by setting imappartitions_script to an empty value.
Diffstat (limited to 'lib')
-rw-r--r--lib/Kolab/Cyrus.pm7
-rw-r--r--lib/Kolab/LDAP.pm13
2 files changed, 16 insertions, 4 deletions
diff --git a/lib/Kolab/Cyrus.pm b/lib/Kolab/Cyrus.pm
index 339f85c..647ba98 100644
--- a/lib/Kolab/Cyrus.pm
+++ b/lib/Kolab/Cyrus.pm
@@ -96,12 +96,13 @@ sub createMailbox
my $cyrus = shift;
my $uid = shift;
my $sf = shift || 0;
- my $cyruid = &createUid($uid, $sf);
+ my $partition = shift || '';
+ my $cyruid = &createUid($uid, $sf);
my $mailbox = ($cyrus->list($cyruid))[0];
if ($uid && ($uid ne $Kolab::config{'cyrus_admin'}) && ($uid ne "freebusy") && ($uid ne "nobody") && !defined($mailbox)) {
- Kolab::log('Y', "Creating mailbox `$cyruid'");
- if (!$cyrus->create($cyruid)) {
+ Kolab::log('Y', "Creating mailbox `$cyruid' on ".($partition?"partition `$partition'":"default partition"));
+ if (!$cyrus->create($cyruid, $partition)) {
Kolab::log('Y', "Unable to create mailbox `$cyruid', Error = `" . $cyrus->error . "'", KOLAB_WARN);
}
} else {
diff --git a/lib/Kolab/LDAP.pm b/lib/Kolab/LDAP.pm
index dec3467..531b3d9 100644
--- a/lib/Kolab/LDAP.pm
+++ b/lib/Kolab/LDAP.pm
@@ -525,9 +525,20 @@ sub createObject
if ($sync) { $newuid_db{$guid} = $oldgyarduid; } else { uidcacheStore($guid, $oldgyarduid); }
} else {
Kolab::log('L', "Creating user `$uid' corresponding to GUID `$guid'", KOLAB_DEBUG);
+ my $partition = '';
+ my $imappartitions_script = $Kolab::config{'imappartitions_script'};
+ if ($imappartitions_script) {
+ my @partitions;
+ if (@partitions = `$imappartitions_script`) {
+ $partition = $partitions[rand($#partitions + 1)];
+ chomp $partition;
+ } else {
+ Kolab::log('L', "Unable to run imappartitions_script `$imappartitions_script': $!", KOLAB_ERROR);
+ }
+ }
# We have a object that we have no previous record of, so create everything
if ($sync) { $newuid_db{$guid} = $uid; } else { uidcacheStore($guid, $uid); }
- Kolab::Cyrus::createMailbox($cyrus, $uid, ($p eq 'sf' ? 1 : 0));
+ Kolab::Cyrus::createMailbox($cyrus, $uid, ($p eq 'sf' ? 1 : 0), $partition);
if( $p eq 'sf' ){
my $foldertype = lc($object->get_value('kolabfoldertype'));