line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Kolab::LDAP::Backend; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
## |
4
|
|
|
|
|
|
|
## Copyright (c) 2003 Code Fusion cc |
5
|
|
|
|
|
|
|
## |
6
|
|
|
|
|
|
|
## Writen by Stuart Bingė |
7
|
|
|
|
|
|
|
## |
8
|
|
|
|
|
|
|
## This program is free software; you can redistribute it and/or |
9
|
|
|
|
|
|
|
## modify it under the terms of the GNU General Public License as |
10
|
|
|
|
|
|
|
## published by the Free Software Foundation; either version 2, or |
11
|
|
|
|
|
|
|
## (at your option) any later version. |
12
|
|
|
|
|
|
|
## |
13
|
|
|
|
|
|
|
## This program is distributed in the hope that it will be useful, |
14
|
|
|
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16
|
|
|
|
|
|
|
## General Public License for more details. |
17
|
|
|
|
|
|
|
## |
18
|
|
|
|
|
|
|
## You can view the GNU General Public License, online, at the GNU |
19
|
|
|
|
|
|
|
## Project's homepage; see . |
20
|
|
|
|
|
|
|
## |
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
51016
|
use 5.008; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
23
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
24
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
53
|
|
|
1
|
|
|
|
|
39
|
|
25
|
1
|
|
|
1
|
|
418
|
use Kolab; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use Kolab::Util; |
27
|
|
|
|
|
|
|
use vars qw( |
28
|
|
|
|
|
|
|
%startup |
29
|
|
|
|
|
|
|
%run |
30
|
|
|
|
|
|
|
%backends |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
require Exporter; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
38
|
|
|
|
|
|
|
'all' => [ qw( |
39
|
|
|
|
|
|
|
&load |
40
|
|
|
|
|
|
|
&startup |
41
|
|
|
|
|
|
|
&run |
42
|
|
|
|
|
|
|
%backends |
43
|
|
|
|
|
|
|
) ] |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
our @EXPORT = qw( |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
our $VERSION = sprintf('%d.%02d', q$Revision: 1.1.1.1 $ =~ /(\d+)\.(\d+)/); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub load |
55
|
|
|
|
|
|
|
{ |
56
|
|
|
|
|
|
|
my $p = shift || ''; |
57
|
|
|
|
|
|
|
my $non_directory = shift; |
58
|
|
|
|
|
|
|
my $backend; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
if (!defined $non_directory) { |
61
|
|
|
|
|
|
|
$p .= '_' if ($p); |
62
|
|
|
|
|
|
|
$backend = $Kolab::config{$p . 'directory_mode'}; |
63
|
|
|
|
|
|
|
} else { |
64
|
|
|
|
|
|
|
$backend = $p; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
return if (exists($backends{$backend})); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Kolab::log('B', "Loading backend `$backend'"); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
unless (eval "require Kolab::LDAP::Backend::$backend") { |
71
|
|
|
|
|
|
|
Kolab::log('B', "Backend `$backend' does not exist, exiting", KOLAB_ERROR); |
72
|
|
|
|
|
|
|
exit(1); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$startup{$backend} = \&{'Kolab::LDAP::Backend::' . $backend . '::startup'}; |
76
|
|
|
|
|
|
|
$run{$backend} = \&{'Kolab::LDAP::Backend::' . $backend . '::run'}; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$backends{$backend} = 1; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# shutdown is handled per-module, using signals |
82
|
|
|
|
|
|
|
sub startup |
83
|
|
|
|
|
|
|
{ |
84
|
|
|
|
|
|
|
foreach my $backend (keys %backends) { |
85
|
|
|
|
|
|
|
my $func = $startup{$backend}; |
86
|
|
|
|
|
|
|
unless (eval '&$func') { |
87
|
|
|
|
|
|
|
$func = 'Kolab::LDAP::Backend::' . $backend . '::startup'; |
88
|
|
|
|
|
|
|
Kolab::log('B', "Function `$func' does not exist, exiting", KOLAB_ERROR); |
89
|
|
|
|
|
|
|
exit(1); |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub run |
95
|
|
|
|
|
|
|
{ |
96
|
|
|
|
|
|
|
my $backend = shift || 1; |
97
|
|
|
|
|
|
|
return if (!exists($run{$backend})); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my $func = $run{$backend}; |
100
|
|
|
|
|
|
|
unless (eval '&$func') { |
101
|
|
|
|
|
|
|
$func = 'Kolab::LDAP::Backend::' . $backend . '::run'; |
102
|
|
|
|
|
|
|
Kolab::log('B', "Function `$func' does not exist, exiting", KOLAB_ERROR); |
103
|
|
|
|
|
|
|
exit(1); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |
108
|
|
|
|
|
|
|
__END__ |