[yast-commit] r67424 - in /trunk/dns-server: package/yast2-dns-server.changes src/DnsServer.pm
Author: locilka Date: Mon Feb 13 18:19:00 2012 New Revision: 67424 URL: http://svn.opensuse.org/viewcvs/yast?rev=67424&view=rev Log: - Checking for and adding required LDAP schemas (yast, dnszone) while writing the configuration. Fixed handling if configuration cannot be written to LDAP (bnc#690237). Modified: trunk/dns-server/package/yast2-dns-server.changes trunk/dns-server/src/DnsServer.pm Modified: trunk/dns-server/package/yast2-dns-server.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/dns-server/package/yast2-dns-server.changes?rev=67424&r1=67423&r2=67424&view=diff ============================================================================== --- trunk/dns-server/package/yast2-dns-server.changes (original) +++ trunk/dns-server/package/yast2-dns-server.changes Mon Feb 13 18:19:00 2012 @@ -1,4 +1,11 @@ ------------------------------------------------------------------ +Mon Feb 13 18:06:25 CET 2012 - locilka@suse.com + +- Checking for and adding required LDAP schemas (yast, dnszone) + while writing the configuration. Fixed handling if configuration + cannot be written to LDAP (bnc#690237). + +------------------------------------------------------------------ Fri Feb 10 13:13:43 CET 2012 - locilka@suse.com - Fixed transforming records from absolute to relative format Modified: trunk/dns-server/src/DnsServer.pm URL: http://svn.opensuse.org/viewcvs/yast/trunk/dns-server/src/DnsServer.pm?rev=67424&r1=67423&r2=67424&view=diff ============================================================================== --- trunk/dns-server/src/DnsServer.pm (original) +++ trunk/dns-server/src/DnsServer.pm Mon Feb 13 18:19:00 2012 @@ -1281,7 +1281,10 @@ # authenticate to LDAP if ($use_ldap) { - LdapPrepareToWrite (); + unless (LdapPrepareToWrite ()) { + y2error ("Cannot write to LDAP"); + return 0; + } } foreach my $z (@zones) { @@ -1790,6 +1793,31 @@ return; } +# Checks whether all required schemas are correctly included +# Gets an LDAP Domain as a parameter +# Returns boolean +sub LdapSchemasPresent ($) { + my $ldap_domain = shift; + my $ret = 1; + local $Data::Dumper::Indent = 0; + + my $default_config = "ou=ldapconfig,".$ldap_domain; + my $dc_ret = Ldap->GetLDAPEntry ($default_config); + y2milestone ("LDAP: Default config (".$default_config.") found: ".Dumper($dc_ret)); + + # Record not found + $ret = 0 if (! defined $dc_ret || keys(%{$dc_ret}) == 0); + + my $dns_zone = "ou=DNS,".$ldap_domain; + my $dz_ret = Ldap->GetLDAPEntry ($dns_zone); + y2milestone ("LDAP: DNS (".$dns_zone.") found: ".Dumper($dz_ret)); + + # Record not found + $ret = 0 if (! defined $dz_ret || keys(%{$dz_ret}) == 0); + + return $ret; +} + BEGIN { $TYPEINFO{LdapPrepareToWrite} = ["function", "boolean"];} sub LdapPrepareToWrite { my $self = shift; @@ -1805,6 +1833,7 @@ || 0 != scalar (@{NetworkInterfaces->Locate ("IPADDR", $ldap_server)})) { y2milestone ("LDAP server is local, checking included schemas"); + LdapServerAccess->AddLdapSchemas(["/etc/openldap/schema/yast.schema"],1); LdapServerAccess->AddLdapSchemas(["/etc/openldap/schema/dnszone.schema"],1); } else @@ -1856,6 +1885,14 @@ } Ldap->SetGUI(YaST::YCP::Boolean(1)); + # If non-local server is used, schemas are not handled but required anyway + # BNC #710430 and BNC #690237 + unless (LdapSchemasPresent($ldap_domain)) { + y2error ("Required schemas not found."); + Report->Error (__("Required LDAP schemas (yast, dnszone) are not included.\nCannot write to LDAP.")); + return 0; + } + # find suseDnsConfiguration object %ldap_query = ( "base_dn" => $ldap_config_dn, @@ -1886,7 +1923,7 @@ my $err = SCR->Read (".ldap.error") || {}; my $err_descr = Dumper ($err); y2error ("Error descr: $err_descr"); - return; + return 0; } %found = %ldap_object; } @@ -1912,7 +1949,7 @@ my $err = SCR->Read (".ldap.error") || {}; my $err_descr = Dumper ($err); y2error ("Error descr: $err_descr"); - return; + return 0; } @bases = ("ou=DNS,$ldap_domain"); } @@ -1947,9 +1984,11 @@ my $err = SCR->Read (".ldap.error") || {}; my $err_descr = Dumper ($err); y2error ("Error descr: $err_descr"); - return; + return 0; } } + + return 1; } BEGIN { $TYPEINFO{LdapStore} = ["function", "void" ]; } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
locilka@svn2.opensuse.org