Author: rhafer Date: Wed Sep 10 18:09:57 2008 New Revision: 50990 URL: http://svn.opensuse.org/viewcvs/yast?rev=50990&view=rev Log: More exception handling (bnc#425148) Modified: trunk/ldap-server/src/YaPI/LdapServer.pm trunk/ldap-server/src/agent/SlapdConfigAgent.cc trunk/ldap-server/src/lib/slapd-config.cpp Modified: trunk/ldap-server/src/YaPI/LdapServer.pm URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/YaPI/LdapServer.pm?rev=50990&r1=50989&r2=50990&view=diff ============================================================================== --- trunk/ldap-server/src/YaPI/LdapServer.pm (original) +++ trunk/ldap-server/src/YaPI/LdapServer.pm Wed Sep 10 18:09:57 2008 @@ -1187,7 +1187,8 @@ if(! defined $schemaList) { my $err = SCR->Error(".ldapserver"); $err->{'code'} = "SCR_READ_FAILED"; - return $self->SetError(%{$err}); + $self->SetError(%{$err}); + return undef; } return $schemaList; } Modified: trunk/ldap-server/src/agent/SlapdConfigAgent.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/agent/SlapdConfigAgent.cc?rev=50990&r1=50989&r2=50990&view=diff ============================================================================== --- trunk/ldap-server/src/agent/SlapdConfigAgent.cc (original) +++ trunk/ldap-server/src/agent/SlapdConfigAgent.cc Wed Sep 10 18:09:57 2008 @@ -80,37 +80,43 @@ y2milestone("Path %s Length %ld ", path->toString().c_str(), path->length()); y2milestone("Component %s ", path->component_str(0).c_str()); - - if ( path->length() < 1 ) { - return YCPNull(); - } - else if ( path->component_str(0) == "global" ) - { - y2milestone("Global read"); - return ReadGlobal(path->at(1), arg, opt); - } - else if ( path->component_str(0) == "databases" ) - { - y2milestone("read databases"); - return ReadDatabases(path->at(1), arg, opt); - } - else if ( path->component_str(0) == "schemaList" ) - { - y2milestone("read schemalist"); - return ReadSchemaList(path->at(1), arg, opt); - } - else if ( path->component_str(0) == "schema" ) - { - return ReadSchema( path->at(1), arg, opt ); - } - else if ( path->component_str(0) == "database" ) - { - y2milestone("read database"); - return ReadDatabase(path->at(1), arg, opt); - } - else if ( path->component_str(0) == "configAsLdif" ) - { - return ConfigToLdif(); + + try { + if ( path->length() < 1 ) { + return YCPNull(); + } + else if ( path->component_str(0) == "global" ) + { + y2milestone("Global read"); + return ReadGlobal(path->at(1), arg, opt); + } + else if ( path->component_str(0) == "databases" ) + { + y2milestone("read databases"); + return ReadDatabases(path->at(1), arg, opt); + } + else if ( path->component_str(0) == "schemaList" ) + { + y2milestone("read schemalist"); + return ReadSchemaList(path->at(1), arg, opt); + } + else if ( path->component_str(0) == "schema" ) + { + return ReadSchema( path->at(1), arg, opt ); + } + else if ( path->component_str(0) == "database" ) + { + y2milestone("read database"); + return ReadDatabase(path->at(1), arg, opt); + } + else if ( path->component_str(0) == "configAsLdif" ) + { + return ConfigToLdif(); + } + } catch ( std::runtime_error e ) { + lastError->add(YCPString("summary"), YCPString(std::string( e.what() ) ) ); + lastError->add(YCPString("description"), YCPString("") ); + return YCPBoolean(false); } return YCPNull(); } @@ -122,34 +128,39 @@ { y2milestone("Path %s Length %ld ", path->toString().c_str(), path->length()); - - if ( path->component_str(0) == "global" ) - { - y2milestone("Global Write"); - return WriteGlobal(path->at(1), arg, arg2); - } - else if ( (path->component_str(0) == "database") && (path->length() > 1) ) - { - y2milestone("Database Write"); - return WriteDatabase(path->at(1), arg, arg2); - } - else if ( path->component_str(0) == "schema" ) - { - y2milestone("Schema Write"); - return WriteSchema(path->at(1), arg, arg2); - } - else if ( path->component_str(0) == "sambaACLHack" ) - { - // FIXME: remove this, when ACL support in WriteDatabase() is implemented - y2error("Warning: sambaACL is currently not implemented"); - return YCPBoolean(true); - } else { - lastError->add(YCPString("summary"), YCPString("Write Failed") ); - std::string msg = "Unsupported SCR path: `.ldapserver."; - msg += path->toString().c_str(); - msg += "`"; - lastError->add(YCPString("description"), YCPString(msg) ); - return YCPNull(); + try { + if ( path->component_str(0) == "global" ) + { + y2milestone("Global Write"); + return WriteGlobal(path->at(1), arg, arg2); + } + else if ( (path->component_str(0) == "database") && (path->length() > 1) ) + { + y2milestone("Database Write"); + return WriteDatabase(path->at(1), arg, arg2); + } + else if ( path->component_str(0) == "schema" ) + { + y2milestone("Schema Write"); + return WriteSchema(path->at(1), arg, arg2); + } + else if ( path->component_str(0) == "sambaACLHack" ) + { + // FIXME: remove this, when ACL support in WriteDatabase() is implemented + y2error("Warning: sambaACL is currently not implemented"); + return YCPBoolean(true); + } else { + lastError->add(YCPString("summary"), YCPString("Write Failed") ); + std::string msg = "Unsupported SCR path: `.ldapserver."; + msg += path->toString().c_str(); + msg += "`"; + lastError->add(YCPString("description"), YCPString(msg) ); + return YCPNull(); + } + } catch ( std::runtime_error e ) { + lastError->add(YCPString("summary"), YCPString(std::string( e.what() ) ) ); + lastError->add(YCPString("description"), YCPString("") ); + return YCPBoolean(false); } } Modified: trunk/ldap-server/src/lib/slapd-config.cpp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/lib/slapd-config.cpp?rev=50990&r1=50989&r2=50990&view=diff ============================================================================== --- trunk/ldap-server/src/lib/slapd-config.cpp (original) +++ trunk/ldap-server/src/lib/slapd-config.cpp Wed Sep 10 18:09:57 2008 @@ -1455,6 +1455,10 @@ { LDAPSearchResults *sr; LDAPEntry *dbEntry; + if ( ! m_lc ) + { + throw std::runtime_error( "LDAP Connection not initialized" ); + } try { sr = m_lc->search( "cn=config", LDAPConnection::SEARCH_BASE); dbEntry = sr->getNext(); @@ -1473,6 +1477,10 @@ void OlcConfig::setGlobals( OlcGlobalConfig &olcg) { + if ( ! m_lc ) + { + throw std::runtime_error( "LDAP Connection not initialized" ); + } try { LDAPModList ml = olcg.entryDifftoMod(); m_lc->modify( olcg.getDn(), &ml ); @@ -1528,6 +1536,10 @@ OlcDatabaseList OlcConfig::getDatabases() { OlcDatabaseList res; + if ( ! m_lc ) + { + throw std::runtime_error( "LDAP Connection not initialized" ); + } try { LDAPSearchResults *sr = m_lc->search( "cn=config", LDAPConnection::SEARCH_ONE, "objectclass=olcDatabaseConfig" ); @@ -1558,6 +1570,10 @@ OlcSchemaList OlcConfig::getSchemaNames() { OlcSchemaList res; + if ( ! m_lc ) + { + throw std::runtime_error( "LDAP Connection not initialized" ); + } try { StringList attrs; LDAPSearchResults *sr = m_lc->search( "cn=schema,cn=config", -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org