From: rettenbe Date: Wed, 28 May 2008 15:29:11 +0000 (+0000) Subject: * gosa-si-server-nobus X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=95bc386bf8758c7d4d0937e17078c7c6bf046874;p=gosa.git * gosa-si-server-nobus * under construction git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11089 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/gosa-si-server-nobus b/gosa-si/gosa-si-server-nobus index 4529bcaa8..4fab86989 100755 --- a/gosa-si/gosa-si-server-nobus +++ b/gosa-si/gosa-si-server-nobus @@ -939,10 +939,10 @@ sub send_msg_to_target { # known_clients - $sql_statement = "SELECT * FROM known_clients WHERE hostname='$address'"; + $sql_statement = "SELECT * FROM $known_clients_tn WHERE hostname='$address'"; $res = $known_clients_db->select_dbentry($sql_statement); if( keys(%$res) == 1) { - $act_status = $res->{1}->{'status'}; + $act_status = exists $res->{1}->{'status'} ? $res->{1}->{'status'} : ""; if ($act_status eq "down" && $new_status eq "down") { $sql_statement = "DELETE FROM known_clients WHERE hostname='$address'"; $res = $known_clients_db->del_dbentry($sql_statement); @@ -962,7 +962,7 @@ sub send_msg_to_target { $sql_statement = "SELECT * FROM $known_server_tn WHERE hostname='$address'"; $res = $known_server_db->select_dbentry($sql_statement); if( keys(%$res) == 1) { - $act_status = $res->{1}->{'status'}; + $act_status = exists $res->{1}->{'status'} ? $res->{1}->{'status'} : ""; if ($act_status eq "down" && $new_status eq "down") { $sql_statement = "DELETE FROM known_server WHERE hostname='$address'"; $res = $known_server_db->del_dbentry($sql_statement); @@ -973,8 +973,7 @@ sub send_msg_to_target { $res = $known_server_db->update_dbentry($sql_statement); if($new_status eq "down"){ daemon_log("$session_id WARNING: set '$address' from status '$act_status' to '$new_status'", 3); - } - else { + } else { daemon_log("$session_id INFO: set '$address' from status '$act_status' to '$new_status'", 5); } } @@ -1041,7 +1040,8 @@ 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 - daemon_log("$session_id INFO 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", 5); + daemon_log("$session_id INFO 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", 5); 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 } ) { @@ -1054,25 +1054,97 @@ sub msg_to_decrypt { $error++; } - # add message to incoming_db - if( $error == 0) { - my $header = @{$msg_hash->{'header'}}[0]; - my $target = @{$msg_hash->{'target'}}[0]; - my $res = $incoming_db->add_dbentry( {table=>$incoming_tn, - primkey=>[], - headertag=>$header, - targettag=>$target, - xmlmessage=>$msg, - timestamp=>&get_time, - module=>$module, - sessionid=>$session_id, - } ); - if ($res != 0) { - # TODO ist das mit $! so ok??? - #&daemon_log("$session_id ERROR: cannot add message to incoming.db: $!", 1); + my $header; + my $target; + my $done = 0; + my $sql; + my $res; + # check whether this message should be processed here + if ($error == 0) { + $header = @{$msg_hash->{'header'}}[0]; + $target = @{$msg_hash->{'target'}}[0]; + + # 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'})) { + $done = 1; + } } - } + # target is a client address in known_clients -> process here + if (not $done) { + $sql = "SELECT * FROM $known_clients_tn WHERE (hostname='$target' OR macaddress LIKE '$target')"; + $res = $known_clients_db->select_dbentry($sql); + if (keys(%$res) > 0) { + $done = 1; + } + } + + # if message should be processed here -> add message to incoming_db + if ($done) { + my $res = $incoming_db->add_dbentry( {table=>$incoming_tn, + primkey=>[], + headertag=>$header, + targettag=>$target, + xmlmessage=>$msg, + timestamp=>&get_time, + module=>$module, + sessionid=>$session_id, + } ); + + } + + # target is own address with forward_to_gosa-tag -> forward to gosa + if (not $done) { + if (($target eq $server_address) && (exists $msg_hash->{'forward_to_gosa'})){ + if( $msg =~ s/session_id=(\d+)$// ) { + my $session_id = $1 ; + } + if( defined $session_id ) { + my $session_reference = $kernel->ID_id_to_session($session_id); + if( defined $session_reference ) { + $heap = $session_reference->get_heap(); + } + } + if(exists $heap->{'client'}) { + $msg = &encrypt_msg($msg, $GosaPackages_key); + $heap->{'client'}->put($msg); + } + $done = 1; + } + } + + # target is a client address in foreign_clients -> forward to registration server + if (not $done) { + $sql = "SELECT * FROM $foreign_clients_tn WHERE (hostname='$target' OR macaddress LIKE '$target')"; + $res = $foreign_clients_db->select_dbentry($sql); + if (keys(%$res) > 0) { + my $regserver = $res->{1}->{'regserver'}; + my $sql = "SELECT * FROM $known_server_tn WHERE hostname='$regserver'"; + 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>/; + &send_msg_to_target($msg, $regserver, $regserver_key, $header, $session_id); + } + $done = 1; + } + } + + # target is a server address -> forward to server + if (not $done) { + $sql = "SELECT * FROM $known_server_tn WHERE hostname='$target'"; + $res = $known_server_db->select_dbentry($sql); + if (keys(%$res) > 0) { + my $hostkey = $res->{1}->{'hostkey'}; + &send_msg_to_target($msg, $target, $hostkey, $header, $session_id); + $done = 1; + } + } + + + } + return; } diff --git a/gosa-si/modules/GosaPackages.pm b/gosa-si/modules/GosaPackages.pm index 8976fa113..8f0e76eea 100644 --- a/gosa-si/modules/GosaPackages.pm +++ b/gosa-si/modules/GosaPackages.pm @@ -51,7 +51,7 @@ $gosa_mac_address= &get_mac($network_interface); if( inet_aton($server_ip) ){ $server_ip = inet_ntoa(inet_aton($server_ip)); } our $server_address = "$server_ip:$server_port"; if( inet_aton($gosa_ip) ){ $gosa_ip = inet_ntoa(inet_aton($gosa_ip)); } -my $gosa_address = "$gosa_ip:$gosa_port"; +$main::gosa_address = "$gosa_ip:$gosa_port"; # create general settings for this module #y $gosa_cipher = &create_ciphering($gosa_passwd); @@ -73,7 +73,7 @@ if ($error == 0) { ## FUNCTIONS ################################################################# sub get_module_info { - my @info = ($gosa_address, + my @info = ($main::gosa_address, $gosa_passwd, ); return \@info; diff --git a/gosa-si/server/events/server_server_com.pm b/gosa-si/server/events/server_server_com.pm index c2f8e7708..81cc4c0e5 100644 --- a/gosa-si/server/events/server_server_com.pm +++ b/gosa-si/server/events/server_server_com.pm @@ -43,6 +43,7 @@ sub new_server { my $func_dic = {table=>$main::known_server_tn, primkey=>['hostname'], hostname => $source, + status => "new_server", hostkey => $key, timestamp=>&get_time(), }; diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index 5b4145f51..325c38680 100755 --- a/gosa-si/tests/client.php +++ b/gosa-si/tests/client.php @@ -66,7 +66,7 @@ for($count = 1; $count <= $zahl; $count++) #$data = "
gosa_trigger_action_reboot
00:01:6c:9d:b9:fa GOSA
"; #$data = "
job_trigger_action_reinstall
GOSA 00:01:6c:9d:b9:fa 00:01:6c:9d:b9:fa 19700101000000
"; #$data = "
job_trigger_action_instant_update
00:01:6c:9d:b9:fa GOSA 19700101000000
"; - $data = "
gosa_new_ping
00:01:6c:9d:b9:fa GOSA
"; + #$data = "
gosa_new_ping
00:01:6c:9d:b9:fa GOSA
"; # get_login_usr_for_client @@ -105,6 +105,8 @@ for($count = 1; $count <= $zahl; $count++) #$data = "
gosa_krb5_create_principal
00:01:6c:9d:aa:16 horst@WIRECARD.SYSGOSA666
"; #$data = "
gosa_krb5_modify_principal
00:01:6c:9d:b9:fa horst@WIRECARD.SYSGOSA666
"; + $data = "
new_ping
10.89.1.131:20081 GOSA
"; + $sock->write($data); $answer = "nothing"; $answer = $sock->read();