summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9c01f09)
raw | patch | inline | side by side (parent: 9c01f09)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 19 May 2008 15:09:02 +0000 (15:09 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 19 May 2008 15:09:02 +0000 (15:09 +0000) |
* under construction
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10957 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10957 594d385d-05f5-0310-b6e9-bd551577e9d8
index 25a091cb83cca5c38e35d816758fd23e043cbd09..a9f612b320b5d71c7d376de468ab8edf3becb7e0 100755 (executable)
$server_ip, $server_port, $ClientPackages_key,
$arp_activ, $gosa_unit_tag,
$GosaPackages_key, $gosa_ip, $gosa_port, $gosa_timeout,
- $foreign_server_string, $server_domain, $foreign_server_key
+ $foreign_server_string, $server_domain, $ServerPackages_key, $foreign_servers_register_delay,
);
# additional variable which should be globaly accessable
"ServerPackages"=> {
"address" => [\$foreign_server_string, ""],
"domain" => [\$server_domain, ""],
- "key" => [\$foreign_server_key, "none"],
+ "key" => [\$ServerPackages_key, "none"],
+ "key-lifetime" => [\$foreign_servers_register_delay, 600],
}
);
my $error_string;
my %act_modules = %$known_modules;
-
- while( my ($mod, $info) = each(%act_modules)) {
+
+ while( my ($mod, $info) = each(%act_modules)) {
# check a key exists for this module
my $module_key = ${$mod."_key"};
if( $act_status eq "down" ) {
$sql_statement = "DELETE FROM known_server WHERE hostname='$address'";
$res = $known_server_db->del_dbentry($sql_statement);
- daemon_log("$session_id WARNING: failed 2x to a send msg to host '$address', delete host from known_server", 3);
+ daemon_log("$session_id WARNING: failed 2x to send a message to host '$address', delete host from known_server", 3);
}
else {
$sql_statement = "UPDATE known_server SET status='$new_status' WHERE hostname='$address'";
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 );
$kernel->yield('create_fai_release_db', $fai_release_tn );
$kernel->sig(USR1 => "sig_handler");
}
+sub register_at_foreign_servers {
+ my ($kernel) = $_[KERNEL];
+
+ # hole alle bekannten server aus known_server_db
+ my $sql = "SELECT * FROM $known_server_tn";
+ my $res = $known_server_db->exec_statement($sql);
+
+ # no entries in known_server_db
+ if (not ref(@$res[0]) eq "ARRAY") {
+ # TODO
+ }
+
+ foreach my $hit (@$res) {
+ my $hostname = @$hit[0];
+ my $hostkey = &create_passwd;
+
+ my %data= ('known_clients' => "",
+ 'key' => $hostkey,
+ );
+ my $foreign_server_msg = &build_msg('new_server', $server_address, $hostname, \%data);
+ my $error = &send_msg_to_target($foreign_server_msg, $hostname, $ServerPackages_key, "new_server", 0);
+
+
+ }
+
+ $kernel->delay_set("register_at_foreign_servers", $foreign_servers_register_delay);
+ return;
+}
+
+
#==== MAIN = main ==============================================================
# parse commandline options
Getopt::Long::Configure( "bundling" );
$known_clients_db->create_table($known_clients_tn, \@known_clients_col_names);
# connect to known_server_db
+unlink($known_server_file_name);
$known_server_db = GOSA::DBsqlite->new($known_server_file_name);
$known_server_db->create_table($known_server_tn, \@known_server_col_names);
# create xml object used for en/decrypting
$xml = new XML::Simple();
-# create socket for incoming xml messages
+
+# foreign servers
+my @foreign_server_list;
+
+# add foreign server from cfg file
+if ($foreign_server_string ne "") {
+ my @cfg_foreign_server_list = split(",", $foreign_server_string);
+ foreach my $foreign_server (@cfg_foreign_server_list) {
+ push(@foreign_server_list, $foreign_server);
+ }
+}
+
+# add foreign server from dns
+my @tmp_servers;
+if ( !$server_domain) {
+ # Try our DNS Searchlist
+ for my $domain(get_dns_domains()) {
+ chomp($domain);
+ my @tmp_domains= &get_server_addresses($domain);
+ if(@tmp_domains) {
+ for my $tmp_server(@tmp_domains) {
+ push @tmp_servers, $tmp_server;
+ }
+ }
+ }
+ if(@tmp_servers && length(@tmp_servers)==0) {
+ daemon_log("0 WARNING: no foreign gosa-si-server found in DNS for domain '$server_domain'", 3);
+ }
+} else {
+ @tmp_servers = &get_server_addresses($server_domain);
+ if( 0 == @tmp_servers ) {
+ daemon_log("0 WARNING: no foreign gosa-si-server found in DNS for domain '$server_domain'", 3);
+ }
+}
+foreach my $server (@tmp_servers) {
+ unshift(@foreign_server_list, $server);
+}
+# eliminate duplicate entries
+@foreign_server_list = &del_doubles(@foreign_server_list);
+my $all_foreign_server = join(", ", @foreign_server_list);
+daemon_log("0 INFO: found foreign server in config file and DNS: $all_foreign_server", 5);
+
+# add all found foreign servers to known_server
+my $act_timestamp = &get_time();
+foreach my $foreign_server (@foreign_server_list) {
+ my $res = $known_server_db->add_dbentry( {table=>$known_server_tn,
+ primkey=>['hostname'],
+ hostname=>$foreign_server,
+ status=>'not_jet_registered',
+ hostkey=>"none",
+ timestamp=>$act_timestamp,
+ } );
+}
+
POE::Component::Server::TCP->new(
Port => $server_port,
@@ -2713,6 +2799,7 @@ daemon_log("start socket for incoming xml messages at port '$server_port' ", 1);
POE::Session->create(
inline_states => {
_start => \&_start,
+ register_at_foreign_servers => \®ister_at_foreign_servers,
sig_handler => \&sig_handler,
watch_for_new_messages => \&watch_for_new_messages,
watch_for_delivery_messages => \&watch_for_delivery_messages,
# TODO
# check wether all modules are gosa-si valid passwd check
-#############################################
-# send registration message to foreign server
-my @foreign_server_list;
-# add foreign server from cfg file
-if ($foreign_server_string ne "") {
- my @cfg_foreign_server_list = split(",", $foreign_server_string);
- foreach my $foreign_server (@cfg_foreign_server_list) {
- push(@foreign_server_list, $foreign_server);
- }
-}
-
-# add foreign server from dns
-my @tmp_servers;
-if ( !$server_domain) {
- # Try our DNS Searchlist
- for my $domain(get_dns_domains()) {
- chomp($domain);
- my @tmp_domains= &get_server_addresses($domain);
- if(@tmp_domains) {
- for my $tmp_server(@tmp_domains) {
- push @tmp_servers, $tmp_server;
- }
- }
- }
- if(@tmp_servers && length(@tmp_servers)==0) {
- daemon_log("0 WARNING: no foreign gosa-si-server found in DNS for domain '$server_domain'", 3);
- }
-} else {
- @tmp_servers = &get_server_addresses($server_domain);
- if( 0 == @tmp_servers ) {
- daemon_log("0 WARNING: no foreign gosa-si-server found in DNS for domain '$server_domain'", 3);
- }
-}
-foreach my $server (@tmp_servers) {
- unshift(@foreign_server_list, $server);
-}
-# eliminate duplicate entries
-@foreign_server_list = &del_doubles(@foreign_server_list);
-
-my $all_foreign_server = join(", ", @foreign_server_list);
-daemon_log("0 INFO: found foreign server in config file and DNS: $all_foreign_server", 5);
-
-# build messages
-foreach my $foreign_server (@foreign_server_list) {
- # do not send myself a 'new_server' registration!!!
- if ($foreign_server eq $server_address) { next;}
-
- print STDERR "foreign_server: $foreign_server\n";
- my %data= ('known_clients' => "",
- 'key' => "",
- );
- my $foreign_server_msg = &build_msg('new_server', $server_address, $foreign_server, \%data);
- my $error = &send_msg_to_target($foreign_server_msg, $foreign_server, $foreign_server_key, "new_server", 0);
- if ($error != 0 ) {
- daemon_log("0 WARNING: sending of 'new_server'-message to $foreign_server failed!", 3);
- }
-}
POE::Kernel->run();
index b3430e89d2046ed5160e24d0a3471cfc65b184a1..d2296f0508774c8b1318e1892c6bda1228f7812a 100644 (file)
use Exporter;
@ISA = qw(Exporter);
my @functions = (
+ "create_passwd",
"create_xml_hash",
"get_content_from_xml_hash",
"add_content2xml_hash",
my $DIR;
if ($error == 0) {
- opendir (DIR, $event_dir) or sub {
+ opendir ($DIR, $event_dir) or do {
$error++;
push(@result, "cannot open directory '$event_dir' for reading: $!\n");
}
}
if ($error == 0) {
- while (defined (my $event = readdir (DIR))) {
+ while (defined (my $event = readdir ($DIR))) {
if( $event eq "." || $event eq ".." ) { next; }
# try to import event module
my $events_string = join( ", ", @{$events_l});
push(@result, "import of event module '$event' succeed: $events_string");
}
+
+ close $DIR;
}
return ($error, \@result, $event_hash);
index 9e45163ab15712119b003247f93d55681f808e02..d70afd40e6a34e6df05a8198261ddd7f803677dc 100644 (file)
sub get_module_info {
my @info = ($main::server_address,
+ $main::foreign_server_key,
);
return \@info;
}
+sub process_incoming_msg {
+ my ($msg, $msg_hash, $session_id) = @_ ;
+ my $header = @{$msg_hash->{header}}[0];
+ my $source = @{$msg_hash->{source}}[0];
+ my @target_l = @{$msg_hash->{target}};
+
+ my @msg_l;
+ my @out_msg_l;
+
+ &main::daemon_log("$session_id DEBUG: ServerPackages: msg to process '$header'", 7);
+ if( exists $event_hash->{$header} ) {
+ # a event exists with the header as name
+ &main::daemon_log("$session_id INFO: found event '$header' at event-module '".$event_hash->{$header}."'", 5);
+ no strict 'refs';
+ @out_msg_l = &{$event_hash->{$header}."::$header"}($msg, $msg_hash, $session_id);
+ } else {
+ }
+
+ return @out_msg_l;
+}
1;
diff --git a/gosa-si/server/events/server_server_com.pm b/gosa-si/server/events/server_server_com.pm
index e146e2dd4d0138903501f6d6e1a3eda49cfaa341..2df9c7c2e02cb6a672064078410830994d8fd9dd 100644 (file)
sub new_server {
-
+print STDERR "hier kommt die logik von new_server\n";
}
1;
index d4d51a9f8a517cd2e71e7d4f71cae6c173cc5d01..18f59d7b56f281721030809846e33859612d1890 100755 (executable)
my $db_name;
-$db_name = "/var/lib/gosa-si/jobs.db";
-if (-e $db_name) {
- print "\n############################################################\n";
- my $table_name = "jobs";
- print "$db_name\n";
- print "$table_name\n";
- my $sqlite = GOSA::DBsqlite->new($db_name);
- my $col_names = $sqlite->get_table_columns($table_name);
-
- print join(', ', @{ $col_names } )."\n" ;
- my $answer = $sqlite->show_table($table_name);
- print $answer."\n";
-}
-
-
-$db_name = "/var/lib/gosa-si/clients.db";
-if (-e $db_name) {
- print "\n############################################################\n";
- my $table_name = "known_clients";
- print "$db_name\n";
- print "$table_name\n";
-
- my $sqlite = GOSA::DBsqlite->new($db_name);
- my $col_names = $sqlite->get_table_columns($table_name);
- print join(', ', @{ $col_names } )."\n" ;
- my $answer = $sqlite->show_table($table_name);
- print $answer."\n";
-}
-
-
$db_name = "/var/lib/gosa-si/servers.db";
if (-e $db_name) {
print "\n############################################################\n";
print $answer."\n";
}
-
-$db_name = "/var/lib/gosa-si/users.db";
-if (-e $db_name) {
- print "\n############################################################\n";
- my $table_name = "login_users";
- print "$db_name\n";
- print "$table_name\n";
-
- my $sqlite = GOSA::DBsqlite->new($db_name);
- my $col_names = $sqlite->get_table_columns($table_name);
- print join(', ', @{ $col_names } )."\n" ;
- my $answer = $sqlite->show_table($table_name);
- print $answer."\n";
-}
-
-
print "\nFINISH\n";