Code

gosa-si-server: feedback for gosa in case of no processed msgs
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 4 Jun 2008 07:55:09 +0000 (07:55 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 4 Jun 2008 07:55:09 +0000 (07:55 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11193 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/gosa-si-server
gosa-si/server/events/gosaTriggered.pm
gosa-si/server/events/server_server_com.pm
gosa-si/tests/client.php

index c3d08010164bb723fc71938d107e0d0a91ff5e2b..75fec07b1a336106418d4457614e8709c0aa911a 100755 (executable)
@@ -1059,10 +1059,13 @@ sub msg_to_decrypt {
         $header = @{$msg_hash->{'header'}}[0];
         $target = @{$msg_hash->{'target'}}[0];
         $source = @{$msg_hash->{'source'}}[0];
+        my $local_address;
         my ($target_ip, $target_port) = split(':', $target);
                if ($target =~ /^\d+\.\d+\.\d+\.\d+:\d+$/) {
-                       my $server_address = &get_local_ip_for_remote_ip($target_ip).":$server_port";
-               }
+                       $local_address = &get_local_ip_for_remote_ip($target_ip).":$server_port";
+               } else {
+            $local_address = $server_address;
+        }
 
         # target and source is equal to GOSA -> process here
         if (not $done) {
@@ -1073,10 +1076,10 @@ sub msg_to_decrypt {
 
         # target is own address without forward_to_gosa-tag -> process here
         if (not $done) {
-            if (($target eq $server_address) && (not exists $msg_hash->{'forward_to_gosa'})) {
+            if (($target eq $local_address) && (not exists $msg_hash->{'forward_to_gosa'})) {
                 $done = 1;
                 if ($source eq "GOSA") {
-                    $msg =~ s/<\/xml>/<forward_to_gosa>$server_address,$session_id<\/forward_to_gosa><\/xml>/;
+                    $msg =~ s/<\/xml>/<forward_to_gosa>$local_address,$session_id<\/forward_to_gosa><\/xml>/;
                 }
                 print STDERR "target is own address without forward_to_gosa-tag -> process here\n";
             }
@@ -1099,9 +1102,9 @@ sub msg_to_decrypt {
             my $forward_to_gosa =  @{$msg_hash->{'forward_to_gosa'}}[0];
             my $gosa_at;
             my $gosa_session_id;
-            if (($target eq $server_address) && (defined $forward_to_gosa)){
+            if (($target eq $local_address) && (defined $forward_to_gosa)){
                 my ($gosa_at, $gosa_session_id) = split(/,/, $forward_to_gosa);
-                if ($gosa_at ne $server_address) {
+                if ($gosa_at ne $local_address) {
                     $done = 1;
                     print STDERR "target is own address with forward_to_gosa-tag not pointing to myself -> process here\n"; 
                 }
@@ -1134,9 +1137,9 @@ sub msg_to_decrypt {
             my $forward_to_gosa =  @{$msg_hash->{'forward_to_gosa'}}[0];
             my $gosa_at;
             my $gosa_session_id;
-            if (($target eq $server_address) && (defined $forward_to_gosa)){
+            if (($target eq $local_address) && (defined $forward_to_gosa)){
                 my ($gosa_at, $gosa_session_id) = split(/,/, $forward_to_gosa);
-                if ($gosa_at eq $server_address) {
+                if ($gosa_at eq $local_address) {
                     my $session_reference = $kernel->ID_id_to_session($gosa_session_id);
                     if( defined $session_reference ) {
                         $heap = $session_reference->get_heap();
@@ -1163,10 +1166,10 @@ sub msg_to_decrypt {
                 my $res = $known_server_db->select_dbentry($sql);
                 if (keys(%$res) > 0) {
                     my $regserver_key = $res->{1}->{'hostkey'};
-                    $msg =~ s/<source>GOSA<\/source>/<source>$server_address<\/source>/;
+                    $msg =~ s/<source>GOSA<\/source>/<source>$local_address<\/source>/;
                     $msg =~ s/<target>$target<\/target>/<target>$hostname<\/target>/;
                     if ($source eq "GOSA") {
-                        $msg =~ s/<\/xml>/<forward_to_gosa>$server_address,$session_id<\/forward_to_gosa><\/xml>/;
+                        $msg =~ s/<\/xml>/<forward_to_gosa>$local_address,$session_id<\/forward_to_gosa><\/xml>/;
                     }
                     &send_msg_to_target($msg, $regserver, $regserver_key, $header, $session_id);
                 }
@@ -1183,8 +1186,8 @@ sub msg_to_decrypt {
                 my $hostkey = $res->{1}->{'hostkey'};
 
                 if ($source eq "GOSA") {
-                    $msg =~ s/<source>GOSA<\/source>/<source>$server_address<\/source>/;
-                    $msg =~ s/<\/xml>/<forward_to_gosa>$server_address,$session_id<\/forward_to_gosa><\/xml>/;
+                    $msg =~ s/<source>GOSA<\/source>/<source>$local_address<\/source>/;
+                    $msg =~ s/<\/xml>/<forward_to_gosa>$local_address,$session_id<\/forward_to_gosa><\/xml>/;
 
                 }
 
@@ -1198,7 +1201,21 @@ sub msg_to_decrypt {
 
         if (not $done) {
             daemon_log("$session_id ERROR: do not know what to do with this message: $msg", 1);
+            if ($source eq "GOSA") {
+                my %data = ('error_msg' => &encode_base64($msg), 'error_string' => "Do not know what to do with this message!");
+                my $error_msg = &build_msg("error", $local_address, "GOSA", \%data ); 
+
+                my $session_reference = $kernel->ID_id_to_session($session_id);
+                if( defined $session_reference ) {
+                    $heap = $session_reference->get_heap();
+                }
+                if(exists $heap->{'client'}) {
+                    $error_msg = &encrypt_msg($error_msg, $GosaPackages_key);
+                    $heap->{'client'}->put($error_msg);
+                }
+            }
         }
+
     }
 
     return;
@@ -1403,7 +1420,6 @@ sub process_task {
 
 sub session_start {
     my ($kernel) = $_[KERNEL];
-    &trigger_db_loop($kernel);
     $global_kernel = $kernel;
     $kernel->yield('register_at_foreign_servers');
        $kernel->yield('create_fai_server_db', $fai_server_tn );
@@ -1420,16 +1436,6 @@ sub session_start {
 
 }
 
-sub trigger_db_loop {
-       my ($kernel) = @_ ;
-#      $kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay);
-#      $kernel->delay_set('watch_for_done_jobs', $job_queue_loop_delay); 
-#      $kernel->delay_set('watch_for_new_messages', $messaging_db_loop_delay);
-#    $kernel->delay_set('watch_for_delivery_messages', $messaging_db_loop_delay);
-#      $kernel->delay_set('watch_for_done_messages', $messaging_db_loop_delay);
-#    $kernel->delay_set('watch_for_old_known_clients', $job_queue_loop_delay);
-}
-
 
 sub watch_for_done_jobs {
     my ($kernel,$heap) = @_[KERNEL, HEAP];
index 1b278a52b943d0f6772e69ff356d24b111b6ddd2..964ffdf6f2c976bfb6290d8b48b907611b22af1c 100644 (file)
@@ -59,16 +59,6 @@ sub get_events {
 }
 
 sub send_user_msg {
-
-# msg from gosa
-# <xml><header>gosa_send_user_msg</header><source>GOSA</source><target>GOSA</target>
-# <timestamp>20080429151605</timestamp>
-# <users>andreas.rettenberger</users>
-# <subject>hallo</subject>
-# <message>test</message>
-# <macaddress>GOSA</macaddress>
-# </xml>
-
     my ($msg, $msg_hash, $session_id) = @_ ;
     my $header = @{$msg_hash->{'header'}}[0];
     my $source = @{$msg_hash->{'source'}}[0];
@@ -78,7 +68,7 @@ sub send_user_msg {
     my $subject = @{$msg_hash->{'subject'}}[0];
     my $from = @{$msg_hash->{'from'}}[0];
     my @users = @{$msg_hash->{'users'}};
-       my @groups = @{$msg_hash->{'groups'}}[0];
+       my @groups = @{$msg_hash->{'groups'}};
     my $delivery_time = @{$msg_hash->{'delivery_time'}}[0];
     #my $message = &decode_base64(@{$msg_hash->{'message'}}[0]);
     my $message = @{$msg_hash->{'message'}}[0];
@@ -110,11 +100,7 @@ sub send_user_msg {
        # highlight user name and group name
        my @receiver_l;
        @users = map(push(@receiver_l, "u_$_"), @users);
-       #@groups = map(push(@receiver_l, "g_$_"), @groups);
-# TODO
-# handling, was passiert wenn in einer liste nix drin steht
-# handling von groups hinzufügen
-       
+       @groups = map(push(@receiver_l, "g_$_"), @groups);
 
     my $func_dic = {table=>$main::messaging_tn,
         primkey=>[],
@@ -138,93 +124,6 @@ sub send_user_msg {
     return;
 }
 
-#sub send_user_msg_OLD {
-#    my ($msg, $msg_hash, $session_id) = @_ ;
-#    my @out_msg_l;
-#    my @user_list;
-#    my @group_list;
-#
-#    my $header = @{$msg_hash->{'header'}}[0];
-#    my $source = @{$msg_hash->{'source'}}[0];
-#    my $target = @{$msg_hash->{'target'}}[0];
-#    my $message = @{$msg_hash->{'message'}}[0];
-#    if( exists $msg_hash->{'user'} ) { @user_list = @{$msg_hash->{'user'}}; }
-#    if( exists $msg_hash->{'group'} ) { @group_list = @{$msg_hash->{'group'}}; }
-#
-#    my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
-#    if( defined $jobdb_id) {
-#        my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id=jobdb_id";
-#        &main::daemon_log("$session_id DEBUG: $sql_statement", 7); 
-#        my $res = $main::job_db->exec_statement($sql_statement);
-#    }
-#
-#    # error handling
-#    if( not @user_list && not @group_list ) {
-#        &main::daemon_log("$session_id WARNING: no user-tag or a group-tag specified in 'send_user_msg'", 3); 
-#        return ("<xml><header>$header</header><source>GOSA</source><target>GOSA</target>".
-#                "<error_string>no user-tag or a group-tag specified in 'send_user_msg'</error_string></xml>");
-#    }
-#    if( not defined $message ) {
-#        &main::daemon_log("$session_id WARNING: no message-tag specified in 'send_user_msg'", 3); 
-#        return ("<xml><header>$header</header><source>GOSA</source><target>GOSA</target>".
-#                "<error_string>no message-tag specified in 'send_user_msg'</error_string></xml>");
-#
-#    }
-#
-#    # resolve groups to users
-#    my $ldap_handle = &main::get_ldap_handle($session_id);
-#    if( @group_list ) {
-#        if( not defined $ldap_handle ) {
-#            &main::daemon_log("$session_id ERROR: cannot connect to ldap", 1);
-#            return ();
-#        } 
-#        foreach my $group (@group_list) {   # Perform search
-#            my $mesg = $ldap_handle->search( 
-#                    base => $main::ldap_base,
-#                    scope => 'sub',
-#                    attrs => ['memberUid'],
-#                    filter => "(&(objectClass=posixGroup)(cn=$group)(memberUid=*))");
-#            if($mesg->code) {
-#                &main::daemon_log($mesg->error, 1);
-#                return ();
-#            }
-#            my $entry= $mesg->entry(0);
-#            my @users= $entry->get_value("memberUid");
-#            foreach my $user (@users) { push(@user_list, $user); }
-#        }
-#    }
-#
-#    # drop multiple users in @user_list
-#    my %seen = ();
-#    foreach my $user (@user_list) {
-#        $seen{$user}++;
-#    }
-#    @user_list = keys %seen;
-#
-#    # build xml messages sended to client where user is logged in
-#    foreach my $user (@user_list) {
-#        my $sql_statement = "SELECT * FROM $main::login_users_tn WHERE user='$user'"; 
-#        my $db_res = $main::login_users_db->select_dbentry($sql_statement);
-#
-#        if(0 == keys(%{$db_res})) {
-#
-#        } else {
-#            while( my($hit, $content) = each %{$db_res} ) {
-#                my $out_hash = &create_xml_hash('send_user_msg', $main::server_address, $content->{'client'});
-#                &add_content2xml_hash($out_hash, 'message', $message);
-#                &add_content2xml_hash($out_hash, 'user', $user);
-#                if( exists $msg_hash->{'jobdb_id'} ) { 
-#                    &add_content2xml_hash($out_hash, 'jobdb_id', @{$msg_hash->{'jobdb_id'}}[0]); 
-#                }
-#                my $out_msg = &create_xml_string($out_hash);
-#                push(@out_msg_l, $out_msg);
-#            }
-#        }
-#    }
-#
-#    return @out_msg_l;
-#}
-
 
 sub recreate_fai_server_db {
     my ($msg, $msg_hash, $session_id) = @_ ;
index 68aa78702ed2efa57a751c38b65874034b0ace14..ea24e08c2560aaa76b9c862026152d683fb6f2df 100644 (file)
@@ -81,6 +81,9 @@ sub new_server {
         my $res = $main::foreign_clients_db->exec_statementlist(\@sql_list);
     }
             
+    # fetch all registered clients
+    
+
     # build confirm_new_server message
     my %data = ( key=>$key );
     my $out_msg = &build_msg('confirm_new_server', $main::server_address, $source, \%data);
index 06275cd75722d557caf66bae87d5d4e8828bf178..dd6b3c059f5bbc3db2ee18585d608cc324655ab4 100755 (executable)
@@ -52,7 +52,7 @@ for($count = 1; $count <= $zahl; $count++)
     #$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>";
+    #$data = "<xml> <header>gosa_clear_jobdb</header> <source>GOSA</source> <target>GOSA</target></xml>";
 
     # set gosa-si-client to 'activated'
     #$data = "<xml> <header>job_set_activated_for_installation</header> <target>10.89.1.31:20083</target> <source>GOSA</source> <macaddress>00:01:6c:9d:b9:fa</macaddress><timestamp>22220101000000</timestamp></xml>";
@@ -108,7 +108,7 @@ for($count = 1; $count <= $zahl; $count++)
 
     #$data = "<xml><header>gosa_query_fai_server</header><source>GOSA</source> <target>10.89.1.131:20081</target></xml>";
     #$data = "<xml> <header>gosa_ping</header> <target>00:01:6c:9d:aa:16</target> <source>GOSA</source> </xml>";
-    #$data = "<xml> <header>gosa_ping</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
+    $data = "<xml> <header>gosa_ping</header> <target>00:01:6c:9d:b9:fb</target> <source>GOSA</source> </xml>";
     #$data = "<xml> <header>job_ping</header> <source>GOSA</source> <target>00:0c:29:02:e5:4d</target> <macaddress>00:0c:29:02:e5:4d</macaddress><timestamp>29700101000000</timestamp> </xml>";
 
     $sock->write($data);