From d1d3dde68573111828806b6f586a0b26ef92df3f Mon Sep 17 00:00:00 2001 From: rettenbe Date: Wed, 12 Nov 2008 10:08:38 +0000 Subject: [PATCH] reregistering after undecipherable msg between client and server works again git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13006 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-client | 6 +++++- gosa-si/gosa-si-server | 19 ++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index d3965ce39..b7a20565a 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -429,6 +429,10 @@ sub send_msg_to_target { if( $msg_header ) { $msg_header = "'$msg_header'-"; } else { $msg_header = ""; } + # Memorize own source address + $msg =~ /(\S+)<\/source>/; + my $own_source_address = $1; + # encrypt xml msg my $crypted_msg = &encrypt_msg($msg, $encrypt_key); @@ -447,7 +451,7 @@ sub send_msg_to_target { # send xml msg if( $error == 0 ) { - print $socket $crypted_msg."\n"; + print $socket $crypted_msg.";$own_source_address\n"; daemon_log("INFO: send ".$msg_header."msg to $address", 5); daemon_log("DEBUG: message:\n$msg", 9); } diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 6815ecbc3..fa9d32aec 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -1063,11 +1063,11 @@ sub update_jobdb_status_for_send_msgs { &daemon_log("$session_id DEBUG: $sql_statement", 7); my $res = $job_db->update_dbentry($sql_statement); } else { - &daemon_log("$session_id WARNING: sending message succeed but cannot update job status.", 3); + &daemon_log("$session_id DEBUG: sending message succeed but cannot update job status.", 7); } } } else { - &daemon_log("$session_id ERROR: cannot update job status, msg has no jobdb_id-tag: $answer", 1); + &daemon_log("$session_id DEBUG: cannot update job status, msg has no jobdb_id-tag: $answer", 7); } } @@ -1103,6 +1103,7 @@ sub msg_to_decrypt { # hole neue msg aus @msgs_to_decrypt my $next_msg = shift @msgs_to_decrypt; + my ($next_msg, $msg_source) = split(/;/, $next_msg); # msg is from a new client or gosa ($msg, $msg_hash, $module) = &input_from_unknown_host($next_msg, $session_id); @@ -1119,17 +1120,13 @@ sub msg_to_decrypt { if(( !$msg ) || ( !$msg_hash ) || ( !$module )){ # if an incoming msg could not be decrypted (maybe a wrong key), send client a ping. If the client # could not understand a msg from its server the client cause a re-registering process + my $remote_ip = $heap->{'remote_ip'}; + my $remote_port = $heap->{'remote_port'}; + my $ping_msg = "
gosa_ping
$server_address$msg_source
"; + my ($test_error, $test_error_string) = &send_msg_to_target($ping_msg, "$msg_source", "dummy-key", "gosa_ping", $session_id); + daemon_log("$session_id WARNING cannot understand incoming msg, send 'ping'-msg to all host with ip '".$heap->{remote_ip}. "' to cause a re-registering of the client if necessary", 3); - my $sql_statement = "SELECT * FROM $main::known_clients_tn WHERE (hostname LIKE '".$heap->{'remote_ip'}."%')"; - my $query_res = $known_clients_db->select_dbentry( $sql_statement ); - while( my ($hit_num, $hit) = each %{ $query_res } ) { - my $host_name = $hit->{'hostname'}; - my $host_key = $hit->{'hostkey'}; - my $ping_msg = "
gosa_ping
$server_address $host_name
"; - my $error = &send_msg_to_target($ping_msg, $host_name, $host_key, "gosa_ping", $session_id); - &update_jobdb_status_for_send_msgs($ping_msg, $error); - } $error++; } -- 2.30.2