aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Fripost/Panel/Interface.pm4
-rw-r--r--lib/Fripost/Schema/Domain.pm9
-rw-r--r--lib/Fripost/Schema/Local.pm2
-rwxr-xr-xmisc/deleteExpiredEntries.pl4
4 files changed, 11 insertions, 8 deletions
diff --git a/lib/Fripost/Panel/Interface.pm b/lib/Fripost/Panel/Interface.pm
index cc7545a..aee0df4 100644
--- a/lib/Fripost/Panel/Interface.pm
+++ b/lib/Fripost/Panel/Interface.pm
@@ -225,7 +225,7 @@ sub EditLocal : Runmode {
# Search for *the* matching user, alias or list.
my ($d,$l) = ($self->split_path)[1,2];
- $fp->domain->get ($d, -die => 404, -attrs => []);
+ $fp->domain->get ($d, -die => 404, -assert_exist => 1);
my %local = $fp->local->get ($l.'@'.$d, -die => 404,
-concat => "\x{0D}\x{0A}" );
die "Unknown type" unless grep { $local{type} eq $_ }
@@ -488,7 +488,7 @@ sub AddLocal : Runmode {
unless ($error) {
my $fp = Fripost::Schema::->SASLauth( $self->authen->username, %CFG );
- $fp->domain->get ($d, -die => 404, -attrs => []);
+ $fp->domain->get ($d, -die => 404, -assert_exist => 1);
$error = $fp->$t->add( \%entry, -concat => "(\n|\x{0D}\x{0A})", %rest);
$fp->done;
return $self->redirect('./') unless $error;
diff --git a/lib/Fripost/Schema/Domain.pm b/lib/Fripost/Schema/Domain.pm
index 56e9737..8c3586f 100644
--- a/lib/Fripost/Schema/Domain.pm
+++ b/lib/Fripost/Schema/Domain.pm
@@ -17,7 +17,7 @@ use warnings;
use utf8;
use parent 'Fripost::Schema';
-use Net::LDAP qw/LDAP_SUCCESS LDAP_COMPARE_TRUE/;
+use Net::LDAP qw/LDAP_SUCCESS LDAP_COMPARE_TRUE LDAP_NO_SUCH_OBJECT/;
use Fripost::Schema::Util qw/concat get_perms explode must_attrs
email_valid canonical_dn/;
use Net::IDN::Encode qw/domain_to_ascii domain_to_unicode
@@ -113,6 +113,8 @@ sub get {
fripostOwner
fripostPostmaster/ ];
+ $attrs = [ '1.1' ] if $options{'-assert_exist'};
+
my $domains = $self->ldap->search(
base => canonical_dn({fvd => $d}, @{$self->suffix}),
scope => 'base',
@@ -133,6 +135,7 @@ sub get {
die $options{'-die'}."\n" if defined $options{'-die'};
die "No such such domain: ā€˜$dā€™\n";
}
+ return if $options{'-assert_exist'};
return ( domain => domain_to_unicode($domain->get_value('fvd'))
, isactive => $domain->get_value('fripostIsStatusActive') eq 'TRUE'
@@ -237,11 +240,11 @@ sub add {
scope => 'base',
deref => 'never',
filter => 'objectClass=FripostVirtualDomain',
- attrs => [] );
+ attrs => [ '1.1' ] );
if ($mesg->code == LDAP_SUCCESS) {
die "Domain ā€˜".$domain."ā€™ already exists.\n";
}
- elsif ($mesg->code != 32) {
+ elsif ($mesg->code != LDAP_NO_SUCH_OBJECT) {
die $mesg->error."\n";
}
diff --git a/lib/Fripost/Schema/Local.pm b/lib/Fripost/Schema/Local.pm
index 51cac34..7a1ae22 100644
--- a/lib/Fripost/Schema/Local.pm
+++ b/lib/Fripost/Schema/Local.pm
@@ -144,7 +144,7 @@ sub exists {
, scope => 'base'
, deref => 'never'
, filter => 'objectClass=*'
- , attrs => []
+ , attrs => [ '1.1' ]
);
return 1 unless $mesg->code; # 0 Success
unless ($mesg->code == 32) { # 32 No such object
diff --git a/misc/deleteExpiredEntries.pl b/misc/deleteExpiredEntries.pl
index d4de6b6..3cbf570 100755
--- a/misc/deleteExpiredEntries.pl
+++ b/misc/deleteExpiredEntries.pl
@@ -53,14 +53,14 @@ die $entries->error."\n" if $entries->code;
$fp->done;
sub delete_entry {
- shift;
- my $obj = shift;
+ my ($mesg, $obj) = @_;
if (defined $obj and $obj->isa('Net::LDAP::Entry')) {
# print STDERR "Deleting DN ".$obj->dn."\n";
$obj->delete;
my $mesg = $obj->update($fp->ldap);
die $mesg->error."\n" if $mesg->code;
}
+ $mesg->pop_entry;
}