Mailinglist Archive: yast-commit (2114 mails)

< Previous Next >
[yast-commit] r58775 - in /trunk/ldap-server/src/lib: slapd-config.cpp slapd-config.h
  • From: rhafer@xxxxxxxxxxxxxxxx
  • Date: Fri, 25 Sep 2009 12:49:02 -0000
  • Message-id: <E1MrAEQ-0006uK-Qs@xxxxxxxxxxxxxxxx>
Author: rhafer
Date: Fri Sep 25 14:49:02 2009
New Revision: 58775

URL: http://svn.opensuse.org/viewcvs/yast?rev=58775&view=rev
Log:
Additional checks for Schema Entries, to avoid crashes and for more
detailed error messages (bnc#541819)

Modified:
trunk/ldap-server/src/lib/slapd-config.cpp
trunk/ldap-server/src/lib/slapd-config.h

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=58775&r1=58774&r2=58775&view=diff
==============================================================================
--- trunk/ldap-server/src/lib/slapd-config.cpp (original)
+++ trunk/ldap-server/src/lib/slapd-config.cpp Fri Sep 25 14:49:02 2009
@@ -1253,6 +1253,8 @@
tls.applySettings( *this );
}

+const std::string OlcSchemaConfig::schemabase = "cn=schema,cn=config";
+
OlcSchemaConfig::OlcSchemaConfig() : OlcConfigEntry()
{
m_dbEntryChanged.setDN("cn=schema,cn=config");
@@ -1264,6 +1266,21 @@
{
log_it(SLAPD_LOG_INFO, "OlcSchemaConfig::OlcSchemaConfig(const LDAPEntry
&e) : OlcConfigEntry(e)");
std::string name(this->getStringValue("cn"));
+ std::string dn(e.getDN() );
+ if ( name.empty() )
+ {
+ throw std::runtime_error( "Entry '" + dn + "' has no 'cn' Attribute."
);
+ }
+ if ( (dn.size() <= schemabase.size()) ||
+ (dn.compare( dn.size()-schemabase.size(), schemabase.size(),
schemabase )) )
+ {
+ throw std::runtime_error( "Entry '" + dn + "' is not a child of '" +
schemabase + "'." );
+ }
+ if ( this->getStringValues("olcobjectclasses").empty() &&
+ this->getStringValues("olcattributetypes").empty() )
+ {
+ throw std::runtime_error( "Entry '" + dn + "' does not define any
objectclasses or attributetypes." );
+ }
if ( name[0] == '{' )
{
std::string::size_type pos = name.find('}');
@@ -1277,8 +1294,24 @@
}
OlcSchemaConfig::OlcSchemaConfig(const LDAPEntry &e1, const LDAPEntry &e2) :
OlcConfigEntry(e1, e2)
{
- log_it(SLAPD_LOG_INFO, "OlcSchemaConfig::OlcSchemaConfig(const LDAPEntry
&e) : OlcConfigEntry(e)");
+ log_it(SLAPD_LOG_INFO, "OlcSchemaConfig::OlcSchemaConfig(const LDAPEntry
&e1, const LDAPEntry &e2) : OlcConfigEntry(e1, e2)" );
std::string name(this->getStringValue("cn"));
+ std::string dn(e2.getDN() );
+ if ( name.empty() )
+ {
+ throw std::runtime_error( "Entry '" + dn + "' has no 'cn' Attribute."
);
+ }
+ if ( (dn.size() <= schemabase.size()) ||
+ (dn.compare( dn.size()-schemabase.size(), schemabase.size(),
schemabase )) )
+ {
+ throw std::runtime_error( "Entry '" + dn + "' is not a child of '" +
schemabase + "'." );
+ }
+ if ( this->getStringValues("olcobjectclasses").empty() &&
+ this->getStringValues("olcattributetypes").empty() )
+ {
+ throw std::runtime_error( "Entry '" + dn + "' does not define any
objectclasses or attributetypes." );
+ }
+
entryIndex = splitIndexFromString( name, m_name );
}


Modified: trunk/ldap-server/src/lib/slapd-config.h
URL:
http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/lib/slapd-config.h?rev=58775&r1=58774&r2=58775&view=diff
==============================================================================
--- trunk/ldap-server/src/lib/slapd-config.h (original)
+++ trunk/ldap-server/src/lib/slapd-config.h Fri Sep 25 14:49:02 2009
@@ -292,6 +292,7 @@
virtual void clearChangedEntry();
const std::string& getName() const;
const std::vector<LDAPAttrType> getAttributeTypes() const;
+ static const std::string schemabase;

protected:
virtual void updateEntryDn( bool origEntry = false);

--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages