Skip to content

Commit 0509008

Browse files
committed
LDAP: Add deref option to specify how to dereference aliases
1 parent 88da409 commit 0509008

File tree

9 files changed

+148
-32
lines changed

9 files changed

+148
-32
lines changed

src/cgi/wwsympa.fcgi.in

+7-5
Original file line numberDiff line numberDiff line change
@@ -3657,6 +3657,7 @@ sub is_ldap_user {
36573657
base => $ldap->{'suffix'},
36583658
filter => "$filter",
36593659
scope => $ldap->{'scope'},
3660+
deref => $ldap->{'deref'},
36603661
timeout => $ldap->{'timeout'}
36613662
);
36623663

@@ -15492,7 +15493,8 @@ sub do_arc_download {
1549215493
my $string = $message->as_string =~ s/\r?\n/\r\n/gr;
1549315494
if ($Archive::Zip::SimpleZip::VERSION) {
1549415495
$rv = $zip->addString($string,
15495-
Name => sprintf('%s/%s.eml', $arc_dirname, $handle->basename)
15496+
Name =>
15497+
sprintf('%s/%s.eml', $arc_dirname, $handle->basename)
1549615498
);
1549715499
$az = $Archive::Zip::SimpleZip::SimpleZipError;
1549815500
} else {
@@ -16649,21 +16651,21 @@ sub do_invite {
1664916651
if ($in{'email'}) {
1665016652
@emails =
1665116653
grep {$_} map { Sympa::Tools::Text::canonic_email($_) }
16652-
split /\0/, $in{'email'};
16653-
$log->syslog('info', 'single invite "%s"', join(' ',@emails));
16654+
split /\0/, $in{'email'};
16655+
$log->syslog('info', 'single invite "%s"', join(' ', @emails));
1665416656
unless (@emails) {
1665516657
add_stash('user', 'no_email');
1665616658
return 'review';
1665716659
}
16658-
} else { # addresses for multiple users (from import.tt2) are $in{dump}
16660+
} else { # addresses for multiple users (from import.tt2) are $in{dump}
1665916661
foreach (split /\r\n|\r|\n/, $in{'dump'}) {
1666016662
next unless /\S/;
1666116663
next if /\A\s*#/; #FIXME: email address can contain '#'
1666216664

1666316665
my ($email) = m{\A\s*(\S+)(?:\s+(.*))?\s*\z};
1666416666
push @emails, $email;
1666516667
}
16666-
$log->syslog('info', 'multiple invite "%s"', join(' ',@emails));
16668+
$log->syslog('info', 'multiple invite "%s"', join(' ', @emails));
1666716669
unless (@emails) {
1666816670
add_stash('user', 'no_email');
1666916671
return 'import';

src/lib/Conf.pm

+11-5
Original file line numberDiff line numberDiff line change
@@ -685,12 +685,13 @@ sub _load_auth {
685685
'get_dn_by_uid_filter' => '.+',
686686
'get_dn_by_email_filter' => '.+',
687687
'email_attribute' => Sympa::Regexps::ldap_attrdesc(),
688-
'alternative_email_attribute' => '.*', # Obsoleted
688+
'alternative_email_attribute' => '.*', # Obsoleted
689689
'scope' => 'base|one|sub',
690-
'authentication_info_url' => 'http(s)?:/.*',
691-
'use_tls' => 'starttls|ldaps|none',
692-
'use_ssl' => '1', # Obsoleted
693-
'use_start_tls' => '1', # Obsoleted
690+
'deref' => 'never|search|find|always',
691+
'authentication_info_url' => 'http(s)?:/.*',
692+
'use_tls' => 'starttls|ldaps|none',
693+
'use_ssl' => '1', # Obsoleted
694+
'use_start_tls' => '1', # Obsoleted
694695
'ssl_version' => 'sslv2/3|sslv2|sslv3|tlsv1|tlsv1_[123]',
695696
'ssl_ciphers' => '[\w:]+',
696697
'ssl_cert' => '.+',
@@ -722,6 +723,7 @@ sub _load_auth {
722723
'timeout' => '\d+',
723724
'suffix' => '.+',
724725
'scope' => 'base|one|sub',
726+
'deref' => 'never|search|find|always',
725727
'get_email_by_uid_filter' => '.+',
726728
'email_attribute' => Sympa::Regexps::ldap_attrdesc(),
727729
'use_tls' => 'starttls|ldaps|none',
@@ -749,6 +751,7 @@ sub _load_auth {
749751
'timeout' => '\d+',
750752
'suffix' => '.+',
751753
'scope' => 'base|one|sub',
754+
'deref' => 'never|search|find|always',
752755
'get_email_by_uid_filter' => '.+',
753756
'email_attribute' => Sympa::Regexps::ldap_attrdesc(),
754757
'use_tls' => 'starttls|ldaps|none',
@@ -883,10 +886,12 @@ sub _load_auth {
883886
## Force the default scope because '' is interpreted as
884887
## 'base'
885888
$current_paragraph->{'scope'} ||= 'sub';
889+
$current_paragraph->{'deref'} ||= 'find';
886890
} elsif ($current_paragraph->{'auth_type'} eq 'generic_sso') {
887891
## Force the default scope because '' is interpreted as
888892
## 'base'
889893
$current_paragraph->{'scope'} ||= 'sub';
894+
$current_paragraph->{'deref'} ||= 'find';
890895
## default value for http_header_value_separator is ';'
891896
$current_paragraph->{'http_header_value_separator'} ||=
892897
';';
@@ -903,6 +908,7 @@ sub _load_auth {
903908
## Force the default scope because '' is interpreted as
904909
## 'base'
905910
$current_paragraph->{'scope'} ||= 'sub';
911+
$current_paragraph->{'deref'} ||= 'find';
906912
} elsif ($current_paragraph->{'auth_type'} eq 'user_table') {
907913
;
908914
} elsif ($current_paragraph->{'auth_type'} eq 'cgi') {

src/lib/Sympa/CLI/test/ldap.pm

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ sub _run {
8989
base => ($options->{suffix} // ''),
9090
filter => $filter,
9191
scope => ($options->{scope} || 'sub'),
92+
deref => ($options->{deref} || 'find'),
9293
attrs =>
9394
($options->{attrs} ? [split /\s*,\s*/, $options->{attrs}] : ['']),
9495
) or die sprintf "Search impossible: %s\n", $db->error;

src/lib/Sympa/Conf.pm-YETUSED

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package Sympa::Conf;
2+
3+
use strict;
4+
use warnings;
5+
6+
use Exporter qw(import);
7+
BEGIN { our @EXPORT = qw(Conf); }
8+
9+
use Sympa::Constants;
10+
11+
our %Conf;
12+
13+
sub Conf ($@) {
14+
my $that = shift || '*';
15+
my @keys = map { split /[.]/ } @_;
16+
17+
_load() unless %Conf;
18+
warn 'loaded';
19+
}
20+
21+
sub _load {
22+
die 'Cannot load';
23+
}
24+
25+
1;
26+
__END__
27+
28+
package Conf;
29+
30+
use strict;
31+
use warnings;
32+
33+
*Conf = *Sympa::Conf;
34+
# or
35+
#*Conf = 'Sympa::Conf';
36+
37+
1;
38+

src/lib/Sympa/Config/Schema.pm

+61-7
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ our %pinfo = (
348348
gettext_id => 'Name of the database',
349349
gettext_comment =>
350350
"With SQLite, this must be the full path to database file.\nWith Oracle Database, this must be SID, net service name or easy connection identifier (to use net service name, db_host should be set to \"none\" and HOST, PORT and SERVICE_NAME should be defined in tnsnames.ora file).",
351-
format => '.+',
351+
format => '.+',
352352
occurrence => '1',
353353
},
354354
db_user => {
@@ -1717,8 +1717,8 @@ our %pinfo = (
17171717
default => 'owner',
17181718
},
17191719
quota => {
1720-
context => [qw(list domain site)],
1721-
order => 3,
1720+
context => [qw(list domain site)],
1721+
order => 3,
17221722
gettext_id => "quota",
17231723
gettext_unit => 'Kbytes',
17241724
format => '\d+',
@@ -3418,6 +3418,15 @@ our %pinfo = (
34183418
occurrence => '1',
34193419
default => 'sub'
34203420
},
3421+
deref => {
3422+
context => [qw(list)],
3423+
order => 5.5,
3424+
gettext_id => "dereferencing aliases",
3425+
format => ['never', 'search', 'find', 'always'],
3426+
occurrence => '1',
3427+
default => 'find',
3428+
not_before => '6.2.74',
3429+
},
34213430
timeout => {
34223431
context => [qw(list)],
34233432
order => 6,
@@ -3599,6 +3608,15 @@ our %pinfo = (
35993608
format => ['base', 'one', 'sub'],
36003609
default => 'sub'
36013610
},
3611+
deref1 => {
3612+
context => [qw(list)],
3613+
order => 5.5,
3614+
gettext_id => "dereferencing aliases",
3615+
format => ['never', 'search', 'find', 'always'],
3616+
occurrence => '1',
3617+
default => 'find',
3618+
not_before => '6.2.74',
3619+
},
36023620
timeout1 => {
36033621
context => [qw(list)],
36043622
order => 6,
@@ -3653,6 +3671,15 @@ our %pinfo = (
36533671
occurrence => '1',
36543672
default => 'sub'
36553673
},
3674+
deref2 => {
3675+
context => [qw(list)],
3676+
order => 12.5,
3677+
gettext_id => "dereferencing aliases",
3678+
format => ['never', 'search', 'find', 'always'],
3679+
occurrence => '1',
3680+
default => 'find',
3681+
not_before => '6.2.74',
3682+
},
36563683
timeout2 => {
36573684
context => [qw(list)],
36583685
order => 13,
@@ -3821,8 +3848,8 @@ our %pinfo = (
38213848
order => 9,
38223849
gettext_id =>
38233850
"Directory where the database is stored (used for DBD::CSV only)",
3824-
format => '.+',
3825-
obsolete => 'db_name',
3851+
format => '.+',
3852+
obsolete => 'db_name',
38263853
not_after => '6.2.70',
38273854
},
38283855
nosync_time_ranges => {
@@ -3987,6 +4014,15 @@ our %pinfo = (
39874014
occurrence => '1',
39884015
default => 'sub'
39894016
},
4017+
deref => {
4018+
context => [qw(list)],
4019+
order => 5.5,
4020+
gettext_id => "dereferencing aliases",
4021+
format => ['never', 'search', 'find', 'always'],
4022+
occurrence => '1',
4023+
default => 'find',
4024+
not_before => '6.2.74',
4025+
},
39904026
timeout => {
39914027
context => [qw(list)],
39924028
order => 6,
@@ -4164,6 +4200,15 @@ our %pinfo = (
41644200
occurrence => '1',
41654201
default => 'sub'
41664202
},
4203+
deref1 => {
4204+
context => [qw(list)],
4205+
order => 5.5,
4206+
gettext_id => "dereferencing aliases",
4207+
format => ['never', 'search', 'find', 'always'],
4208+
occurrence => '1',
4209+
default => 'find',
4210+
not_before => '6.2.74',
4211+
},
41674212
timeout1 => {
41684213
context => [qw(list)],
41694214
order => 6,
@@ -4218,6 +4263,15 @@ our %pinfo = (
42184263
occurrence => '1',
42194264
default => 'sub'
42204265
},
4266+
deref2 => {
4267+
context => [qw(list)],
4268+
order => 12.5,
4269+
gettext_id => "dereferencing aliases",
4270+
format => ['never', 'search', 'find', 'always'],
4271+
occurrence => '1',
4272+
default => 'find',
4273+
not_before => '6.2.74',
4274+
},
42214275
timeout2 => {
42224276
context => [qw(list)],
42234277
order => 13,
@@ -4381,8 +4435,8 @@ our %pinfo = (
43814435
order => 9,
43824436
gettext_id =>
43834437
"Directory where the database is stored (used for DBD::CSV only)",
4384-
format => '.+',
4385-
obsolete => 'db_name',
4438+
format => '.+',
4439+
obsolete => 'db_name',
43864440
not_after => '6.2.70',
43874441
},
43884442
email_entry => {

src/lib/Sympa/DataSource/LDAP.pm

+16-14
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,12 @@ sub _open {
4646
$self->{_db} = $db;
4747

4848
my $pagesize = $options{pagesize} || $self->{pagesize};
49-
if ($pagesize and $db->__dbh->root_dse->supported_control(
49+
if ($pagesize
50+
and $db->__dbh->root_dse->supported_control(
5051
Net::LDAP::Constant::LDAP_CONTROL_PAGED()
51-
)) {
52-
$self->{_page} = Net::LDAP::Control::Paged->new( size => $pagesize );
52+
)
53+
) {
54+
$self->{_page} = Net::LDAP::Control::Paged->new(size => $pagesize);
5355
}
5456

5557
my $mesg = $self->_open_operation(%options);
@@ -69,13 +71,15 @@ sub _open_operation {
6971
my $ldap_filter = $options{filter} || $self->{filter};
7072
my $ldap_attrs = $options{attrs} || $self->{attrs};
7173
my $ldap_scope = $options{scope} || $self->{scope};
74+
my $ldap_deref = $options{deref} || $self->{deref};
7275

7376
my @args = (
74-
base => $ldap_suffix,
75-
filter => $ldap_filter,
76-
attrs => [split /\s*,\s*/, $ldap_attrs],
77-
scope => $ldap_scope,
78-
control=> $self->{_page} ? [$self->{_page}] : []
77+
base => $ldap_suffix,
78+
filter => $ldap_filter,
79+
attrs => [split /\s*,\s*/, $ldap_attrs],
80+
scope => $ldap_scope,
81+
deref => $ldap_deref,
82+
control => $self->{_page} ? [$self->{_page}] : []
7983
);
8084

8185
my $mesg = $self->{_db}->do_operation('search', @args);
@@ -133,8 +137,7 @@ sub _load_next {
133137
# second page, or later one (but not post-last) of a paged search:
134138
# load next page
135139
$mesg = $self->_open_operation(%options);
136-
}
137-
else {
140+
} else {
138141
$mesg = $self->__dsh;
139142
}
140143
while (my $entry = $mesg->shift_entry) {
@@ -180,10 +183,9 @@ sub _load_next {
180183
}
181184

182185
if ($self->{_page} and $mesg) {
183-
my $cookie = $mesg->control(
184-
Net::LDAP::Constant::LDAP_CONTROL_PAGED
185-
)->cookie;
186-
$self->{_page}->cookie( $cookie );
186+
my $cookie =
187+
$mesg->control(Net::LDAP::Constant::LDAP_CONTROL_PAGED)->cookie;
188+
$self->{_page}->cookie($cookie);
187189
}
188190

189191
return [@retrieved];

src/lib/Sympa/ListOpt.pm

+8
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ our %list_option = (
106106
'one' => {'gettext_id' => 'one level'},
107107
'sub' => {'gettext_id' => 'subtree'},
108108

109+
# include_ldap_2level_query.deref2, include_ldap_2level_query.deref1,
110+
# include_ldap_query.deref
111+
'never' => {'gettext_id' => 'never'},
112+
'search' =>
113+
{'gettext_id' => 'in searching subordinates of the base object'},
114+
'find' => {'gettext_id' => 'in locating the base object'},
115+
'always' => {'gettext_id' => 'always'},
116+
109117
# include_ldap_query.use_tls, include_ldap_2level_query.use_tls,
110118
# include_ldap_ca.use_tls, include_ldap_2level_ca.use_tls
111119
'starttls' => {'gettext_id' => 'use STARTTLS'},

src/lib/Sympa/Scenario.pm

+4-1
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,7 @@ sub do_search {
14011401
base => "$ldap_conf{'suffix'}",
14021402
filter => "$filter",
14031403
scope => "$ldap_conf{'scope'}",
1404+
deref => "$ldap_conf{'deref'}",
14041405
attrs => ['1.1']
14051406
);
14061407
unless ($mesg) {
@@ -1580,7 +1581,8 @@ sub _load_ldap_configuration {
15801581
return;
15811582
}
15821583

1583-
my @valid_options = qw(host suffix filter scope bind_dn bind_password
1584+
my @valid_options =
1585+
qw(host suffix filter scope deref bind_dn bind_password
15841586
use_tls ssl_version ssl_ciphers ssl_cert ssl_key
15851587
ca_verify ca_path ca_file);
15861588
my @required_options = qw(host suffix filter);
@@ -1593,6 +1595,7 @@ sub _load_ldap_configuration {
15931595
'suffix' => undef,
15941596
'filter' => undef,
15951597
'scope' => 'sub',
1598+
'deref' => 'find',
15961599
'bind_dn' => undef,
15971600
'bind_password' => undef
15981601
);

0 commit comments

Comments
 (0)