summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 664ac34)
raw | patch | inline | side by side (parent: 664ac34)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 28 May 2008 15:29:11 +0000 (15:29 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 28 May 2008 15:29:11 +0000 (15:29 +0000) |
* under construction
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11089 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11089 594d385d-05f5-0310-b6e9-bd551577e9d8
index 4529bcaa8620263745be8b77adfe76f3f62ff901..4fab869890287a40b1d083628adac29658f749df 100755 (executable)
# 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);
$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);
$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);
}
}
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 } ) {
$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/<source>GOSA<\/source>/<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;
}
index 8976fa1138ff97de6e860e468b7ecd7de39e8de6..8f0e76eea8c69a40a39b3d8fb2bd932bc528a94b 100644 (file)
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);
## 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 c2f8e770815a93e174d780ac96c05855df817f80..81cc4c0e5b0c596fe8acda61fc1cc5a260311004 100644 (file)
my $func_dic = {table=>$main::known_server_tn,
primkey=>['hostname'],
hostname => $source,
+ status => "new_server",
hostkey => $key,
timestamp=>&get_time(),
};
index 5b4145f51e4e21a23ad08ec37011da2c2bad3a03..325c38680dc227f5065b5c9b0c3064d0ae05b774 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
#$data = "<xml> <header>gosa_trigger_action_reboot</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
#$data = "<xml> <header>job_trigger_action_reinstall</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:01:6c:9d:b9:fa</macaddress> <timestamp>19700101000000</timestamp> </xml>";
#$data = "<xml> <header>job_trigger_action_instant_update</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> <timestamp>19700101000000</timestamp> </xml>";
- $data = "<xml> <header>gosa_new_ping</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
+ #$data = "<xml> <header>gosa_new_ping</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
# get_login_usr_for_client
#$data = "<xml> <header>gosa_krb5_create_principal</header> <target>00:01:6c:9d:aa:16</target> <principal>horst@WIRECARD.SYS</principal><source>GOSA</source><max_life>666</max_life></xml>";
#$data = "<xml> <header>gosa_krb5_modify_principal</header> <target>00:01:6c:9d:b9:fa</target> <principal>horst@WIRECARD.SYS</principal><source>GOSA</source><max_life>666</max_life></xml>";
+ $data = "<xml> <header>new_ping</header> <target>10.89.1.131:20081</target> <source>GOSA</source> <forward_to_gosa></forward_to_gosa> </xml>";
+
$sock->write($data);
$answer = "nothing";
$answer = $sock->read();