Author: rhafer Date: Fri Jun 27 16:00:20 2008 New Revision: 48645 URL: http://svn.opensuse.org/viewcvs/yast?rev=48645&view=rev Log: Don't crash on missing keys in the db-Maps Modified: trunk/ldap-server/src/agent/SlapdConfigAgent.cc Modified: trunk/ldap-server/src/agent/SlapdConfigAgent.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/agent/SlapdConfig... ============================================================================== --- trunk/ldap-server/src/agent/SlapdConfigAgent.cc (original) +++ trunk/ldap-server/src/agent/SlapdConfigAgent.cc Fri Jun 27 16:00:20 2008 @@ -199,10 +199,26 @@ { boost::shared_ptr<OlcBdbDatabase> db(new OlcBdbDatabase() ); db->setIndex(i); - db->setSuffix(dbMap->value(YCPString("suffix"))->asString()->value_cstr()); - db->setRootDn(dbMap->value(YCPString("rootdn"))->asString()->value_cstr()); - db->setDirectory(dbMap->value(YCPString("directory"))->asString()->value_cstr()); -// db->setRootPw(dbMap->value(YCPString("rootpw"))->asString()->toString()); + YCPMapIterator j = dbMap.begin(); + for ( ; j != dbMap.end(); j++ ) + { + if ( std::string("suffix") == j.key()->asString()->value_cstr() ) + { + db->setSuffix( j.value()->asString()->value_cstr() ); + } + else if (std::string("rootdn") == j.key()->asString()->value_cstr() ) + { + db->setRootDn( j.value()->asString()->value_cstr() ); + } + else if (std::string("rootpw") == j.key()->asString()->value_cstr() ) + { + db->setRootPw( j.value()->asString()->value_cstr() ); + } + else if (std::string("directory") == j.key()->asString()->value_cstr() ) + { + db->setDirectory( j.value()->asString()->value_cstr() ); + } + } databases.push_back(db); } else @@ -210,9 +226,22 @@ y2error("Database Type \"%s\" not supported. Trying to use generic Database class", dbtype.c_str()); boost::shared_ptr<OlcDatabase> db(new OlcDatabase(dbtype.c_str()) ); db->setIndex(i); -// db->setSuffix(dbMap->value(YCPString("suffix"))->asString()->value_cstr()); - db->setRootDn(dbMap->value(YCPString("rootdn"))->asString()->value_cstr()); - db->setRootPw(dbMap->value(YCPString("rootpw"))->asString()->value_cstr()); + YCPMapIterator j = dbMap.begin(); + for ( ; j != dbMap.end(); j++ ) + { + if ( std::string("suffix") == j.key()->asString()->value_cstr() ) + { + db->setSuffix( j.value()->asString()->value_cstr() ); + } + else if (std::string("rootdn") == j.key()->asString()->value_cstr() ) + { + db->setRootDn( j.value()->asString()->value_cstr() ); + } + else if (std::string("rootpw") == j.key()->asString()->value_cstr() ) + { + db->setRootPw( j.value()->asString()->value_cstr() ); + } + } databases.push_back(db); } } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org