[yast-commit] r48640 - in /trunk/ldap-server/src: LdapServer.pm agent/SlapdConfigAgent.cc lib/backConfigTest.cpp lib/backConfigTest.h tree_structure.ycp
Author: rhafer Date: Fri Jun 27 16:00:01 2008 New Revision: 48640 URL: http://svn.opensuse.org/viewcvs/yast?rev=48640&view=rev Log: - brought back ppolicy support - some cleanup Modified: trunk/ldap-server/src/LdapServer.pm trunk/ldap-server/src/agent/SlapdConfigAgent.cc trunk/ldap-server/src/lib/backConfigTest.cpp trunk/ldap-server/src/lib/backConfigTest.h trunk/ldap-server/src/tree_structure.ycp Modified: trunk/ldap-server/src/LdapServer.pm URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/LdapServer.pm?rev... ============================================================================== --- trunk/ldap-server/src/LdapServer.pm (original) +++ trunk/ldap-server/src/LdapServer.pm Fri Jun 27 16:00:01 2008 @@ -582,10 +582,44 @@ return $rc; } -BEGIN { $TYPEINFO {AddPasswordPolicy} = ["function", "boolean" , "integer", ["map", "string", "string" ] ]; } +BEGIN { $TYPEINFO {GetOverlayList} = ["function", [ "list", [ "map" , "string", "string"] ], "integer" ]; } +sub GetOverlayList +{ + my ($self, $index) = @_; + y2milestone("GetOverlayList ", $index); + my $rc = SCR->Read(".ldapserver.database.{".$index."}.overlays" ); + y2milestone( "Overlays: ".Data::Dumper->Dump([$rc]) ); + return $rc; +} + +BEGIN { $TYPEINFO {GetPpolicyOverlay} = ["function", [ "map" , "string", "any" ], "integer" ]; } +sub GetPpolicyOverlay +{ + my ($self, $index) = @_; + y2milestone("GetPpolicyOverlay ", $index); + my $rc = SCR->Read(".ldapserver.database.{".$index."}.ppolicy" ); + y2milestone( "Ppolicy: ".Data::Dumper->Dump([$rc]) ); + if ( defined $rc->{'hashClearText'} ) + { + $rc->{'hashClearText'} = YaST::YCP::Boolean($rc->{'hashClearText'}); + } + if ( defined $rc->{'useLockout'} ) + { + $rc->{'useLockout'} = YaST::YCP::Boolean($rc->{'useLockout'}); + } + return $rc; +} + +BEGIN { $TYPEINFO {AddPasswordPolicy} = ["function", "boolean" , "integer", ["map", "string", "any" ] ]; } sub AddPasswordPolicy { my ($self, $dbIndex, $ppolicy ) = @_; + y2milestone("AddPasswordPolicy: ".Data::Dumper->Dump([$ppolicy])." ". scalar(keys %{$ppolicy}) ); + if ( 0 < scalar(keys %{$ppolicy}) ) + { + $ppolicy->{'hashClearText'} = YaST::YCP::Boolean($ppolicy->{'hashClearText'}); + $ppolicy->{'useLockout'} = YaST::YCP::Boolean($ppolicy->{'useLockout'}); + } if ( ! SCR->Write(".ldapserver.database.{".$dbIndex."}.ppolicy", $ppolicy ) ) { my $err = SCR->Error(".ldapserver"); $self->SetError( $err->{'summary'}, $err->{'description'} ); 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:01 2008 @@ -226,6 +226,12 @@ for ( i = databases.begin(); i != databases.end() ; i++ ) { olc.updateEntry(**i); + OlcOverlayList overlays = (*i)->getOverlays(); + OlcOverlayList::const_iterator k; + for ( k = overlays.begin(); k != overlays.end(); k++ ) + { + olc.updateEntry(**k); + } } OlcSchemaList::const_iterator j; for ( j = schema.begin(); j != schema.end() ; j++ ) @@ -391,26 +397,84 @@ } else { std::string dbComponent = path->component_str(1); y2milestone("Component %s ", dbComponent.c_str()); - IndexMap idx = (*i)->getDatabaseIndexes(); - IndexMap::const_iterator j = idx.begin(); - for ( ; j != idx.end(); j++ ) - { - YCPMap ycpIdx; - y2milestone("indexed Attribute: \"%s\"", j->first.c_str() ); - std::vector<IndexType>::const_iterator k = j->second.begin(); - for ( ; k != j->second.end(); k++ ) + if ( dbComponent == "indexes" ) + { + IndexMap idx = (*i)->getDatabaseIndexes(); + IndexMap::const_iterator j = idx.begin(); + for ( ; j != idx.end(); j++ ) { - if ( *k == Eq ){ - ycpIdx.add(YCPString("eq"), YCPBoolean(true) ); - } else if ( *k == Present ){ - ycpIdx.add(YCPString("pres"), YCPBoolean(true) ); - } else if ( *k == Sub ){ - ycpIdx.add(YCPString("sub"), YCPBoolean(true) ); + YCPMap ycpIdx; + y2milestone("indexed Attribute: \"%s\"", j->first.c_str() ); + std::vector<IndexType>::const_iterator k = j->second.begin(); + for ( ; k != j->second.end(); k++ ) + { + if ( *k == Eq ){ + ycpIdx.add(YCPString("eq"), YCPBoolean(true) ); + } else if ( *k == Present ){ + ycpIdx.add(YCPString("pres"), YCPBoolean(true) ); + } else if ( *k == Sub ){ + ycpIdx.add(YCPString("sub"), YCPBoolean(true) ); + } } + resMap.add( YCPString(j->first), ycpIdx ); } - resMap.add( YCPString(j->first), ycpIdx ); + return resMap; + } + else if ( dbComponent == "overlays" ) + { + OlcOverlayList overlays = (*i)->getOverlays(); + OlcOverlayList::const_iterator j = overlays.begin(); + YCPList resList; + for (; j != overlays.end(); j++ ) + { + y2milestone("Overlay: %s", (*j)->getType().c_str() ); + YCPMap overlayMap; + overlayMap.add( YCPString("type"), YCPString( (*j)->getType() ) ); + overlayMap.add( YCPString("index"), YCPInteger( (*j)->getEntryIndex() ) ); + resList.add(overlayMap); + } + return resList; + } + else if ( dbComponent == "ppolicy" ) + { + OlcOverlayList overlays = (*i)->getOverlays(); + OlcOverlayList::const_iterator j = overlays.begin(); + YCPList resList; + for (; j != overlays.end(); j++ ) + { + if ( (*j)->getType() == "ppolicy" ) + { + resMap.add(YCPString("defaultPolicy"), + YCPString((*j)->getStringValue("olcPpolicyDefault") ) ); + if ( (*j)->getStringValue("olcPPolicyHashCleartext") == "TRUE" ) + { + resMap.add(YCPString("hashClearText"), YCPBoolean(true) ); + } + else + { + resMap.add(YCPString("hashClearText"), YCPBoolean(false) ); + } + if ( (*j)->getStringValue("olcPPolicyUseLockout") == "TRUE" ) + { + resMap.add(YCPString("useLockout"), YCPBoolean(true) ); + } + else + { + resMap.add(YCPString("useLockout"), YCPBoolean(false) ); + } + break; + } + } + return resMap; + } + else + { + lastError->add(YCPString("summary"), YCPString("Read Failed") ); + std::string msg = "Unsupported SCR path: `.ldapserver.database."; + msg += path->toString().c_str(); + msg += "`"; + lastError->add(YCPString("description"), YCPString(msg) ); } - return resMap; } } } @@ -672,7 +736,47 @@ (*i)->addIndex(attr, idx); } ret = true; - } else { + } + else if (dbComponent == "ppolicy" ) + { + OlcOverlayList overlays = (*i)->getOverlays(); + OlcOverlayList::const_iterator j = overlays.begin(); + for (; j != overlays.end(); j++ ) + { + if ( (*j)->getType() == "ppolicy" ) + { + YCPMap argMap = arg->asMap(); + y2milestone("Mapsize: %d", argMap.size()); + if ( argMap.size() == 0 ){ + y2milestone("Delete ppolicy overlay"); + (*j)->clearChangedEntry(); + } else { + (*j)->setStringValue("olcPpolicyDefault", + argMap->value(YCPString("defaultPolicy"))->asString()->value_cstr() ); + if ( argMap->value(YCPString("useLockout"))->asBoolean()->value() == true ) + { + (*j)->setStringValue("olcPpolicyUseLockout", "TRUE"); + } + else + { + (*j)->setStringValue("olcPpolicyUseLockout", "FALSE"); + } + if ( argMap->value(YCPString("hashClearText"))->asBoolean()->value() == true ) + { + (*j)->setStringValue("olcPpolicyHashCleartext", "TRUE"); + } + else + { + (*j)->setStringValue("olcPpolicyHashCleartext", "FALSE"); + } + } + break; + } + } + ret = true; + } + else + { lastError->add(YCPString("summary"), YCPString("Write Failed") ); std::string msg = "Unsupported SCR path: `.ldapserver.database."; msg += path->toString().c_str(); @@ -772,7 +876,7 @@ y2milestone("Comment or empty" ); continue; } - int pos=schemaLine.find_last_not_of(" \t\n"); + std::string::size_type pos=schemaLine.find_last_not_of(" \t\n"); if (pos != std::string::npos ) schemaLine.erase(pos+1, std::string::npos ); Modified: trunk/ldap-server/src/lib/backConfigTest.cpp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/lib/backConfigTes... ============================================================================== --- trunk/ldap-server/src/lib/backConfigTest.cpp (original) +++ trunk/ldap-server/src/lib/backConfigTest.cpp Fri Jun 27 16:00:01 2008 @@ -13,6 +13,22 @@ return toupper(c1) == toupper(c2); } +static int splitIndexFromString(const std::string &in, std::string &out) +{ + int index=0; + if ( in[0] == '{' ) + { + std::string::size_type pos = in.find('}'); + std::istringstream indexstr(in.substr(1, pos-1)); + indexstr >> index; + out = in.substr( pos+1, std::string::npos ); + } else { + out = in; + index = 0; + } + return index; +} + static bool strCaseIgnoreEquals(const std::string &s1, const std::string &s2) { if(s1.size() == s2.size()){ @@ -27,16 +43,7 @@ OlcDatabase::OlcDatabase( const LDAPEntry& le=LDAPEntry()) : OlcConfigEntry(le) { std::string type(this->getStringValue("olcdatabase")); - if ( type[0] == '{' ) - { - std::string::size_type pos = type.find('}'); - std::istringstream indexstr(type.substr(1, pos-1)); - indexstr >> entryIndex; - m_type = type.substr( pos+1, std::string::npos ); - } else { - m_type = type; - entryIndex = 0; - } + entryIndex = splitIndexFromString( type, m_type ); } OlcDatabase::OlcDatabase( const std::string& type ) : m_type(type) @@ -364,16 +371,7 @@ { std::cout << "OlcSchemaConfig::OlcSchemaConfig(const LDAPEntry &e) : OlcConfigEntry(e)" << std::endl; std::string name(this->getStringValue("cn")); - if ( name[0] == '{' ) - { - std::string::size_type pos = name.find('}'); - std::istringstream indexstr(name.substr(1, pos-1)); - indexstr >> entryIndex; - m_name = name.substr( pos+1, std::string::npos ); - } else { - m_name = name; - entryIndex = 0; - } + entryIndex = splitIndexFromString( name, m_name ); } void OlcSchemaConfig::clearChangedEntry() @@ -395,13 +393,9 @@ for ( j = types.begin(); j != types.end(); j++ ) { LDAPAttrType currentAttr; - if ( (*j)[0] == '{' ) - { - std::string::size_type pos = j->find('}'); - currentAttr = LDAPAttrType( j->substr( pos+1, std::string::npos ) ); - } else { - currentAttr = LDAPAttrType( *j ); - } + std::string tmp; + splitIndexFromString( *j, tmp ); + currentAttr = LDAPAttrType( tmp ); res.push_back(currentAttr); } return res; @@ -418,35 +412,35 @@ tls.applySettings( *this ); } -std::map<std::string, std::list<std::string> > OlcGlobalConfig::toMap() const -{ - std::map<std::string, std::list<std::string> > resMap; - const LDAPAttribute *at = m_dbEntryChanged.getAttributeByName("olcsuffix"); - if ( at ) - { - StringList values = at->getValues(); - StringList::const_iterator j; - std::list<std::string> valList; - for ( j = values.begin(); j != values.end(); j++ ) - { - valList.push_back(*j); - } - resMap.insert(std::make_pair("suffix", valList)); - } - at = m_dbEntryChanged.getAttributeByName("olcDatabase"); - if ( at ) - { - StringList values = at->getValues(); - StringList::const_iterator j; - std::list<std::string> valList; - for ( j = values.begin(); j != values.end(); j++ ) - { - valList.push_back(*j); - } - resMap.insert(std::make_pair("type", valList)); - } - return resMap; -} +//std::map<std::string, std::list<std::string> > OlcGlobalConfig::toMap() const +//{ +// std::map<std::string, std::list<std::string> > resMap; +// const LDAPAttribute *at = m_dbEntryChanged.getAttributeByName("olcsuffix"); +// if ( at ) +// { +// StringList values = at->getValues(); +// StringList::const_iterator j; +// std::list<std::string> valList; +// for ( j = values.begin(); j != values.end(); j++ ) +// { +// valList.push_back(*j); +// } +// resMap.insert(std::make_pair("suffix", valList)); +// } +// at = m_dbEntryChanged.getAttributeByName("olcDatabase"); +// if ( at ) +// { +// StringList values = at->getValues(); +// StringList::const_iterator j; +// std::list<std::string> valList; +// for ( j = values.begin(); j != values.end(); j++ ) +// { +// valList.push_back(*j); +// } +// resMap.insert(std::make_pair("type", valList)); +// } +// return resMap; +//} bool OlcConfigEntry::isDatabaseEntry ( const LDAPEntry& e ) { @@ -529,17 +523,17 @@ } } -std::map<std::string, std::list<std::string> > OlcConfigEntry::toMap() const -{ - std::map<std::string, std::list<std::string> > resMap; -// std::string value = this->getStringValue("olcConcurrency"); -// resMap.insert( std::make_pair( "concurrency", value ) ); +//std::map<std::string, std::list<std::string> > OlcConfigEntry::toMap() const +//{ +// std::map<std::string, std::list<std::string> > resMap; +//// std::string value = this->getStringValue("olcConcurrency"); +//// resMap.insert( std::make_pair( "concurrency", value ) ); +//// +//// value = this->getStringValue("olcThreads"); +//// resMap.insert( std::make_pair("threads", value ) ); // -// value = this->getStringValue("olcThreads"); -// resMap.insert( std::make_pair("threads", value ) ); - - return resMap; -} +// return resMap; +//} void OlcConfigEntry::setIndex( int index ) { @@ -561,37 +555,54 @@ m_dbEntryChanged = LDAPEntry(); } +OlcOverlay* OlcOverlay::createFromLdapEntry( const LDAPEntry& e) +{ + return new OlcOverlay(e); +} -std::map<std::string, std::list<std::string> > OlcDatabase::toMap() const +OlcOverlay::OlcOverlay( const LDAPEntry& e) : OlcConfigEntry(e) { - std::map<std::string, std::list<std::string> > resMap; - const LDAPAttribute *at = m_dbEntryChanged.getAttributeByName("olcsuffix"); - if ( at ) - { - StringList values = at->getValues(); - StringList::const_iterator j; - std::list<std::string> valList; - for ( j = values.begin(); j != values.end(); j++ ) - { - valList.push_back(*j); - } - resMap.insert(std::make_pair("suffix", valList)); - } - at = m_dbEntryChanged.getAttributeByName("olcDatabase"); - if ( at ) - { - StringList values = at->getValues(); - StringList::const_iterator j; - std::list<std::string> valList; - for ( j = values.begin(); j != values.end(); j++ ) - { - valList.push_back(*j); - } - resMap.insert(std::make_pair("type", valList)); - } - return resMap; + std::cerr << "OlcOverlay::OlcOverlay()" << std::endl; + std::string type(this->getStringValue("olcoverlay")); + entryIndex = splitIndexFromString( type, m_type ); +} + +const std::string OlcOverlay::getType() const +{ + return m_type; } + +//std::map<std::string, std::list<std::string> > OlcDatabase::toMap() const +//{ +// std::map<std::string, std::list<std::string> > resMap; +// const LDAPAttribute *at = m_dbEntryChanged.getAttributeByName("olcsuffix"); +// if ( at ) +// { +// StringList values = at->getValues(); +// StringList::const_iterator j; +// std::list<std::string> valList; +// for ( j = values.begin(); j != values.end(); j++ ) +// { +// valList.push_back(*j); +// } +// resMap.insert(std::make_pair("suffix", valList)); +// } +// at = m_dbEntryChanged.getAttributeByName("olcDatabase"); +// if ( at ) +// { +// StringList values = at->getValues(); +// StringList::const_iterator j; +// std::list<std::string> valList; +// for ( j = values.begin(); j != values.end(); j++ ) +// { +// valList.push_back(*j); +// } +// resMap.insert(std::make_pair("type", valList)); +// } +// return resMap; +//} + void OlcDatabase::setSuffix( const std::string &suffix) { this->setStringValue("olcSuffix", suffix); @@ -617,26 +628,36 @@ return this->m_type; } -std::map<std::string, std::list<std::string> > OlcBdbDatabase::toMap() const +void OlcDatabase::addOverlay(boost::shared_ptr<OlcOverlay> overlay) { - std::map<std::string, std::list<std::string> > resMap = - OlcDatabase::toMap(); + m_overlays.push_back(overlay); +} - const LDAPAttribute *at = m_dbEntryChanged.getAttributeByName("olcDbNoSync"); - if ( at ) - { - StringList values = at->getValues(); - StringList::const_iterator j; - std::list<std::string> valList; - for ( j = values.begin(); j != values.end(); j++ ) - { - valList.push_back(*j); - } - resMap.insert(std::make_pair("nosync", valList)); - } - return resMap; +OlcOverlayList& OlcDatabase::getOverlays() +{ + return m_overlays; } +//std::map<std::string, std::list<std::string> > OlcBdbDatabase::toMap() const +//{ +// std::map<std::string, std::list<std::string> > resMap = +// OlcDatabase::toMap(); +// +// const LDAPAttribute *at = m_dbEntryChanged.getAttributeByName("olcDbNoSync"); +// if ( at ) +// { +// StringList values = at->getValues(); +// StringList::const_iterator j; +// std::list<std::string> valList; +// for ( j = values.begin(); j != values.end(); j++ ) +// { +// valList.push_back(*j); +// } +// resMap.insert(std::make_pair("nosync", valList)); +// } +// return resMap; +//} + bool OlcDatabase::isBdbDatabase( const LDAPEntry& e ) { StringList oc = e.getAttributeByName("objectclass")->getValues(); @@ -692,8 +713,16 @@ void OlcConfigEntry::setStringValue(const std::string &type, const std::string &value) { - LDAPAttribute attr(type, value); - m_dbEntryChanged.replaceAttribute(attr); + std::cerr << "setStringValue() " << type << " " << value << std::endl; + if ( value.empty() ) + { + m_dbEntryChanged.delAttribute(type); + } + else + { + LDAPAttribute attr(type, value); + m_dbEntryChanged.replaceAttribute(attr); + } } void OlcConfigEntry::addStringValue(const std::string &type, const std::string &value) @@ -886,10 +915,20 @@ LDAPSearchResults *sr = m_lc->search( "cn=config", LDAPConnection::SEARCH_ONE, "objectclass=olcDatabaseConfig" ); LDAPEntry *dbEntry; - while ( dbEntry = sr->getNext() ) + while ( (dbEntry = sr->getNext()) != 0 ) { - std::cout << "Got Database Entry: " << dbEntry->getDN() << std::endl; + std::string dbDn(dbEntry->getDN()); + std::cout << "Got Database Entry: " << dbDn << std::endl; boost::shared_ptr<OlcDatabase> olce(OlcDatabase::createFromLdapEntry(*dbEntry)); + LDAPSearchResults *overlaySearchRes = m_lc->search( dbDn, + LDAPConnection::SEARCH_ONE, "objectclass=olcOverlayConfig" ); + LDAPEntry *overlayEntry; + while ( (overlayEntry = overlaySearchRes->getNext()) != 0 ) + { + std::cout << "Got Overlay: " << overlayEntry->getDN() << std::endl; + boost::shared_ptr<OlcOverlay> overlay(OlcOverlay::createFromLdapEntry(*overlayEntry) ); + olce->addOverlay(overlay); + } res.push_back(olce); } } catch (LDAPException e ) { Modified: trunk/ldap-server/src/lib/backConfigTest.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/lib/backConfigTes... ============================================================================== --- trunk/ldap-server/src/lib/backConfigTest.h (original) +++ trunk/ldap-server/src/lib/backConfigTest.h Fri Jun 27 16:00:01 2008 @@ -48,11 +48,10 @@ void addStringValue(const std::string &type, const std::string &value); void setIndex( int index ); - void getEntryDn(); int getEntryIndex() const; - virtual std::map<std::string, std::list<std::string> > toMap() const; +// virtual std::map<std::string, std::list<std::string> > toMap() const; virtual std::string toLdif() const; protected: @@ -78,6 +77,18 @@ typedef std::map<std::string, std::vector<IndexType> > IndexMap; +class OlcOverlay : public OlcConfigEntry +{ + public: + static OlcOverlay* createFromLdapEntry( const LDAPEntry& le); + OlcOverlay( const LDAPEntry &le ); + const std::string getType() const; + + protected: + std::string m_type; +}; + +typedef std::list<boost::shared_ptr<OlcOverlay> > OlcOverlayList; class OlcDatabase : public OlcConfigEntry { public : @@ -95,15 +106,19 @@ const std::string getSuffix() const; const std::string getType() const; - virtual std::map<std::string, std::list<std::string> > toMap() const; + //virtual std::map<std::string, std::list<std::string> > toMap() const; virtual IndexMap getDatabaseIndexes() const {}; virtual std::vector<IndexType> getDatabaseIndex( const std::string &attr ) const {}; virtual void addIndex(const std::string& attr, const std::vector<IndexType>& idx) {}; virtual void deleteIndex(const std::string& attr) {}; - + + void addOverlay(boost::shared_ptr<OlcOverlay> overlay); + OlcOverlayList& getOverlays() ; + protected: virtual void updateEntryDn(); std::string m_type; + OlcOverlayList m_overlays; }; @@ -112,7 +127,7 @@ public: OlcBdbDatabase(); OlcBdbDatabase( const LDAPEntry& le ); - virtual std::map<std::string, std::list<std::string> > toMap() const; + //virtual std::map<std::string, std::list<std::string> > toMap() const; void setDirectory( const std::string &dir); virtual IndexMap getDatabaseIndexes() const; @@ -140,7 +155,7 @@ OlcTlsSettings getTlsSettings() const; void setTlsSettings( const OlcTlsSettings& tls); - virtual std::map<std::string, std::list<std::string> > toMap() const; + //virtual std::map<std::string, std::list<std::string> > toMap() const; }; class OlcSchemaConfig : public OlcConfigEntry @@ -191,6 +206,7 @@ typedef std::list<boost::shared_ptr<OlcDatabase> > OlcDatabaseList; typedef std::list<boost::shared_ptr<OlcSchemaConfig> > OlcSchemaList; + class OlcConfig { public: Modified: trunk/ldap-server/src/tree_structure.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/tree_structure.yc... ============================================================================== --- trunk/ldap-server/src/tree_structure.ycp (original) +++ trunk/ldap-server/src/tree_structure.ycp Fri Jun 27 16:00:01 2008 @@ -995,19 +995,21 @@ define boolean cb_read_ppolicy() { y2milestone("cb_read_ppolicy()"); + integer index = (integer)widget_map[current_tree_item,"index"]:nil; // Check for ppolicy overlay - //map<string,string> ppolicy_map = LdapServer::GetPasswordPolicyOverlay(suffix); - string suffix = ""; - map<string,string> ppolicy_map = nil; - if ( ppolicy_map != nil ){ + map<string,any> ppolicy_map = LdapServer::GetPpolicyOverlay(index); + if ( size(ppolicy_map) != 0 ){ UI::ChangeWidget( `cb_ppolicy_overlay, `Value, true ); - string pp_hash_cleartext = ppolicy_map["ppolicy_hash_cleartext"]:nil; - string pp_use_lockout = ppolicy_map["ppolicy_use_lockout"]:nil; - string pp_default = ppolicy_map["ppolicy_default"]:nil; + boolean pp_hash_cleartext = (boolean)ppolicy_map["hashClearText"]:nil; + boolean pp_use_lockout = (boolean)ppolicy_map["useLockout"]:nil; + string pp_default = (string)ppolicy_map["defaultPolicy"]:nil; boolean pp_append_checked = false; + map<string,string> olddb = LdapServer::GetDatabase(index); + string suffix = olddb["suffix"]:""; integer pos = search( pp_default, suffix ); if( pos > -1 ) { + string chkSuffix = substring( pp_default, pos ); if ( chkSuffix == suffix ) { @@ -1015,17 +1017,17 @@ pp_append_checked = true; } } - if ( pp_hash_cleartext != nil ){ + if ( pp_hash_cleartext ){ UI::ChangeWidget( `cb_ppolicy_hashcleartext, `Value, true ); } else { UI::ChangeWidget( `cb_ppolicy_hashcleartext, `Value, false ); } - if ( pp_use_lockout != nil ){ + if ( pp_use_lockout ){ UI::ChangeWidget( `cb_ppolicy_uselockout, `Value, true ); } else { UI::ChangeWidget( `cb_ppolicy_uselockout, `Value, false ); } - if ( pp_default != nil ){ + if ( pp_default != "" ){ UI::ChangeWidget( `te_ppolicy_defaultpolicy, `Value, pp_default ); UI::ChangeWidget( `cb_pp_append_basedn, `Value, pp_append_checked ); } else { @@ -1051,13 +1053,22 @@ boolean hashcleartext = (boolean)UI::QueryWidget( `cb_ppolicy_hashcleartext, `Value ); boolean uselockout = (boolean)UI::QueryWidget( `cb_ppolicy_uselockout, `Value ); string pp_default = (string)UI::QueryWidget( `te_ppolicy_defaultpolicy, `Value ); -// map<string,string> ppolicy_old = LdapServer::GetPasswordPolicyOverlay(suffix); - map<string,string> ppolicy = $[]; - if (hashcleartext ) { - ppolicy = add( ppolicy, "ppolicy_hash_cleartext", ""); + map<string,any> ppolicy = $[]; + if (hashcleartext ) + { + ppolicy = add( ppolicy, "hashClearText", true); + } + else + { + ppolicy = add( ppolicy, "hashClearText", false); + } + if (uselockout) + { + ppolicy = add( ppolicy, "useLockout", true); } - if (uselockout) { - ppolicy = add( ppolicy, "ppolicy_use_lockout", ""); + else + { + ppolicy = add( ppolicy, "useLockout", false); } if (pp_default != "" ) { if( (boolean)UI::QueryWidget( `cb_pp_append_basedn, `Value ) ) @@ -1066,10 +1077,11 @@ string suffix = db["suffix"]:""; pp_default = pp_default+","+suffix; } -// if (pp_default != ppolicy_old["ppolicy_default"]:nil ) { -// db = add(db, "ppolicy_default_changed", "1"); -// } - ppolicy = add( ppolicy, "ppolicy_default", pp_default); + ppolicy = add( ppolicy, "defaultPolicy", pp_default); + } + else + { + ppolicy = add( ppolicy, "defaultPolicy", ""); } y2milestone("Policy: %1", ppolicy); result = LdapServer::AddPasswordPolicy( index, ppolicy ); @@ -1086,6 +1098,13 @@ // LdapServer::WriteSchemaIncludeList(inclist); // } } else { + // delete ppolicy + result = LdapServer::AddPasswordPolicy( index, $[] ); + if ( ! result ) { + map<string, string> err = LdapServer::GetError(); + callback_error = err["msg"]:"" + "\n" + err["details"]:""; + } + // map<string,string> ppolicy_map = LdapServer::GetPasswordPolicyOverlay(suffix); // if ( ppolicy_map != nil ){ // list<any> newoverlay = []; -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
rhafer@svn.opensuse.org