Skip to content

Commit

Permalink
Enhanced checking for errors while writing to LDAP
Browse files Browse the repository at this point in the history
- BNC #768708
  • Loading branch information
kobliha committed Nov 9, 2012
1 parent 26b330a commit 293cc7d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/DnsServer.pm
Expand Up @@ -402,7 +402,11 @@ sub SaveGlobals {
my %zone = %{$_};
$zone{"zone"};
} @zones;
DnsZones->ZonesDeleteLdap (\@zone_names);

unless (DnsZones->ZonesDeleteLdap (\@zone_names)) {
y2error ("Cannot delete selected zones");
return 0;
}
}

# delete all removed options
Expand Down
15 changes: 14 additions & 1 deletion src/DnsZones.pm
Expand Up @@ -706,6 +706,7 @@ sub ZoneFileWriteLdap {
unless ($ldap_write) {
y2error("LDAP Error (write): ".Ldap->LDAPError());
Ldap->LDAPErrorMessage('write', Ldap->LDAPError());
return 0;
}

my @all_records = map {
Expand Down Expand Up @@ -753,6 +754,7 @@ sub ZoneFileWriteLdap {
unless ($ldap_write) {
y2error("LDAP Error (delete): ".Ldap->LDAPError());
Ldap->LDAPErrorMessage('write', Ldap->LDAPError());
return 0;
}

# write all the other records
Expand Down Expand Up @@ -820,6 +822,7 @@ sub ZoneFileWriteLdap {
unless ($ldap_write) {
y2error("LDAP Error (write): ".Ldap->LDAPError());
Ldap->LDAPErrorMessage('write', Ldap->LDAPError());
return 0;
}

return $ldap_write;
Expand All @@ -839,14 +842,24 @@ sub ZonesDeleteLdap {
@check_zones == 0;
} @current_zones_in_ldap;

my $ldap_write = 1;

foreach my $z (@zones_to_delete) {
y2milestone ("Removing zone $z from LDAP");
my %request = (
"dn" => "zoneName=$z,$zone_base_config_dn",
"subtree" => 1,
);
SCR->Write (".ldap.delete", \%request);
$ldap_write = SCR->Write (".ldap.delete", \%request);

unless ($ldap_write) {
y2error("LDAP Error (write): ".Ldap->LDAPError());
Ldap->LDAPErrorMessage('write', Ldap->LDAPError());
last;
}
}

return $ldap_write;
}

BEGIN{ $TYPEINFO{ZonesListLdap} = ["function", ["list", "string"]];}
Expand Down

0 comments on commit 293cc7d

Please sign in to comment.