summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 55dd4be)
raw | patch | inline | side by side (parent: 55dd4be)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 12 Feb 2008 14:59:45 +0000 (14:59 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 12 Feb 2008 14:59:45 +0000 (14:59 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8874 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-server | patch | blob | history | |
gosa-si/modules/ArpHandler.pm | patch | blob | history | |
gosa-si/modules/SIPackages.pm | patch | blob | history | |
gosa-si/tests/client.php | patch | blob | history |
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index bdc990bea7e824f875f57849b8837f195610ba37..e4df616d29fcc7aa0976f2f00487b59bdaf7e1c6 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
use lib "/usr/lib/gosa-si/modules";
my (%cfg_defaults, $foreground, $verbose, $ping_timeout);
-my ($bus, $msg_to_bus, $bus_cipher);
+my ($bus_activ, $bus, $msg_to_bus, $bus_cipher);
my ($server, $server_mac_address);
my ($gosa_server, $job_queue_timeout, $job_queue_table_name, $job_queue_file_name,$job_queue_loop_delay);
my ($known_modules, $known_clients_file_name, $known_server_file_name);
$ping_timeout = 5;
$no_bus = 0;
+$bus_activ = "true";
$no_arp = 0;
"log-file" => [\$log_file, "/var/run/".$0.".log"],
"pid-file" => [\$pid_file, "/var/run/".$0.".pid"],
},
+"bus" => {
+ "activ" => [\$bus_activ, "true"],
+ },
"server" => {
# "ip" => [\$server_ip, "0.0.0.0"],
"port" => [\$server_port, "20081"],
# for each answer in answer list
foreach my $answer ( @{$answer_l} ) {
- my $error = 0;
- # check answer if gosa-si envelope conform
- if(defined($answer)) {
- my $answer_hash = $xml->XMLin($answer, ForceArray=>1);
- $answer_header = @{$answer_hash->{'header'}}[0];
- @answer_target_l = @{$answer_hash->{'target'}};
- $answer_source = @{$answer_hash->{'source'}}[0];
- if( !$answer_header ) {
- daemon_log('ERROR: module answer is not gosa-si envelope conform: no header', 1);
- daemon_log("\n$answer", 8);
- $error++;
- }
- if( 0 == length @answer_target_l ) {
- daemon_log('ERROR: module answer is not gosa-si envelope conform: no targets', 1);
- daemon_log("\n$answer", 8);
- $error++;
- }
- if( !$answer_source ) {
- daemon_log('ERROR: module answer is not gosa-si envelope conform: no source', 1);
- daemon_log("\n$answer", 8);
- $error++;
- }
-
- if( $error != 0 ) {
- next;
- }
- }
+ my $error = 0;
+ # check answer if gosa-si envelope conform
+ if(defined($answer)) {
+ my $answer_hash = $xml->XMLin($answer, ForceArray=>1);
+ $answer_header = @{$answer_hash->{'header'}}[0];
+ @answer_target_l = @{$answer_hash->{'target'}};
+ $answer_source = @{$answer_hash->{'source'}}[0];
+ if( !$answer_header ) {
+ daemon_log('ERROR: module answer is not gosa-si envelope conform: no header', 1);
+ daemon_log("\n$answer", 8);
+ $error++;
+ }
+ if( 0 == length @answer_target_l ) {
+ daemon_log('ERROR: module answer is not gosa-si envelope conform: no targets', 1);
+ daemon_log("\n$answer", 8);
+ $error++;
+ }
+ if( !$answer_source ) {
+ daemon_log('ERROR: module answer is not gosa-si envelope conform: no source', 1);
+ daemon_log("\n$answer", 8);
+ $error++;
+ }
- # deliver msg to all targets
- foreach my $answer_target ( @answer_target_l ) {
- if( $answer_target eq "*" ) {
- # answer is for all clients
- my $sql_statement= "SELECT * FROM known_clients";
- my $query_res = $known_clients_db->select_dbentry( $sql_statement );
- while( my ($hit_num, $hit) = each %{ $query_res } ) {
- my $host_name = $hit->{hostname};
- my $host_key = $hit->{hostkey};
- &send_msg_to_target($answer, $host_name, $host_key, $answer_header);
- }
- }
- elsif( $answer_target eq "GOSA" ) {
- # answer is for GOSA and has to returned to connected client
- my $gosa_answer = &encrypt_msg($answer, $GosaPackages_key);
- $client_answer = $gosa_answer;
- }
- elsif( $answer_target eq "KNOWN_SERVER" ) {
- # answer is for all server in known_server
- my $sql_statement= "SELECT * FROM known_server";
- my $query_res = $known_server_db->select_dbentry( $sql_statement );
- while( my ($hit_num, $hit) = each %{ $query_res } ) {
- my $host_name = $hit->{hostname};
- my $host_key = $hit->{hostkey};
- $answer =~ s/KNOWN_SERVER/$host_name/g;
- &send_msg_to_target($answer, $host_name, $host_key, $answer_header);
- }
- }
- elsif( $answer_target =~ /^([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})$/i ) {
- daemon_log("target is mac address '$answer_target', looking for host in known_clients", 3);
- my $sql_statement = "SELECT * FROM known_clients WHERE macaddress='$answer_target'";
- my $query_res = $known_clients_db->select_dbentry( $sql_statement );
- my $found_ip_flag = 0;
- while( my ($hit_num, $hit) = each %{ $query_res } ) {
- my $host_name = $hit->{hostname};
- my $host_key = $hit->{hostkey};
- $answer =~ s/$answer_target/$host_name/g;
- daemon_log("found host '$host_name', assoziated to '$answer_target'", 3);
- &send_msg_to_target($answer, $host_name, $host_key, $answer_header);
- $found_ip_flag++ ;
- }
- if( $found_ip_flag == 0) {
- daemon_log("WARNING: no host found in known_clients with mac address '$answer_target', forward msg to bus", 1);
- my $sql_statement = "SELECT * FROM known_server WHERE hostname='$bus_address'";
- my $query_res = $known_server_db->select_dbentry( $sql_statement );
- while( my ($hit_num, $hit) = each %{ $query_res } ) {
- my $bus_address = $hit->{hostname};
- my $bus_key = $hit->{hostkey};
- &send_msg_to_target($answer, $bus_address, $bus_key, $answer_header);
- last;
- }
+ if( $error != 0 ) {
+ next;
+ }
+ }
- }
- } else {
- # ... answer is for one specific host
-
- # get encrypt_key
- my $encrypt_key = &get_encrypt_key($answer_target);
- if( not defined $encrypt_key ) {
- # unknown target, forward msg to bus
- daemon_log("WARNING: unknown target '$answer_target', forward msg to bus", 3);
- my $sql_statement = "SELECT * FROM known_server WHERE hostname='$bus_address'";
- my $query_res = $known_server_db->select_dbentry( $sql_statement );
- my $bus_key = $query_res->{1}->{hostkey};
- &send_msg_to_target($answer, $bus_address, $bus_key, $answer_header);
- next;
- }
- # send_msg
- &send_msg_to_target($answer, $answer_target, $encrypt_key, $answer_header);
- }
- }
- }
+ # deliver msg to all targets
+ foreach my $answer_target ( @answer_target_l ) {
+ if( $answer_target eq "*" ) {
+ # answer is for all clients
+ my $sql_statement= "SELECT * FROM known_clients";
+ my $query_res = $known_clients_db->select_dbentry( $sql_statement );
+ while( my ($hit_num, $hit) = each %{ $query_res } ) {
+ my $host_name = $hit->{hostname};
+ my $host_key = $hit->{hostkey};
+ &send_msg_to_target($answer, $host_name, $host_key, $answer_header);
+ }
+ }
+ elsif( $answer_target eq "GOSA" ) {
+ # answer is for GOSA and has to returned to connected client
+ my $gosa_answer = &encrypt_msg($answer, $GosaPackages_key);
+ $client_answer = $gosa_answer;
+ }
+ elsif( $answer_target eq "KNOWN_SERVER" ) {
+ # answer is for all server in known_server
+ my $sql_statement= "SELECT * FROM known_server";
+ my $query_res = $known_server_db->select_dbentry( $sql_statement );
+ while( my ($hit_num, $hit) = each %{ $query_res } ) {
+ my $host_name = $hit->{hostname};
+ my $host_key = $hit->{hostkey};
+ $answer =~ s/KNOWN_SERVER/$host_name/g;
+ &send_msg_to_target($answer, $host_name, $host_key, $answer_header);
+ }
+ }
+ elsif( $answer_target =~ /^([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})$/i ) {
+ daemon_log("target is mac address '$answer_target', looking for host in known_clients", 3);
+ my $sql_statement = "SELECT * FROM known_clients WHERE macaddress='$answer_target'";
+ my $query_res = $known_clients_db->select_dbentry( $sql_statement );
+ my $found_ip_flag = 0;
+ while( my ($hit_num, $hit) = each %{ $query_res } ) {
+ my $host_name = $hit->{hostname};
+ my $host_key = $hit->{hostkey};
+ $answer =~ s/$answer_target/$host_name/g;
+ daemon_log("found host '$host_name', assoziated to '$answer_target'", 3);
+ &send_msg_to_target($answer, $host_name, $host_key, $answer_header);
+ $found_ip_flag++ ;
+ }
+ if( $found_ip_flag == 0) {
+ daemon_log("WARNING: no host found in known_clients with mac address '$answer_target'", 3);
+ if( $bus_activ eq "true" ) {
+ daemon_log("INFO: try to forward msg '$answer_header' to bus '$bus_address'", 5);
+ my $sql_statement = "SELECT * FROM known_server WHERE hostname='$bus_address'";
+ my $query_res = $known_server_db->select_dbentry( $sql_statement );
+ while( my ($hit_num, $hit) = each %{ $query_res } ) {
+ my $bus_address = $hit->{hostname};
+ my $bus_key = $hit->{hostkey};
+ &send_msg_to_target($answer, $bus_address, $bus_key, $answer_header);
+ last;
+ }
+ }
+
+ }
+ } else {
+ # ... answer is for one specific host
+
+ # get encrypt_key
+ my $encrypt_key = &get_encrypt_key($answer_target);
+ if( not defined $encrypt_key ) {
+ # unknown target, forward msg to bus
+ daemon_log("WARNING: unknown target '$answer_target'", 3);
+ if( $bus_activ eq "true" ) {
+ daemon_log("INFO: try to forward msg '$answer_header' to bus '$bus_address'", 5);
+ my $sql_statement = "SELECT * FROM known_server WHERE hostname='$bus_address'";
+ my $query_res = $known_server_db->select_dbentry( $sql_statement );
+ my $bus_key = $query_res->{1}->{hostkey};
+ &send_msg_to_target($answer, $bus_address, $bus_key, $answer_header);
+ }
+ next;
+ }
+ # send_msg
+ &send_msg_to_target($answer, $answer_target, $encrypt_key, $answer_header);
+ }
+ }
+ }
}
if( $client_answer ) {
daemon_log(" ", 1);
daemon_log("$0 started!", 1);
+if ($no_bus > 0) {
+ $bus_activ = "false"
+}
+
+
+
# delete old DBsqlite lock files
#unlink('/tmp/gosa_si_lock*');
index f7ae23010f0fc96f7d29ddd29e12ad7575ad654f..c190342b19c2e01b10346dff4e4434013edc7b88 100644 (file)
"interface" => [\$arp_interface, "all"],
},
"server" => {
- "ldap_uri" => [\$ldap_uri, ""],
- "ldap_base" => [\$ldap_base, ""],
- "ldap_admin_dn" => [\$ldap_admin_dn, ""],
- "ldap_admin_password" => [\$ldap_admin_password, ""],
+ "ldap-uri" => [\$ldap_uri, ""],
+ "ldap-base" => [\$ldap_base, ""],
+ "ldap-admin-dn" => [\$ldap_admin_dn, ""],
+ "ldap-admin-password" => [\$ldap_admin_password, ""],
},
);
index b36fa497e92bf85d14dfce6b0f6f8ec3a38a38b5..bc1be2ff8cd024b3a19074c4a705927e18e09350 100644 (file)
},
"server" => {
"ip" => [\$server_ip, "0.0.0.0"],
- "mac_address" => [\$server_mac_address, "00:00:00:00:00"],
+ "mac-address" => [\$server_mac_address, "00:00:00:00:00"],
"port" => [\$server_port, "20081"],
"ldap-uri" => [\$ldap_uri, ""],
"ldap-base" => [\$ldap_base, ""],
- "ldap-admin_dn" => [\$ldap_admin_dn, ""],
- "ldap-admin_password" => [\$ldap_admin_password, ""],
+ "ldap-admin-dn" => [\$ldap_admin_dn, ""],
+ "ldap-admin-password" => [\$ldap_admin_password, ""],
"max-clients" => [\$max_clients, 100],
},
"SIPackages" => {
index fd2f5566835637074ec792192765607f52a6abf5..4f07e45428a45df8a4c93051e710c031e8f9e55f 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
#$data = "<xml> <header>gosa_halt</header> <target>10.89.1.31:20083</target> <source>10.89.1.31:20081</source> </xml>";
#$data = "<xml> <header>gosa_new_key_for_client</header> <target>00:01:6c:9d:b9:fa</target> <source>10.89.1.31:20081</source> </xml>";
#$data = "<xml> <header>gosa_new_key_for_client</header> <target>00:0c:29:bd:7b:e7</target> <source>10.89.1.31:20081</source> </xml>";
-#$data = "<xml> <header>gosa_new_key_for_client</header> <target>10.89.1.197:20083</target> <source>10.89.1.31:20081</source> </xml>";
-$data = "<xml> <header>gosa_new_key_for_client</header> <target>10.89.1.31:20083</target> <source>10.89.1.31:20081</source> </xml>";
+$data = "<xml> <header>gosa_new_key_for_client</header> <target>10.89.1.197:20083</target> <source>10.89.1.31:20081</source> </xml>";
+#$data = "<xml> <header>gosa_new_key_for_client</header> <target>10.89.1.31:20083</target> <source>10.89.1.31:20081</source> </xml>";
$sock->write($data);