Code

bugfix: comunication between gosa and gosa-si
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 12 Mar 2008 10:26:35 +0000 (10:26 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 12 Mar 2008 10:26:35 +0000 (10:26 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9703 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/client/events/corefunctions.pm
gosa-si/gosa-si-client
gosa-si/server/events/databases.pm
gosa-si/tests/client.php

index 3f534088e4040c5dd8cf144916e784094f934d8c..3d0311926bda160bfe7b8dc12eb02270a719f6f7 100644 (file)
@@ -312,6 +312,11 @@ sub new_key {
 
     my $out_hash = &create_xml_hash("new_key", $main::client_address, $main::server_address, $new_server_key);    
     my $out_msg = &create_xml_string($out_hash);
+
+    # set global $NEW_KEY_FLAG, gosa-si-client cause a reregistering process if no 'confirm_new_key'-msg 
+    # comes from gosa-si-server within a given time
+    
+
     return $out_msg; 
 }
 
index 359803d20acbbda991c93a707655b5e5e96f2dd4..75424cef3f940e9bd3984e1fed0177697daadb79 100755 (executable)
@@ -614,15 +614,15 @@ sub send_msg_to_target {
     # opensocket
     my $socket = &open_socket($address);
     if( !$socket ) {
-        daemon_log("cannot send ".$msg_header."msg to $address , host not reachable", 1);
+        daemon_log("ERROR: cannot send ".$msg_header."msg to $address , host not reachable", 1);
         $error++;
     }
     
     # send xml msg
     if( $error == 0 ) {
         print $socket $crypted_msg."\n";
-        daemon_log("send ".$msg_header."msg to $address", 1);
-        daemon_log("message:\n$msg", 8);
+        daemon_log("INFO: send ".$msg_header."msg to $address", 5);
+        daemon_log("DEBUG: message:\n$msg", 8);
     }
 
     # close socket in any case
@@ -930,6 +930,7 @@ sub trigger_new_key {
     &send_msg_to_target($msg, $client_address, $server_key, 'new_key');
 
     $kernel->delay_set('trigger_new_key', $server_key_lifetime);
+    $kernel->delay_set('trigger_reregistering_process', 10);
 }
 
 
@@ -960,6 +961,10 @@ sub trigger_logged_in_users_report {
     }
 }
 
+sub trigger_reregistering_process {
+    $REGISTERED = 0;
+}
+
 
 sub generic_file_reset {
     my ( $heap, $wheel_id ) = @_[ HEAP, ARG0 ];
@@ -1086,11 +1091,11 @@ sub server_input {
     my $error = 0;
     my $answer;
     
-    daemon_log("Incoming msg:\n$input\n", 8);
+    daemon_log("DEBUG: Incoming msg:\n$input\n", 8);
 
     my ($msg, $msg_hash) = &check_key_and_xml_validity($input, $server_key);
     if( (!$msg) || (!$msg_hash) ) {
-        daemon_log("Deciphering of incoming msg failed", 5);
+        daemon_log("WARNING: Deciphering of incoming msg failed", 3);
         $error++;
     }
 
@@ -1102,8 +1107,14 @@ sub server_input {
         my $source = @{$msg_hash->{source}}[0];
 
         if( exists $event_hash->{$header} ) {
+
+            # preprocessing 
+            if($header eq "confirm_new_key") {
+                $kernel->delay_set()
+            }
+
             # a event exists with the header as name
-            daemon_log("found event '$header' at event-module '".$event_hash->{$header}."'", 5);
+            daemon_log("DEBUG: found event '$header' at event-module '".$event_hash->{$header}."'", 7);
             no strict 'refs';
             $answer = &{$event_hash->{$header}."::$header"}($msg, $msg_hash);
         }
index d40ca0b8f7ad39fc0740e8540a732d32cba6f37e..8f56480576b192f6cb8a7f31ab1e0753bbc2888f 100644 (file)
@@ -70,6 +70,7 @@ sub query_db {
     my $res_hash = $db->select_dbentry($sql_statement);
     
     my $out_xml = &db_res2si_msg($res_hash, $header, $target, $source);
+    $out_xml =~ s/<\/xml>/<session_id>$session_id<\/session_id><\/xml>/;
     my @out_msg_l = ( $out_xml );
     return @out_msg_l;
 }
@@ -131,7 +132,7 @@ sub delete_jobdb_entry {
     }
 
     # prepare xml answer
-    my $out_xml = "<xml><header>answer</header><source>$target</source><target>$source</target><answer1>$res</answer1></xml>";
+    my $out_xml = "<xml><header>answer</header><source>$target</source><target>$source</target><answer1>$res</answer1><session_id>$session_id</session_id></xml>";
     my @out_msg_l = ( $out_xml );
     return @out_msg_l;
 
@@ -153,7 +154,7 @@ sub clear_jobdb {
     if( not $db_res > 0 ) { $error++; };
     
     if( $error == 0 ) {
-        $out_xml = "<xml><header>answer</header><source>$target</source><target>$source</target><answer1>0</answer1></xml>";
+        $out_xml = "<xml><header>answer</header><source>$target</source><target>$source</target><answer1>0</answer1><session_id>$session_id</session_id></xml>";
     }
     my @out_msg_l = ( $out_xml );
     return @out_msg_l;
@@ -166,7 +167,7 @@ sub update_status_jobdb_entry {
     my $source = @{$msg_hash->{'source'}}[0];
 
     my $error= 0;
-    my $out_xml= "<xml><header>answer</header><source>$target</source><target>$source</target><answer1>1</answer1></xml>";
+    my $out_xml= "<xml><header>answer</header><source>$target</source><target>$source</target><answer1>1</answer1><session_id>$session_id</session_id></xml>";
 
     my @len_hash = keys %{$msg_hash};
     if( 0 == @len_hash) {  $error++; };
@@ -200,7 +201,7 @@ sub update_status_jobdb_entry {
         $out_xml = "<answer1>0</answer1>";
     }
     
-    my $out_msg = sprintf("<xml><header>answer</header><source>%s</source><target>%s</target>%s</xml>", $target, $source, $out_xml);
+    my $out_msg = sprintf("<xml><header>answer</header><source>%s</source><target>%s</target>%s<session_id>$session_id</session_id></xml>", $target, $source, $out_xml);
     my @out_msg_l = ( $out_msg );
     return @out_msg_l;
 }
index b43306e09ed1fc4265a34934779d03aacd3e5ed9..dbe43c1734830a75ad314ef52389d456bc7c4279 100755 (executable)
@@ -35,18 +35,15 @@ if($sock->connected()){
 #$data = "<xml> <header>gosa_update_status_jobdb_entry</header> <source>GOSA</source><target>GOSA</target><where><clause><phrase> <macaddress>00:01:6c:9d:b9:fa</macaddress></phrase></clause> </where> <update><status>processing</status> <result>update</result></update></xml>";
 
 # jobdb query
-#$data = "<xml><header>gosa_query_jobdb</header><source>GOSA</source> <target>GOSA</target>".
-#    "<where><clause><connector>and</connector><phrase><operator>gt</operator><ROWID>0</ROWID></phrase><phrase><operator>le</operator><ROWID>5</ROWID></phrase></clause></where></xml>";
-#$data= "<xml><header>gosa_query_jobdb</header><source>GOSA</source> <target>GOSA</target>".
-#    "<where><clause><phrase><headertag>ping</headertag></phrase></clause></where><limit><from>0</from><to>3</to></limit></xml>";
-#$data= "<xml><header>gosa_query_jobdb</header><source>GOSA</source> <target>GOSA</target>".
-#    "<where><clause><phrase><HEADERTAG>trigger_action_reinstall</HEADERTAG></phrase></clause></where>".
-#    "<limit><from>0</from><to>25</to></limit><orderby>timestamp DESC</orderby></xml>";
-#$data= "<xml><header>gosa_query_jobdb</header><source>GOSA</source> <target>GOSA</target></xml>";
+#$data = "<xml><header>gosa_query_jobdb</header><source>GOSA</source> <target>GOSA</target><where><clause><connector>and</connector><phrase><operator>gt</operator><ROWID>0</ROWID></phrase><phrase><operator>le</operator><ROWID>5</ROWID></phrase></clause></where></xml>";
+#$data= "<xml><header>gosa_query_jobdb</header><source>GOSA</source> <target>GOSA</target><where><clause><phrase><headertag>ping</headertag></phrase></clause></where><limit><from>0</from><to>3</to></limit></xml>";
+#$data= "<xml><header>gosa_query_jobdb</header><source>GOSA</source> <target>GOSA</target><where><clause><phrase><HEADERTAG>trigger_action_reinstall</HEADERTAG></phrase></clause></where><limit><from>0</from><to>25</to></limit><orderby>timestamp DESC</orderby></xml>";
+$data= "<xml><header>gosa_query_jobdb</header><source>GOSA</source> <target>GOSA</target></xml>";
 
 # jobdb count
 #$data = "<xml> <header>gosa_count_jobdb</header><source>GOSA</source> <target>GOSA</target></xml>";
-$data = "<xml> <header>gosa_count_fai_server</header><source>GOSA</source> <target>GOSA</target></xml>";
+#$data = "<xml> <header>gosa_count_fai_server</header><source>GOSA</source> <target>GOSA</target></xml>";
+#$data = "<xml> <header>gosa_count_fai_release</header><source>GOSA</source> <target>GOSA</target></xml>";
 
 # jobdb clear
 #$data = "<xml> <header>gosa_clear_jobdb</header> <source>GOSA</source> <target>GOSA</target></xml>";