line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sys::Dev::LDAP::Populate; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
23000
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
915
|
use Net::LDAP::AutoDNs; |
|
1
|
|
|
|
|
3894
|
|
|
1
|
|
|
|
|
36
|
|
6
|
1
|
|
|
1
|
|
898
|
use Net::LDAP::AutoServer; |
|
1
|
|
|
|
|
263917
|
|
|
1
|
|
|
|
|
812
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Sys::Dev::LDAP::Populate - Populates various parts of /dev/ldap. |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.1.1 |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.1.1'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use Sys::Dev::LDAP::Populate; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my $foo = Sys::Dev::LDAP::Populate->new(); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$foo->populate |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
if($foo->{error}){ |
30
|
|
|
|
|
|
|
print "Error!"; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
For this Net::LDAP::AutoDNs and Net::LDAP::AutoServers is used, with |
34
|
|
|
|
|
|
|
their methods set to the defaults, minus 'devldap'. |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 METHODS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 new |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Initiates the object. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $foo=Sys::Dev::LDAP::Populate->new; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub new{ |
47
|
0
|
|
|
0
|
1
|
|
my $self={ |
48
|
|
|
|
|
|
|
error=>undef, |
49
|
|
|
|
|
|
|
errorString=>'', |
50
|
|
|
|
|
|
|
module=>'Sys-Dev-LDAP-Populate', |
51
|
|
|
|
|
|
|
}; |
52
|
0
|
|
|
|
|
|
bless $self; |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
return $self; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 populate |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
This populates the entries under "/dev/ldap". |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$foo->populate; |
62
|
|
|
|
|
|
|
if($foo->{error}){ |
63
|
|
|
|
|
|
|
print "Error!"; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=cut |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub populate{ |
69
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
70
|
0
|
|
|
|
|
|
my $method='populate'; |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$self->errorblank; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
#makes sure that the ldap device exists |
75
|
0
|
0
|
|
|
|
|
if (! -e "/dev/ldap/server") { |
76
|
0
|
|
|
|
|
|
$self->{error}=1; |
77
|
0
|
|
|
|
|
|
$self->{errorString}='"/dev/ldap/server" does not exist'; |
78
|
0
|
|
|
|
|
|
warn($self->{module}.' '.$method.':'.$self->{error}.': '.$self->{errorString}); |
79
|
0
|
|
|
|
|
|
return undef; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
#creates the new AutoDNs object |
83
|
0
|
|
|
|
|
|
my $AutoDNs=Net::LDAP::AutoDNs->new({methods=>"env,hostname"}); |
84
|
0
|
|
|
|
|
|
my $AutoServers=Net::LDAP::AutoServer->new({methods=>'hostname,dns,env'}); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
#holds the file handle |
87
|
0
|
|
|
|
|
|
my $fh; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
#writes out the user base |
90
|
0
|
0
|
|
|
|
|
if (open($fh , '>', '/dev/ldap/userBase')) { |
91
|
0
|
0
|
|
|
|
|
if (defined($AutoDNs->{users})) { |
92
|
0
|
|
|
|
|
|
print $fh $AutoDNs->{users}; |
93
|
|
|
|
|
|
|
}else { |
94
|
0
|
|
|
|
|
|
print $fh ''; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
close $fh; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
#writes out the group scope |
101
|
0
|
0
|
|
|
|
|
if (open($fh , '>', '/dev/ldap/userScope')) { |
102
|
0
|
0
|
|
|
|
|
if (defined($AutoDNs->{usersScope})) { |
103
|
0
|
|
|
|
|
|
print $fh $AutoDNs->{usersScope}; |
104
|
|
|
|
|
|
|
}else { |
105
|
0
|
|
|
|
|
|
print $fh ''; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
close $fh; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
#writes out the user base |
112
|
0
|
0
|
|
|
|
|
if (open($fh , '>', '/dev/ldap/groupBase')) { |
113
|
0
|
0
|
|
|
|
|
if (defined($AutoDNs->{groups})) { |
114
|
0
|
|
|
|
|
|
print $fh $AutoDNs->{groups}; |
115
|
|
|
|
|
|
|
}else { |
116
|
0
|
|
|
|
|
|
print $fh ''; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
0
|
|
|
|
|
|
close $fh; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
#writes out the group scope |
123
|
0
|
0
|
|
|
|
|
if (open($fh , '>', '/dev/ldap/groupScope')) { |
124
|
0
|
0
|
|
|
|
|
if (defined($AutoDNs->{groupsScope})) { |
125
|
0
|
|
|
|
|
|
print $fh $AutoDNs->{groupsScope}; |
126
|
|
|
|
|
|
|
}else { |
127
|
0
|
|
|
|
|
|
print $fh ''; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
0
|
|
|
|
|
|
close $fh; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
#writes out the home |
134
|
0
|
0
|
|
|
|
|
if (open($fh , '>', '/dev/ldap/homeBase')) { |
135
|
0
|
0
|
|
|
|
|
if (defined($AutoDNs->{home})) { |
136
|
0
|
|
|
|
|
|
print $fh $AutoDNs->{home}; |
137
|
|
|
|
|
|
|
}else { |
138
|
0
|
|
|
|
|
|
print $fh ''; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
print $fh $AutoDNs->{home}; |
142
|
0
|
|
|
|
|
|
close $fh; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
#writes out the base |
146
|
0
|
0
|
|
|
|
|
if (open($fh , '>', '/dev/ldap/base')) { |
147
|
0
|
0
|
|
|
|
|
if (defined($AutoDNs->{base})) { |
148
|
0
|
|
|
|
|
|
print $fh $AutoDNs->{base}; |
149
|
|
|
|
|
|
|
}else { |
150
|
0
|
|
|
|
|
|
print $fh ''; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
close $fh; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
#writes out the server |
157
|
0
|
0
|
|
|
|
|
if (open($fh , '>', '/dev/ldap/server')) { |
158
|
0
|
0
|
|
|
|
|
if (defined($AutoServers->{server})) { |
159
|
0
|
|
|
|
|
|
print $fh $AutoServers->{server}; |
160
|
|
|
|
|
|
|
}else { |
161
|
0
|
|
|
|
|
|
print $fh ''; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
|
close $fh; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
#writes out the port |
168
|
0
|
0
|
|
|
|
|
if (open($fh , '>', '/dev/ldap/port')) { |
169
|
0
|
0
|
|
|
|
|
if (defined($AutoServers->{port})) { |
170
|
0
|
|
|
|
|
|
print $fh $AutoServers->{port}; |
171
|
|
|
|
|
|
|
}else { |
172
|
0
|
|
|
|
|
|
print $fh ''; |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
close $fh; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
#writes out the startTLS |
179
|
0
|
0
|
|
|
|
|
if (open($fh , '>', '/dev/ldap/startTLS')) { |
180
|
0
|
0
|
|
|
|
|
if (defined($AutoServers->{startTLS})) { |
181
|
0
|
|
|
|
|
|
print $fh $AutoServers->{startTLS}; |
182
|
|
|
|
|
|
|
}else { |
183
|
0
|
|
|
|
|
|
print $fh ''; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
0
|
|
|
|
|
|
close $fh; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
#writes out the CAfile |
190
|
0
|
0
|
|
|
|
|
if (open($fh , '>', '/dev/ldap/CAfile')) { |
191
|
0
|
0
|
|
|
|
|
if (defined($AutoServers->{CAfile})) { |
192
|
0
|
|
|
|
|
|
print $fh $AutoServers->{CAfile}; |
193
|
|
|
|
|
|
|
}else { |
194
|
0
|
|
|
|
|
|
print $fh ''; |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
0
|
|
|
|
|
|
close $fh; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
#writes out the CApath |
201
|
0
|
0
|
|
|
|
|
if (open($fh , '>', '/dev/ldap/CApath')) { |
202
|
0
|
0
|
|
|
|
|
if (defined($AutoServers->{CApath})) { |
203
|
0
|
|
|
|
|
|
print $fh $AutoServers->{CApath}; |
204
|
|
|
|
|
|
|
}else { |
205
|
0
|
|
|
|
|
|
print $fh ''; |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
0
|
|
|
|
|
|
close $fh; |
209
|
|
|
|
|
|
|
} |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
#writes out the checkCRL |
212
|
0
|
0
|
|
|
|
|
if (open($fh , '>', '/dev/ldap/checkCRL')) { |
213
|
0
|
0
|
|
|
|
|
if (defined($AutoServers->{checkCRL})) { |
214
|
0
|
|
|
|
|
|
print $fh $AutoServers->{checkCRL}; |
215
|
|
|
|
|
|
|
}else { |
216
|
0
|
|
|
|
|
|
print $fh ''; |
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
|
219
|
0
|
|
|
|
|
|
close $fh; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
#writes out the clientCert |
223
|
0
|
0
|
|
|
|
|
if (open($fh , '>', '/dev/ldap/clientCert')) { |
224
|
0
|
0
|
|
|
|
|
if (defined($AutoServers->{clientCert})) { |
225
|
0
|
|
|
|
|
|
print $fh $AutoServers->{clientCert}; |
226
|
|
|
|
|
|
|
}else { |
227
|
0
|
|
|
|
|
|
print $fh ''; |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
0
|
|
|
|
|
|
close $fh; |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
#writes out the clientKey |
234
|
0
|
0
|
|
|
|
|
if (open($fh , '>', '/dev/ldap/clientKey')) { |
235
|
0
|
0
|
|
|
|
|
if (defined($AutoServers->{clientKey})) { |
236
|
0
|
|
|
|
|
|
print $fh $AutoServers->{clientKey}; |
237
|
|
|
|
|
|
|
}else { |
238
|
0
|
|
|
|
|
|
print $fh ''; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
0
|
|
|
|
|
|
close $fh; |
242
|
|
|
|
|
|
|
} |
243
|
|
|
|
|
|
|
|
244
|
0
|
|
|
|
|
|
return 1; |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head2 errorblank |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
This blanks the error storage and is only meant for internal usage. |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
It does the following. |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
$zconf->{error}=undef; |
254
|
|
|
|
|
|
|
$zconf->{errorString}=""; |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=cut |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
#blanks the error flags |
259
|
|
|
|
|
|
|
sub errorblank{ |
260
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
261
|
|
|
|
|
|
|
|
262
|
0
|
|
|
|
|
|
$self->{error}=undef; |
263
|
0
|
|
|
|
|
|
$self->{errorString}=""; |
264
|
|
|
|
|
|
|
|
265
|
0
|
|
|
|
|
|
return 1; |
266
|
|
|
|
|
|
|
}; |
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head1 ERROR CODES |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
This may be tested via checking if "$foo->{error}" is true. If it is |
272
|
|
|
|
|
|
|
true, then a description can be found via checking "$foo->{errorString}". |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=head2 1 |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
LDAP kmod does not appear to be present. |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=head1 AUTHOR |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
Zane C. Bowers, C<< >> |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head1 BUGS |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
285
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
286
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head1 SUPPORT |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
perldoc Sys::Dev::LDAP::Populate |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
You can also look for information at: |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=over 4 |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
L |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
L |
309
|
|
|
|
|
|
|
|
310
|
|
|
|
|
|
|
=item * CPAN Ratings |
311
|
|
|
|
|
|
|
|
312
|
|
|
|
|
|
|
L |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
=item * Search CPAN |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
L |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
=back |
319
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
Copyright 2009 Zane C. Bowers, all rights reserved. |
327
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
329
|
|
|
|
|
|
|
under the same terms as Perl itself. |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
=cut |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
1; # End of Sys::Dev::LDAP::Populate |