From ddc00569f9beee9e56ad0485bc0687a9e6bc64b5 Mon Sep 17 00:00:00 2001 From: rettenbe Date: Wed, 4 Jun 2008 07:55:09 +0000 Subject: [PATCH] gosa-si-server: feedback for gosa in case of no processed msgs git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11193 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-server | 52 +++++----- gosa-si/server/events/gosaTriggered.pm | 105 +-------------------- gosa-si/server/events/server_server_com.pm | 3 + gosa-si/tests/client.php | 4 +- 4 files changed, 36 insertions(+), 128 deletions(-) diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index c3d080101..75fec07b1 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -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>/$server_address,$session_id<\/forward_to_gosa><\/xml>/; + $msg =~ s/<\/xml>/$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/GOSA<\/source>/$server_address<\/source>/; + $msg =~ s/GOSA<\/source>/$local_address<\/source>/; $msg =~ s/$target<\/target>/$hostname<\/target>/; if ($source eq "GOSA") { - $msg =~ s/<\/xml>/$server_address,$session_id<\/forward_to_gosa><\/xml>/; + $msg =~ s/<\/xml>/$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/GOSA<\/source>/$server_address<\/source>/; - $msg =~ s/<\/xml>/$server_address,$session_id<\/forward_to_gosa><\/xml>/; + $msg =~ s/GOSA<\/source>/$local_address<\/source>/; + $msg =~ s/<\/xml>/$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]; diff --git a/gosa-si/server/events/gosaTriggered.pm b/gosa-si/server/events/gosaTriggered.pm index 1b278a52b..964ffdf6f 100644 --- a/gosa-si/server/events/gosaTriggered.pm +++ b/gosa-si/server/events/gosaTriggered.pm @@ -59,16 +59,6 @@ sub get_events { } sub send_user_msg { - -# msg from gosa -#
gosa_send_user_msg
GOSAGOSA -# 20080429151605 -# andreas.rettenberger -# hallo -# test -# GOSA -#
- 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 ("
$header
GOSAGOSA". -# "no user-tag or a group-tag specified in 'send_user_msg'
"); -# } -# if( not defined $message ) { -# &main::daemon_log("$session_id WARNING: no message-tag specified in 'send_user_msg'", 3); -# return ("
$header
GOSAGOSA". -# "no message-tag specified in 'send_user_msg'
"); -# -# } -# -# # 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) = @_ ; diff --git a/gosa-si/server/events/server_server_com.pm b/gosa-si/server/events/server_server_com.pm index 68aa78702..ea24e08c2 100644 --- a/gosa-si/server/events/server_server_com.pm +++ b/gosa-si/server/events/server_server_com.pm @@ -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); diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index 06275cd75..dd6b3c059 100755 --- a/gosa-si/tests/client.php +++ b/gosa-si/tests/client.php @@ -52,7 +52,7 @@ for($count = 1; $count <= $zahl; $count++) #$data = "
gosa_count_fai_release
GOSA GOSA
"; # jobdb clear - $data = "
gosa_clear_jobdb
GOSA GOSA
"; + #$data = "
gosa_clear_jobdb
GOSA GOSA
"; # set gosa-si-client to 'activated' #$data = "
job_set_activated_for_installation
10.89.1.31:20083 GOSA 00:01:6c:9d:b9:fa22220101000000
"; @@ -108,7 +108,7 @@ for($count = 1; $count <= $zahl; $count++) #$data = "
gosa_query_fai_server
GOSA 10.89.1.131:20081
"; #$data = "
gosa_ping
00:01:6c:9d:aa:16 GOSA
"; - #$data = "
gosa_ping
00:01:6c:9d:b9:fa GOSA
"; + $data = "
gosa_ping
00:01:6c:9d:b9:fb GOSA
"; #$data = "
job_ping
GOSA 00:0c:29:02:e5:4d 00:0c:29:02:e5:4d29700101000000
"; $sock->write($data); -- 2.30.2