aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Fripost/Schema/Local.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Fripost/Schema/Local.pm')
-rw-r--r--lib/Fripost/Schema/Local.pm27
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/Fripost/Schema/Local.pm b/lib/Fripost/Schema/Local.pm
index f497a4e..49c3d68 100644
--- a/lib/Fripost/Schema/Local.pm
+++ b/lib/Fripost/Schema/Local.pm
@@ -115,11 +115,29 @@ sub exists {
# The trick is somewhat dirty, but it's safe enough since postfix
# delivers to mailboxes, aliases, and lists with different
# priorities (and lists have the lowest).
-# $l =~ s/(.*)-(admin|bounces|confirm|join|leave|loop|owner|request|subscribe|unsubscribe|bounce|sendkey)$/$1/;
- # ^ TODO
+ my @cmds = qw/admin bounces confirm join leave owner request subscribe unsubscribe bounce sendkey/;
+ my @tests = ( 'fvu='.$l, 'fva='.$l, 'fvl='.$l );
+
+ foreach (@cmds) {
+ # If the entry is of the form 'foo-command', we need to ensure
+ # that no list 'foo' exists, otherwise the new entry would
+ # override foo's command.
+ if ($l =~ s/-$_$//) {
+ push @tests, 'fvl='.$l;
+ last;
+ }
+ }
+ if (defined $options{t} and $options{t} eq 'list') {
+ # If that's a list that is to be created, we need to ensure that
+ # none of its commands exists.
+ foreach (@cmds) {
+ my $l2 = $l.'-'.$_;
+ push @tests, 'fvu='.$l2, 'fva='.$l2;
+ }
+ }
- foreach my $t (qw/fvu fva fvl/) {
- my $mesg = $self->ldap->search( base => "$t=$l,fvd=$d,".$self->suffix,
+ foreach (@tests) {
+ my $mesg = $self->ldap->search( base => "$_,fvd=$d,".$self->suffix,
scope => 'base',
deref => 'never',
filter => 'objectClass=*'
@@ -129,6 +147,7 @@ sub exists {
die $options{'-die'}."\n" if defined $options{'-die'};
die $mesg->error."\n";
}
+
}
return 0;
}