From: rettenbe Date: Fri, 30 May 2008 08:51:28 +0000 (+0000) Subject: * gosa-si-server-nobus X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f7c0e107922093c505808ea67dacd987ecae360b;p=gosa.git * gosa-si-server-nobus * under construction git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11120 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/client/events/corefunctions.pm b/gosa-si/client/events/corefunctions.pm index bd907aa1b..93087f014 100644 --- a/gosa-si/client/events/corefunctions.pm +++ b/gosa-si/client/events/corefunctions.pm @@ -497,7 +497,6 @@ sub new_ping { my $header = @{$msg_hash->{'header'}}[0]; my $source = @{$msg_hash->{'source'}}[0]; my $target = @{$msg_hash->{'target'}}[0]; - my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; my $session_id = @{$msg_hash->{'session_id'}}[0]; my $out_msg; my $out_hash; @@ -513,6 +512,7 @@ sub new_ping { &add_content2xml_hash($out_hash, "session_id", $session_id); } + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; if (defined $forward_to_gosa) { &add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa); } diff --git a/gosa-si/server/events/databases.pm b/gosa-si/server/events/databases.pm index 9e057c8f1..dd383b3d0 100644 --- a/gosa-si/server/events/databases.pm +++ b/gosa-si/server/events/databases.pm @@ -69,8 +69,14 @@ 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><\/xml>/; + #$out_xml =~ s/<\/xml>/$session_id<\/session_id><\/xml>/; + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + if (defined $forward_to_gosa) { + #&add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa); + $out_xml =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } my @out_msg_l = ( $out_xml ); + return @out_msg_l; } @@ -106,6 +112,12 @@ sub count_db { my $count = keys(%{$res_hash}); my $out_xml= "
answer
$target$source$count$session_id
"; + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + if (defined $forward_to_gosa) { + #&add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa); + $out_xml =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } + my @out_msg_l = ( $out_xml ); return @out_msg_l; } @@ -132,6 +144,12 @@ sub delete_jobdb_entry { # prepare xml answer my $out_xml = "
answer
$target$source$res$session_id
"; + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + if (defined $forward_to_gosa) { + #&add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa); + $out_xml =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } + my @out_msg_l = ( $out_xml ); return @out_msg_l; @@ -155,6 +173,12 @@ sub clear_jobdb { if( $error == 0 ) { $out_xml = "
answer
$target$source0$session_id
"; } + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + if (defined $forward_to_gosa) { + #&add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa); + $out_xml =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } + my @out_msg_l = ( $out_xml ); return @out_msg_l; } @@ -201,6 +225,11 @@ sub update_status_jobdb_entry { } my $out_msg = sprintf("
answer
%s%s%s$session_id
", $target, $source, $out_xml); + if (defined $forward_to_gosa) { + #&add_content2xml_hash($out_hash, "forward_to_gosa", $forward_to_gosa); + $out_xml =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } + my @out_msg_l = ( $out_msg ); return @out_msg_l; } diff --git a/gosa-si/server/events/gosaTriggered.pm b/gosa-si/server/events/gosaTriggered.pm index 3975d8e04..f5035dc2b 100644 --- a/gosa-si/server/events/gosaTriggered.pm +++ b/gosa-si/server/events/gosaTriggered.pm @@ -139,92 +139,92 @@ 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 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 { @@ -241,7 +241,7 @@ sub recreate_fai_server_db { $main::fai_server_db->create_table("new_fai_server", \@main::fai_server_col_names); &main::create_fai_server_db("new_fai_server",undef,"dont", $session_id); $main::fai_server_db->move_table("new_fai_server", $main::fai_server_tn); - + my @out_msg_l = ( $out_msg ); return @out_msg_l; } @@ -415,7 +415,12 @@ sub gen_smb_hash { my $password = @{$msg_hash->{password}}[0]; my %data= ('hash' => join(q[:], ntlmgen $password)); - my $out_msg = &build_msg("gen_smb_hash", $target, 'GOSA', \%data ); + my $out_msg = &build_msg("gen_smb_hash", $target, $source, \%data ); + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + if (defined $forward_to_gosa) { + $out_msg =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } + return ( $out_msg ); } @@ -441,8 +446,12 @@ sub network_completition { %data= ('ip' => '', 'mac' => ''); } - my $out_msg = &build_msg("network_completition", $target, 'GOSA', \%data ); - + my $out_msg = &build_msg("network_completition", $target, $source, \%data ); + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + if (defined $forward_to_gosa) { + $out_msg =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } + return ( $out_msg ); } @@ -778,7 +787,12 @@ sub get_available_kernel { } $data{"answer".$i++}= "default"; - my $out_msg = &build_msg("get_available_kernel", $target, "GOSA", \%data); + my $out_msg = &build_msg("get_available_kernel", $target, $source, \%data); + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + if (defined $forward_to_gosa) { + $out_msg =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } + return ( $out_msg ); } @@ -928,7 +942,12 @@ sub trigger_activate_new { my %data; - my $out_msg = &build_msg("activate_new", $target, "GOSA", \%data); + my $out_msg = &build_msg("activate_new", $target, $source, \%data); + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + if (defined $forward_to_gosa) { + $out_msg =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } + return ( $out_msg ); } diff --git a/gosa-si/server/events/logHandling.pm b/gosa-si/server/events/logHandling.pm index c06a0b2f9..714b9768e 100644 --- a/gosa-si/server/events/logHandling.pm +++ b/gosa-si/server/events/logHandling.pm @@ -90,6 +90,11 @@ sub show_log_by_date { } $out_msg = &create_xml_string($out_hash); + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + if (defined $forward_to_gosa) { + $out_msg =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } + return ($out_msg); } @@ -148,6 +153,11 @@ sub show_log_by_mac { } my $out_msg = &create_xml_string($out_hash); + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + if (defined $forward_to_gosa) { + $out_msg =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } + return ($out_msg); } @@ -203,6 +213,11 @@ sub show_log_by_date_and_mac { } my $out_msg = &create_xml_string($out_hash); + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + if (defined $forward_to_gosa) { + $out_msg =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } + return $out_msg; } @@ -247,6 +262,11 @@ sub show_log_files_by_date_and_mac { } my $out_msg = &create_xml_string($out_hash); + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + if (defined $forward_to_gosa) { + $out_msg =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } + return $out_msg; } @@ -291,6 +311,11 @@ sub get_log_file_by_date_and_mac { my $out_hash = &create_xml_hash($header, $target, $source); &add_content2xml_hash($out_hash, $log_file, $log_content); my $out_msg = &create_xml_string($out_hash); + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + if (defined $forward_to_gosa) { + $out_msg =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } + return $out_msg; } @@ -370,6 +395,11 @@ sub get_recent_log_by_mac { } my $out_msg = &create_xml_string($out_hash); + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + if (defined $forward_to_gosa) { + $out_msg =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } + return $out_msg; } @@ -442,6 +472,11 @@ sub delete_log_by_date_and_mac { } my $out_msg = &create_xml_string($out_hash); + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + if (defined $forward_to_gosa) { + $out_msg =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } + return $out_msg; } diff --git a/gosa-si/server/events/siTriggered.pm b/gosa-si/server/events/siTriggered.pm index 544e2e6ab..007e84df5 100644 --- a/gosa-si/server/events/siTriggered.pm +++ b/gosa-si/server/events/siTriggered.pm @@ -112,6 +112,10 @@ sub got_ping { my $out_hash = &create_xml_hash($header, $source, "GOSA"); &add_content2xml_hash($out_hash, "session_id", $session_id); $out_msg = &create_xml_string($out_hash); + my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; + if (defined $forward_to_gosa) { + $out_msg =~s/<\/xml>/$forward_to_gosa<\/forward_to_gosa><\/xml>/; + } push(@out_msg_l, $out_msg); return @out_msg_l;