diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Fripost/Schema.pm | 22 | ||||
-rw-r--r-- | lib/Fripost/Schema/Domain.pm | 8 | ||||
-rw-r--r-- | lib/Fripost/Schema/List.pm | 6 |
3 files changed, 16 insertions, 20 deletions
diff --git a/lib/Fripost/Schema.pm b/lib/Fripost/Schema.pm index f7a9d75..b5dcdb6 100644 --- a/lib/Fripost/Schema.pm +++ b/lib/Fripost/Schema.pm @@ -47,8 +47,8 @@ sub SASLauth { my ($l,$d) = split_addr(shift); my %cfg = @_; + return unless defined $cfg{ldap_SASL_mechanism}; my $self = bless {}, $class; - return $self unless defined $cfg{ldap_SASL_mechanism}; $self->suffix( ldap_explode_dn(@{$cfg{ldap_suffix}}) ); $self->whoami( canonical_dn( {fvu => $l}, {fvd => $d}, @{$self->suffix} )); @@ -227,23 +227,21 @@ under the same terms as perl itself. =cut -sub _dn2email { +sub _dn2fvu { my $self = shift; - my $dn = shift; - $dn =~ s/^fvd=([^,]+),.*/\@$1/ and return $dn; - $dn =~ s/^fv(?:u|a|l)=([^,]+),fvd=([^,]+),.*/$1\@$2/ - or die "Wrong usage: of _dn2email: $dn"; - return $dn; + my $dn = ldap_explode_dn(shift); + + return '@'. $dn->[0]->{fvd} if exists $dn->[0]->{fvd}; + return $dn->[0]->{fvu} .'@'. $dn->[1]->{fvd}; } -sub _email2dn { +sub _fvu2dn { my $self = shift; my $email = shift; my ($l,$d) = split_addr($email); - die "Wrong usage: of _email2dn: $email" unless defined $d; - my $dn = "fvd=$d,".$self->suffix; - $dn = "fvu=$l,".$dn if $l ne ''; - return $dn; + my @dn = ({fvd => $d}, @{$self->suffix}); + unshift @dn, {fvu => $l} if defined $l and $l ne ''; + canonical_dn( @dn ); } 1; diff --git a/lib/Fripost/Schema/Domain.pm b/lib/Fripost/Schema/Domain.pm index fc80b4c..dc16ae0 100644 --- a/lib/Fripost/Schema/Domain.pm +++ b/lib/Fripost/Schema/Domain.pm @@ -103,9 +103,9 @@ sub get { , catchalls => concat($concat, map { &_email_to_unicode ($_) } $domain->get_value('fripostOptionalMaildrop')) , permissions => get_perms($domain, $self->whoami) - , canCreateAlias => concat($concat, map { &_email_to_unicode ($self->_dn2email($_)) } + , canCreateAlias => concat($concat, map { &_email_to_unicode ($self->_dn2fvu($_)) } $domain->get_value('fripostCanCreateAlias')) - , canCreateList => concat($concat, map { &_email_to_unicode ($self->_dn2email($_)) } + , canCreateList => concat($concat, map { &_email_to_unicode ($self->_dn2fvu($_)) } $domain->get_value('fripostCanCreateList')) ) } @@ -136,10 +136,10 @@ sub replace { , description => $d->{description} , fripostOptionalMaildrop => $d->{catchalls} , fripostCanCreateAlias => - [ map $self->_email2dn($_), + [ map $self->_fvu2dn($_), @{$d->{canCreateAlias}} ] , fripostCanCreateList => - [ map $self->_email2dn($_), + [ map $self->_fvu2dn($_), @{$d->{canCreateList}} ] } ); die $mesg->error."\n" if $mesg->code; diff --git a/lib/Fripost/Schema/List.pm b/lib/Fripost/Schema/List.pm index 7753bd1..18eeb29 100644 --- a/lib/Fripost/Schema/List.pm +++ b/lib/Fripost/Schema/List.pm @@ -18,7 +18,7 @@ use utf8; use parent 'Fripost::Schema'; use Fripost::Schema::Util qw/concat explode must_attrs email_valid - split_addr canonical_dn ldap_explode_dn/; + split_addr canonical_dn/; use Net::IDN::Encode qw/domain_to_ascii email_to_ascii email_to_unicode/; use Mail::GnuPG; use MIME::Entity; @@ -143,9 +143,7 @@ sub add { # Ask the list manager to create the list now. - my $whoami = ldap_explode_dn( $self->whoami ); - my $member = email_valid( $whoami->[0]->{fvu} .'@'. $whoami->[1]->{fvd} - , -exact => 1 ); + my $member = email_valid( $self->_dn2fvu($self->whoami), -exact => 1); my $to = email_valid( 'mklist+'.$l->{transport}.'@fripost.org' , -exact => 1 ); |