summaryrefslogtreecommitdiff
path: root/lib/Kolab/LDAP/Backend/fds.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Kolab/LDAP/Backend/fds.pm')
-rw-r--r--lib/Kolab/LDAP/Backend/fds.pm191
1 files changed, 97 insertions, 94 deletions
diff --git a/lib/Kolab/LDAP/Backend/fds.pm b/lib/Kolab/LDAP/Backend/fds.pm
index 1c5b68a..16044d7 100644
--- a/lib/Kolab/LDAP/Backend/fds.pm
+++ b/lib/Kolab/LDAP/Backend/fds.pm
@@ -35,15 +35,15 @@ our @ISA = qw(Exporter);
our %EXPORT_TAGS = (
'all' => [ qw(
- &startup
- &run
+ &startup
+ &run
) ]
);
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw(
-
+
);
our $VERSION = '0.1';
@@ -73,36 +73,36 @@ sub changeCallback
my $entry = shift || 0;
my $issearch = $mesg->isa("Net::LDAP::Search");
-
+
Kolab::log('FDS', "issearch=" . $issearch , KOLAB_DEBUG);
if (!$issearch) {
- Kolab::log('FDS', 'mesg is not a search object, testing code...', KOLAB_DEBUG);
- if ($mesg->code == 88) {
- Kolab::log('FDS', 'changeCallback() -> Exit code received, returning', KOLAB_DEBUG);
- return;
- } elsif ($mesg->code) {
- Kolab::log('FDS', "mesg->code = `" . $mesg->code . "', mesg->msg = `" . $mesg->error . "'", KOLAB_DEBUG);
- &abort;
- }
+ Kolab::log('FDS', 'mesg is not a search object, testing code...', KOLAB_DEBUG);
+ if ($mesg->code == 88) {
+ Kolab::log('FDS', 'changeCallback() -> Exit code received, returning', KOLAB_DEBUG);
+ return;
+ } elsif ($mesg->code) {
+ Kolab::log('FDS', "mesg->code = `" . $mesg->code . "', mesg->msg = `" . $mesg->error . "'", KOLAB_DEBUG);
+ &abort;
+ }
} else {
- Kolab::log('FDS', 'mesg is a search object, not testing code', KOLAB_DEBUG);
+ Kolab::log('FDS', 'mesg is a search object, not testing code', KOLAB_DEBUG);
}
Kolab::log('FDS', "entry=" . $entry , KOLAB_DEBUG);
-
+
if (!$entry) {
- Kolab::log('FDS', 'changeCallback() called with a null entry', KOLAB_DEBUG);
- goto FOO;
- return;
+ Kolab::log('FDS', 'changeCallback() called with a null entry', KOLAB_DEBUG);
+ goto FOO;
+ return;
} elsif (!$entry->isa("Net::LDAP::Entry")) {
- Kolab::log('FDS', 'changeCallback() called with an invalid entry', KOLAB_DEBUG);
- return;
+ Kolab::log('FDS', 'changeCallback() called with an invalid entry', KOLAB_DEBUG);
+ return;
}
if (!Kolab::LDAP::isObject($entry, $Kolab::config{'user_object_class'}) &&
!Kolab::LDAP::isObject($entry, 'kolab')) {
- Kolab::log('FDS', "Entry is not a `" . $Kolab::config{'user_object_class'} . "' or kolab configuration object, returning", KOLAB_DEBUG);
- return;
+ Kolab::log('FDS', "Entry is not a `" . $Kolab::config{'user_object_class'} . "' or kolab configuration object, returning", KOLAB_DEBUG);
+ return;
}
FOO:
@@ -122,99 +122,102 @@ FOO:
}
sub run {
- # This should be called from a separate thread, as we set our
- # own interrupt handlers here
+ # This should be called from a separate thread, as we set our
+ # own interrupt handlers here
- $SIG{'INT'} = \&shutdown;
- $SIG{'TERM'} = \&shutdown;
+ $SIG{'INT'} = \&shutdown;
+ $SIG{'TERM'} = \&shutdown;
- END {
- alarm 0;
- Kolab::LDAP::destroy($ldap);
- }
+ END {
+ alarm 0;
+ Kolab::LDAP::destroy($ldap);
+ }
- my $mesg;
+ my $mesg;
- Kolab::log('FDS', 'Listener starting up');
+ Kolab::log('FDS', 'Listener starting up');
- $cyrus = Kolab::Cyrus::create;
+ $cyrus = Kolab::Cyrus::create;
- Kolab::log('FDS', 'Cyrus connection established', KOLAB_DEBUG);
+ Kolab::log('FDS', 'Cyrus connection established', KOLAB_DEBUG);
- while (1) {
- Kolab::log('FDS', 'Creating LDAP connection to FDS server', KOLAB_DEBUG);
+ while (1) {
+ Kolab::log('FDS', 'Creating LDAP connection to FDS server', KOLAB_DEBUG);
- $ldap = Kolab::LDAP::create($Kolab::config{'user_ldap_ip'},
- $Kolab::config{'user_ldap_port'},
- $Kolab::config{'user_bind_dn'},
- $Kolab::config{'user_bind_pw'},
- 1
- );
- if (!$ldap) {
- Kolab::log('FDS', 'Sleeping 5 seconds...');
- sleep 5;
- next;
- }
+ $ldap = Kolab::LDAP::create(
+ $Kolab::config{'user_ldap_ip'},
+ $Kolab::config{'user_ldap_port'},
+ $Kolab::config{'user_bind_dn'},
+ $Kolab::config{'user_bind_pw'},
+ 1
+ );
- Kolab::log('FDS', 'LDAP connection established', KOLAB_DEBUG);
+ if (!$ldap) {
+ Kolab::log('FDS', 'Sleeping 5 seconds...');
+ sleep 5;
+ next;
+ }
- Kolab::LDAP::ensureAsync($ldap);
+ Kolab::log('FDS', 'LDAP connection established', KOLAB_DEBUG);
- Kolab::log('FDS', 'Async checked', KOLAB_DEBUG);
+ Kolab::LDAP::ensureAsync($ldap);
- my $ctrl = Net::LDAP::Control->new(
- # type => '1.2.840.113556.1.4.528',
- type => '2.16.840.1.113730.3.4.3',
- critical => 'true'
- );
+ Kolab::log('FDS', 'Async checked', KOLAB_DEBUG);
- Kolab::log('FDS', 'Control created', KOLAB_DEBUG);
+ my $ctrl = Net::LDAP::Control->new(
+# type => '1.2.840.113556.1.4.528',
+ type => '2.16.840.1.113730.3.4.3',
+ critical => 'true'
+ );
- my @userdns = split(/;/, $Kolab::config{'user_dn_list'});
- my $userdn;
+ Kolab::log('FDS', 'Control created', KOLAB_DEBUG);
- Kolab::log('FDS', 'User DN list = ' . $Kolab::config{'user_dn_list'}, KOLAB_DEBUG);
+ my @userdns = split(/;/, $Kolab::config{'user_dn_list'});
+ my $userdn;
- if (length(@userdns) == 0) {
- Kolab::log('FDS', 'No user DNs specified, exiting', KOLAB_ERROR);
- exit(1);
- }
+ Kolab::log('FDS', 'User DN list = ' . $Kolab::config{'user_dn_list'}, KOLAB_DEBUG);
- foreach $userdn (@userdns) {
- Kolab::log('FDS', "Registering change notification on DN `$userdn'");
-
- $mesg = $ldap->search (base => $userdn,
- scope => 'one',
- control => [ $ctrl ],
- callback => \&changeCallback,
- filter => '(objectClass=*)',
- attrs => [ '*',
- $Kolab::config{'user_field_guid'},
- $Kolab::config{'user_field_modified'},
- $Kolab::config{'user_field_quota'},
- $Kolab::config{'user_field_deleted'},
- ],
- );
-
-# $status = ldap_create_persistentsearch_control($ld,$changetypes,$changesonly,$return_echg_ctrls,$ctrl_iscritical,$ctrlp);
-
- Kolab::log('FDS', "Change notification registered on `$userdn'");
- }
+ if (length(@userdns) == 0) {
+ Kolab::log('FDS', 'No user DNs specified, exiting', KOLAB_ERROR);
+ exit(1);
+ }
- eval {
- local $SIG{ALRM} = sub {
- alarm 0;
- Kolab::log('FDS', 'Connection refresh period expired; tearing down connection');
+ foreach $userdn (@userdns) {
+ Kolab::log('FDS', "Registering change notification on DN `$userdn'");
- Kolab::LDAP::destroy($ldap);
- next;
- };
+ $mesg = $ldap->search (
+ base => $userdn,
+ scope => 'one',
+ control => [ $ctrl ],
+ callback => \&changeCallback,
+ filter => '(objectClass=*)',
+ attrs => [ '*',
+ $Kolab::config{'user_field_guid'},
+ $Kolab::config{'user_field_modified'},
+ $Kolab::config{'user_field_quota'},
+ $Kolab::config{'user_field_deleted'},
+ ],
+ );
- Kolab::log('FDS', 'Waiting for changes (refresh period = ' . $Kolab::config{'conn_refresh_period'} . ' minutes)...');
- alarm $Kolab::config{'conn_refresh_period'} * 60;
- $mesg->sync;
- alarm 0;
- };
+# $status = ldap_create_persistentsearch_control($ld,$changetypes,$changesonly,$return_echg_ctrls,$ctrl_iscritical,$ctrlp);
+
+ Kolab::log('FDS', "Change notification registered on `$userdn'");
+ }
+
+ eval {
+ local $SIG{ALRM} = sub {
+ alarm 0;
+ Kolab::log('FDS', 'Connection refresh period expired; tearing down connection');
+
+ Kolab::LDAP::destroy($ldap);
+ next;
+ };
+
+ Kolab::log('FDS', 'Waiting for changes (refresh period = ' . $Kolab::config{'conn_refresh_period'} . ' minutes)...');
+ alarm $Kolab::config{'conn_refresh_period'} * 60;
+ $mesg->sync;
+ alarm 0;
+ };
}
1;