Code

reregistering after undecipherable msg between client and server works again
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 12 Nov 2008 10:08:38 +0000 (10:08 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 12 Nov 2008 10:08:38 +0000 (10:08 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13006 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/gosa-si-client
gosa-si/gosa-si-server

index d3965ce3925964bd90237bde5974662ff0fe1fb3..b7a20565a63d6828876e6fa0c1bb2720d29930f3 100755 (executable)
@@ -429,6 +429,10 @@ sub send_msg_to_target {
     if( $msg_header ) { $msg_header = "'$msg_header'-"; }
     else { $msg_header = ""; }
 
+    # Memorize own source address
+    $msg =~ /<source>(\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);
     }
index 6815ecbc3689562f2032fc6ecd7588751f1c7afc..fa9d32aec67991915cb411f89ef802227893c3b4 100755 (executable)
@@ -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 = "<xml> <header>gosa_ping</header> <source>$server_address</source><target>$msg_source</target></xml>";
+        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 = "<xml> <header>gosa_ping</header> <source>$server_address</source> <target>$host_name</target></xml>";
-                       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++;
        }