From 8c7a192fe908c28d7e88d3365d34f6780e0e26ec Mon Sep 17 00:00:00 2001 From: rettenbe Date: Tue, 18 Mar 2008 16:07:33 +0000 Subject: [PATCH] addidtional changes for: possible bugfix for uncontrolable re-registering at gosa-si-client git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9931 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-client | 85 ++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index 21a7094c7..d3328ea86 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -706,9 +706,6 @@ sub register_at_gosa_si_server { my $events = join( ",", keys %{$event_hash} ); while(1) { - - if( $try_to_register >= @servers ) { last; } - # fetch first gosa-si-server from @servers my $server = shift(@servers); @@ -724,49 +721,47 @@ sub register_at_gosa_si_server { exit(1); } - # create registration msg - my $local_ip = &get_local_ip_for_remote_ip(sprintf("%s", $server =~ /^([0-9\.]*?):.*$/)); - my $local_mac = &get_local_mac_for_remote_ip(sprintf("%s", $server =~ /^([0-9\.]*?):.*$/)); - my $register_hash = &create_xml_hash("here_i_am", $local_ip.":".$client_port, $server); - &add_content2xml_hash($register_hash, "new_passwd", $server_key); - &add_content2xml_hash($register_hash, "mac_address", $local_mac); - &add_content2xml_hash($register_hash, "events", $events); - &add_content2xml_hash($register_hash, "gotoHardwareChecksum", $gotoHardwareChecksum); - - # Add $HOSTNAME from ENV if force-hostname is set - if( defined($client_force_hostname) && - $client_force_hostname eq "true") { - if(defined($ENV{HOSTNAME}) && - length($ENV{HOSTNAME}) >0 ) { - &add_content2xml_hash($register_hash, "force-hostname", $ENV{HOSTNAME}); - } else { - &main::daemon_log("force-hostname was set to true, but no \$HOSTNAME was found in Environment!",0); - } - } - - # send xml hash to server with general server passwd - my $res = &send_msg_hash_to_target($register_hash, $server, $default_server_key); + # create registration msg + my $local_ip = &get_local_ip_for_remote_ip(sprintf("%s", $server =~ /^([0-9\.]*?):.*$/)); + my $local_mac = &get_local_mac_for_remote_ip(sprintf("%s", $server =~ /^([0-9\.]*?):.*$/)); + my $register_hash = &create_xml_hash("here_i_am", $local_ip.":".$client_port, $server); + &add_content2xml_hash($register_hash, "new_passwd", $server_key); + &add_content2xml_hash($register_hash, "mac_address", $local_mac); + &add_content2xml_hash($register_hash, "events", $events); + &add_content2xml_hash($register_hash, "gotoHardwareChecksum", $gotoHardwareChecksum); + + # Add $HOSTNAME from ENV if force-hostname is set + if( defined($client_force_hostname) && $client_force_hostname eq "true") { + if(defined($ENV{HOSTNAME}) && length($ENV{HOSTNAME}) >0 ) { + &add_content2xml_hash($register_hash, "force-hostname", $ENV{HOSTNAME}); + } else { + &main::daemon_log("force-hostname was set to true, but no \$HOSTNAME was found in Environment!",0); + } + } + + # send xml hash to server with general server passwd + my $res = &send_msg_hash_to_target($register_hash, $server, $default_server_key); - # if delivery of registration msg succeed - if($res == 0) { - # reset try_to_register - $try_to_register = 0; - - # Set fixed client address and mac address - $client_ip= &get_local_ip_for_remote_ip(sprintf("%s", $server =~ /^([0-9\.]*?):.*$/)); - $client_address= "$client_ip:$client_port"; - $client_mac_address = $local_mac; - $client_dnsname = $dnsname; - - last; - - # delivery of registration msg failed - } else { - $try_to_register++; - # wait 1 sec until trying to register again - sleep(1); - next; - } + # if delivery of registration msg succeed + if($res == 0) { + # reset try_to_register + $try_to_register = 0; + + # Set fixed client address and mac address + $client_ip= &get_local_ip_for_remote_ip(sprintf("%s", $server =~ /^([0-9\.]*?):.*$/)); + $client_address= "$client_ip:$client_port"; + $client_mac_address = $local_mac; + $client_dnsname = $dnsname; + + # delivery of registration msg failed + } else { + $try_to_register++; + # wait 1 sec until trying to register again + sleep(1); + next; + } + + if( $try_to_register >= @servers ) { last; } } # end of while -- 2.30.2