X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-si%2Fgosa-si-client;h=fd36a5bbf7361f435f95a737af38c7558e6a31cd;hb=d9eeaa2981dd62dc189e9172339f3ef2ef0d58e6;hp=417b9263e02e01caf5408fc749ad850e15af7b2b;hpb=767fe0df52eaeb046a729eea2e86f02ebcbee145;p=gosa.git diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index 417b9263e..fd36a5bbf 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -40,7 +40,7 @@ my $event_dir = "/usr/lib/gosa-si/client/events"; use lib "/usr/lib/gosa-si/client/events"; my ($cfg_file, %cfg_defaults, $foreground, $verbose, $pid_file, $procid, $pid, $log_file); -my ($server_ip, $server_port, $server_key, $server_timeout, $server_domain); +my ($server_ip, $server_port, $server_key, $server_timeout, $server_domain, $server_key_lifetime); my ($client_ip, $client_port, $client_mac_address, $ldap_enabled, $ldap_config, $pam_config, $nss_config); my $xml; my $default_server_key; @@ -77,6 +77,7 @@ our $REGISTERED_FLAG = 1; "server_key" => [\$server_key, ""], "server_timeout" => [\$server_timeout, 10], "server_domain" => [\$server_domain, ""], + "server_key_lifetime" => [\$server_key_lifetime, 600], }, ); @@ -865,10 +866,16 @@ sub register_at_gosa_si_server { # send xml hash to server with general server passwd my $res = &send_msg_hash2address($register_hash, $server, $default_server_key); - last; + if($res == 0) { + last; + } else { + next; + } } daemon_log("waiting for msg 'register_at_gosa_si_server'",1); - $kernel->delay_set('register_at_gosa_si_server',2); + $kernel->delay_set('register_at_gosa_si_server',180); + # clear old settings and set it again + $kernel->delay_set('trigger_new_key', $server_key_lifetime); } return; } @@ -954,9 +961,26 @@ sub import_events { } } +sub trigger_new_key { + my ($kernel) = $_[KERNEL] ; + + my $msg = "
new_key
$client_address$client_address
"; + &send_msg_to_target($msg, $client_address, $server_key, 'new_key'); + + $kernel->delay_set('trigger_new_key', $server_key_lifetime); + +} + + +sub _start { + my ($kernel) = $_[KERNEL]; + $kernel->alias_set('client_session'); + $kernel->yield('register_at_gosa_si_server'); +} + sub server_input { - my ($heap,$input,$wheel) = @_[HEAP, ARG0, ARG1]; + my ($kernel, $heap, $input, $wheel) = @_[KERNEL, HEAP, ARG0, ARG1]; my $error = 0; my $answer; @@ -985,11 +1009,20 @@ sub server_input { ######## # answer if( $answer ) { + # preprocessing if( $answer =~ "
registered
") { + # set registered flag to true to stop sending further registered msgs $REGISTERED_FLAG = 0; } else { - &send_msg_to_address($answer, $server_address, $server_key); + &send_msg_to_target($answer, $server_address, $server_key); + } + # postprocessing + if( $answer =~ "
new_key
") { + # set new key to global variable + $answer =~ /(\S*?)<\/new_key>/; + my $new_key = $1; + $server_key = $new_key; } } @@ -1100,8 +1133,9 @@ daemon_log("found servers in configuration file and via DNS: $servers_string", 5 POE::Session->create( inline_states => { - _start => \®ister_at_gosa_si_server , + _start => \&_start, register_at_gosa_si_server => \®ister_at_gosa_si_server, + trigger_new_key => \&trigger_new_key, } );