[yast-commit] r59818 - in /branches/SuSE-Code-11-SP1-Branch/ldap-server/src: LdapServer.pm dialogs.ycp

Author: rhafer Date: Fri Nov 27 11:36:33 2009 New Revision: 59818 URL: http://svn.opensuse.org/viewcvs/yast?rev=59818&view=rev Log: Refuse master setup if fqdn cannot be resolved (bnc#557773) in cn=config replication the master must contain a syncrepl statement pointing to itself. slapd on the master will ignore that syncrepl statement, for that to work the hostname needs to be resolvable. Otherwise the master will think it's a slave and refuses to accept modifications. Modified: branches/SuSE-Code-11-SP1-Branch/ldap-server/src/LdapServer.pm branches/SuSE-Code-11-SP1-Branch/ldap-server/src/dialogs.ycp Modified: branches/SuSE-Code-11-SP1-Branch/ldap-server/src/LdapServer.pm URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/ldap-s... ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/ldap-server/src/LdapServer.pm (original) +++ branches/SuSE-Code-11-SP1-Branch/ldap-server/src/LdapServer.pm Fri Nov 27 11:36:33 2009 @@ -35,6 +35,7 @@ my %error = ( msg => undef, details => undef ); my $ssl_check_command = "/usr/lib/YaST2/bin/ldap-server-ssl-check"; my $usingDefaults = 1; +my $fqdn = ""; my $readConfig = 0; my $restartRequired = 0; my $configured = 0; @@ -324,6 +325,28 @@ } ## + # @return the full qualified hostname of the machine or "" if not set + # +BEGIN { $TYPEINFO{ReadHostnameFQ} = ["function", "string"]; } +sub ReadHostnameFQ() +{ + if ( $fqdn eq "" ) + { + my $rc = SCR->Execute( '.target.bash_output', "/bin/hostname -f" ); + if ( $rc->{'stdout'} eq "" ) + { + y2milestone("could determine fqdn, hostname -f returned: ". $rc->{'stderr'} ); + } + else + { + $fqdn = $rc->{'stdout'}; + chomp($fqdn); + } + } + return $fqdn; +} + +## # @return Set base DN that shoudl we written to /etc/openldap/ldap.conf # BEGIN { $TYPEINFO{WriteLdapConfBase} = ["function", "boolean", "string"]; } @@ -1598,6 +1621,7 @@ my $domain = $rc->{"stdout"}; if ( $domain eq "" ) { + y2milestone("\"hostname -d\" returned: \"". $rc->{'stderr'} . "\" falling back to default"); $domain = "site"; } chomp($domain); @@ -1748,13 +1772,17 @@ my $syncpw = GenerateRandPassword(); my $syncdn = "uid=syncrepl,ou=system,".$dbDefaults{'suffix'}; - my $rc = SCR->Execute( '.target.bash_output', "/bin/hostname -f" ); - my $fqdn = $rc->{"stdout"}; - chomp($fqdn); + my $hostname = $self->ReadHostnameFQ(); + if ( $hostname eq "" ) + { + $self->SetError( _("Could not determine own full qualified hostname"), + _("A master server for replication cannot work correctly without knowing the own full qualified hostname") ); + return 0; + } my $syncrepl = { "provider" => { "protocol" => "ldap", - "target" => $fqdn, + "target" => $hostname, "port" => YaST::YCP::Integer(389) }, "type" => "refreshAndPersist", Modified: branches/SuSE-Code-11-SP1-Branch/ldap-server/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/ldap-s... ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/ldap-server/src/dialogs.ycp (original) +++ branches/SuSE-Code-11-SP1-Branch/ldap-server/src/dialogs.ycp Fri Nov 27 11:36:33 2009 @@ -335,8 +335,19 @@ } else if (UI::QueryWidget( `id( `rbg_servertype ), `CurrentButton) == `rb_master ) { - LdapServer::WriteSetupMaster(true); - LdapServer::WriteSetupSlave(false); + if ( size( LdapServer::ReadHostnameFQ() ) == 0 ) + { + Popup::Notify(_("YaST was not able to determine the full qualified hostname of this\ncomputer. ") + + _("Setting up a replication master it not possible currently.") ); + UI::ChangeWidget( `rb_master, `Enabled, false ); + UI::ChangeWidget( `rbg_servertype, `CurrentButton, `rb_standalone ); + continue; + } + else + { + LdapServer::WriteSetupMaster(true); + LdapServer::WriteSetupSlave(false); + } } else { -- 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