[yast-commit] r48644 - in /trunk/ldap-server/src: LdapServer.pm agent/SlapdConfigAgent.cc complex.ycp wizards.ycp
Author: rhafer Date: Fri Jun 27 16:00:17 2008 New Revision: 48644 URL: http://svn.opensuse.org/viewcvs/yast?rev=48644&view=rev Log: Reworked migration wizard (slapd.conf -> back-config) Modified: trunk/ldap-server/src/LdapServer.pm trunk/ldap-server/src/agent/SlapdConfigAgent.cc trunk/ldap-server/src/complex.ycp trunk/ldap-server/src/wizards.ycp Modified: trunk/ldap-server/src/LdapServer.pm URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/LdapServer.pm?rev=48644&r1=48643&r2=48644&view=diff ============================================================================== --- trunk/ldap-server/src/LdapServer.pm (original) +++ trunk/ldap-server/src/LdapServer.pm Fri Jun 27 16:00:17 2008 @@ -34,6 +34,7 @@ my $slapdConfChanged = 0; my $serviceEnabled = 0; my $registerSlp = 0; +my $useLdapiForConfig = 0; my %dbDefaults = (); my @databases = (); @@ -304,6 +305,15 @@ y2milestone(); return 0; } + +BEGIN { $TYPEINFO {UseLdapiForConfig} = ["function", "boolean", "boolean"]; } +sub UseLdapiForConfig +{ + my $self = shift; + $useLdapiForConfig = shift; + return 1; +} + BEGIN { $TYPEINFO {ReadServiceEnabled} = ["function", "boolean"]; } sub ReadServiceEnabled { y2milestone("ReadServiceEnabled $serviceEnabled"); @@ -347,7 +357,6 @@ { my $self = shift; my ( $msg, $details ) = @_; - y2milestone("Error: $msg, $details"); $error{'msg'} = $msg; $error{'details'} = $details; } @@ -424,8 +433,10 @@ my $self = shift; my $progressItems = [ _("Cleaning up directory for config database"), _("Converting slapd.conf to config database"), - _("Switching startup configuration to use config database")]; + _("Switching startup configuration to use config database"), + _("Restarting LDAP Server") ]; Progress->New("Migrating LDAP Server Configuration", "Blub", 3, $progressItems, $progressItems, ""); + Progress->NextStage(); Progress->NextStage(); @@ -448,6 +459,37 @@ Progress->Finish(); return 0; } + if ( $useLdapiForConfig ) + { + $rc = SCR->Write('.sysconfig.openldap.OPENLDAP_START_LDAPI', 'yes'); + if ( ! $rc ) + { + y2error("Error while enabling LDAPI listener"); + $self->SetError( _("Enabling LDAPI listener failed.") ); + Progress->Finish(); + return 0; + } + $rc = SCR->Execute('.ldapserver.addRootSaslRegexp'); + if ( ! $rc ) + { + y2error("Error while creating SASL Auth mapping for \"root\"."); + $self->SetError( _("Enabling LDAPI listener failed.") ); + Progress->Finish(); + return 0; + } + } + # FIXME: + # Explicit cache flush, see bnc#350581 for details + SCR->Write(".sysconfig.openldap", undef); + Progress->NextStage(); + $rc = Service->Restart("ldap"); + if (! $rc ) + { + y2error("Error while starting the LDAP service"); + $self->SetError( _("Starting the LDAP service failed.") ); + Progress->Finish(); + return 0; + } Progress->Finish(); return 1; } Modified: trunk/ldap-server/src/agent/SlapdConfigAgent.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/agent/SlapdConfigAgent.cc?rev=48644&r1=48643&r2=48644&view=diff ============================================================================== --- trunk/ldap-server/src/agent/SlapdConfigAgent.cc (original) +++ trunk/ldap-server/src/agent/SlapdConfigAgent.cc Fri Jun 27 16:00:17 2008 @@ -240,6 +240,35 @@ } } } + else if ( path->component_str(0) == "addRootSaslRegexp" ) + { + std::string filename = "/etc/openldap/slapd.d/cn=config.ldif"; + std::ifstream ldifFile(filename.c_str()); + try { + LdifReader ldif(ldifFile); + if ( ldif.readNextRecord() ) + { + LDAPEntry entry, oldEntry; + entry = ldif.getEntryRecord(); + entry.addAttribute( + LDAPAttribute( "olcAuthzRegexp", + "gidNumber=0\\+uidNumber=0,cn=peercred,cn=external,cn=auth dn:cn=config") + ); + ldifFile.close(); + std::ofstream oldifFile(filename.c_str(), std::ios::out|std::ios::trunc); + LdifWriter oldif(oldifFile); + oldif.writeRecord(entry); + oldifFile.close(); + } + return YCPBoolean(true); + } catch ( std::runtime_error e ) { + lastError->add(YCPString("summary"), + YCPString("Error while parsing LDIF file") ); + lastError->add(YCPString("description"), + YCPString(std::string( e.what() ) ) ); + return YCPBoolean(false); + } + } return YCPBoolean(true); } Modified: trunk/ldap-server/src/complex.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/complex.ycp?rev=48644&r1=48643&r2=48644&view=diff ============================================================================== --- trunk/ldap-server/src/complex.ycp (original) +++ trunk/ldap-server/src/complex.ycp Fri Jun 27 16:00:17 2008 @@ -162,6 +162,88 @@ string configFile = "/etc/openldap/slapd.conf"; if ( !hasBackconfig && configModified ) { + return `migrate; + + } + else if (! configModified ) + { + // Start new config wizward + LdapServer::InitDbDefaults(); + return `initial; + } + + return `next; +} + +symbol MigrationMainDialog() +{ + string caption = "Migrate existing Configuration"; + string summary = _("Your system is currently configured to use the configuration +file /etc/openldap/slapd.conf. This YaST module does only support the dynamich +configuration database of OpenLDAP (back-config). Do you want to migrate your +existing configuration to the configuration database?"); + term contents = + `VBox( + `HSquash( + `RadioButtonGroup( + `id( `rb ), + `VBox( + `Label( summary ), + `Left( + `RadioButton( `id( 0 ), _("Migrate existing configuration"), true ) + ), + `Left( + `RadioButton( `id( 1 ), _("Create a new configuration from scratch") ) + ) + ) + ) + ) + ); + + Wizard::SetContentsButtons(caption, contents, HELPS["summary"]:"", + Label::BackButton(), Label::NextButton()); + symbol ret = `next; + while(true) { + ret = (symbol)UI::UserInput(); + + /* abort? */ + if (ret == `abort || ret == `cancel ) + { + if(ReallyAbort()) + { + break; + } + else + { + continue; + } + } + else if ( ret == `next ) + { + integer current = (integer) UI::QueryWidget(`id(`rb), `CurrentButton); + if ( current == 0 ) + { + ret = `next; + } + else + { + ret = `initial; + } + break; + } + else if ( ret == `back ) + { + break; + } + else { + y2error("unexpected retcode: %1", ret); + continue; + } + } + + return ret; + +/* switchToBackConfig = Popup::ContinueCancelHeadline( _("Convert to \"Back-Config\"?"), _("Your system is currently configured to use the configuration file /etc/openldap/slapd.conf. This YaST @@ -193,17 +275,126 @@ { return `abort; } +*/ +} + +symbol MigrationDialog() +{ + string caption = "Migrate existing Configuration"; + string summary = _("In order to access the server configration after the migration you need +to configure how YaST should authenticate against the configuration database."); + list enc_types = [ + `item( `id( "CRYPT" ), "CRYPT" ), + `item( `id( "SMD5" ), "SMD5" ), + `item( `id( "SHA" ), "SHA" ), + `item( `id( "SSHA" ), "SSHA", true ), + `item( `id( "PLAIN" ), "PLAIN" ) + ]; + term contents = + `VBox( + `HSquash( + `RadioButtonGroup( `id( `rb ), + `VBox( + `Label( summary ), + `Left( + `RadioButton( `id( `rb_ldapi ), `opt(`notify), + _("Access the Server via LDAP over Unix Domain Sockets (ldapi) +and give \"root\" full access to the configuration."), true ) + ), + `Left( + `RadioButton( `id( `rb_passwd ), `opt(`notify), + _("Use a \"normal\" encrypted LDAP connection with LDAP +simple authentication.") ) + ), + `Left( + `Label( `id( `lab_pw ), _("Please set a password of the configuration user (cn=config)") ) + ), + `Password( `id( `te_rootpw ), _("New &Password") ), + `HSpacing( 0.5 ), + `Password( `id( `te_valid_rootpw ), _("&Validate Password") ), + `HSpacing( 0.5 ), + `ComboBox( `id( `cb_cryptmethod ), _("Password &Encryption"), enc_types ) + ) + ) + ) + ); + + Wizard::SetContentsButtons(caption, contents, HELPS["summary"]:"", + Label::BackButton(), Label::NextButton()); + + UI::ChangeWidget( `lab_pw , `Enabled, false ); + UI::ChangeWidget( `te_rootpw , `Enabled, false ); + UI::ChangeWidget( `te_valid_rootpw , `Enabled, false ); + UI::ChangeWidget( `cb_cryptmethod , `Enabled, false ); + symbol ret = `next; + while(true) { + ret = (symbol)UI::UserInput(); + + /* abort? */ + if (ret == `abort || ret == `cancel ) + { + if(ReallyAbort()) + { + break; + } + else + { + continue; + } + } + else if ( ret == `next ) + { + symbol current = (symbol) UI::QueryWidget(`id(`rb), `CurrentButton); + if ( current == `rb_ldapi ) + { + LdapServer::UseLdapiForConfig( true ); + ret = `next; + } + else + { + ret = `initial; + } + break; + } + else if ( ret == `back ) + { + break; + } + else if ( ret == `rb_ldapi ) + { + UI::ChangeWidget( `lab_pw , `Enabled, false ); + UI::ChangeWidget( `te_rootpw , `Enabled, false ); + UI::ChangeWidget( `te_valid_rootpw , `Enabled, false ); + UI::ChangeWidget( `cb_cryptmethod , `Enabled, false ); + } + else if ( ret == `rb_passwd ) + { + UI::ChangeWidget( `lab_pw , `Enabled, true ); + UI::ChangeWidget( `te_rootpw , `Enabled, true ); + UI::ChangeWidget( `te_valid_rootpw , `Enabled, true ); + UI::ChangeWidget( `cb_cryptmethod , `Enabled, true ); + } + else + { + y2error("unexpected retcode: %1", ret); + continue; + } } - else if (! configModified ) + + return ret; +} + +symbol DoMigration() +{ + if (! LdapServer::MigrateSlapdConf()) { - // Start new config wizward - LdapServer::InitDbDefaults(); - return `initial; + y2milestone("LdapServer::MigrateSlapdConf failed"); + DisplayError( LdapServer::GetError() ); + return `abort; } - + LdapServer::Read(); return `next; } - /** * Write settings dialog * @return `abort if aborted and `next otherwise @@ -234,7 +425,7 @@ term contents = `VBox( `RichText( summary ), - `Right( + `Right( `PushButton( `id(`pb_advanced), _("Advanced Configuration") ) ) ); Modified: trunk/ldap-server/src/wizards.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ldap-server/src/wizards.ycp?rev=48644&r1=48643&r2=48644&view=diff ============================================================================== --- trunk/ldap-server/src/wizards.ycp (original) +++ trunk/ldap-server/src/wizards.ycp Fri Jun 27 16:00:17 2008 @@ -101,6 +101,51 @@ return ret; } +any MigrateSequence() { + + /* Initialization dialog caption */ + string caption = _("LDAP Server Configuration"); + /* Initialization dialog contents */ + term contents = `Label(_("Initializing...")); + + + map aliases = $[ + "startup" : ``( MigrationMainDialog() ), + "proposal" : ``( ProposalSequence() ), + "authconfig" : ``( MigrationDialog() ), + "migrate" : ``( DoMigration() ) + ]; + + map sequence = $[ + "ws_start" : "startup", + "startup" : $[ + `abort : `abort, + `next : "authconfig", + `initial : "proposal" + ], + "authconfig" : $[ + `next : "migrate" + ], + "migrate" : $[ + `next : `next + ], + "proposal" : $[ + `next : `next + ] + ]; + + y2milestone( "--> starting MigrateSequence" ); + + Wizard::CreateDialog(); + any ret = Sequencer::Run(aliases, sequence); + + y2milestone( "--> MigrateSequence finished " ); + + UI::CloseDialog(); + + return ret; +} + /** * Whole configuration of ldap-server * @return sequence result @@ -109,6 +154,7 @@ map aliases = $[ "read" : ``( ReadDialog() ), + "migrate" : ``( MigrateSequence() ), "propose" : ``( ProposalSequence() ), "main" : ``( MainSequence() ), "write" : ``( WriteDialog() ) @@ -119,8 +165,14 @@ "read" : $[ `abort : `abort, `initial : "propose", + `migrate : "migrate", `next : "main" ], + "migrate" : $[ + `abort : `abort, + `initial : "propose", + `next : "main" + ], "propose" : $[ `next : `next, `abort : `abort -- 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