summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 76838e6)
raw | patch | inline | side by side (parent: 76838e6)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 19 May 2008 08:54:16 +0000 (08:54 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 19 May 2008 08:54:16 +0000 (08:54 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10946 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/debian/gosa-si-server.install | patch | blob | history | |
gosa-si/gosa-si-client | patch | blob | history | |
gosa-si/gosa-si-server-nobus | patch | blob | history | |
gosa-si/modules/GosaSupportDaemon.pm | patch | blob | history | |
gosa-si/modules/ServerPackages.pm | [new file with mode: 0644] | patch | blob |
gosa-si/server.conf | patch | blob | history |
index d858ee01e7ac234e489b908db408acafb43e99f8..843f0d7cb68dd033a1231b92e9ec7b2e677223aa 100644 (file)
gosa-si-bus usr/sbin
server.conf etc/gosa-si
bus.conf etc/gosa-si
-modules/SIPackages.pm usr/lib/gosa-si/modules
-modules/GosaPackages.pm usr/lib/gosa-si/modules
-modules/ArpHandler.pm usr/lib/gosa-si/modules
-modules/oui.txt usr/lib/gosa-si/modules
+modules/SIPackages.pm usr/lib/gosa-si/modules
+modules/GosaPackages.pm usr/lib/gosa-si/modules
+modules/ArpHandler.pm usr/lib/gosa-si/modules
+modules/oui.txt usr/lib/gosa-si/modules
+modules/ServerPackages.pm usr/lib/gosa-si/modules
server/events/gosaTriggered.pm usr/lib/gosa-si/server/events
server/events/siTriggered.pm usr/lib/gosa-si/server/events
server/events/clMessages.pm usr/lib/gosa-si/server/events
diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index 7330d128d4263c6fee1d3876f6a7651c02675705..a966c1a819f5dfd7ade57aa808a1c5909890eb2b 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
use Digest::MD5 qw(md5_hex md5 md5_base64);
use MIME::Base64;
use XML::Simple;
-use Net::DNS;
+#use Net::DNS; # no longer used because function moved to GosaSupportDaemon.pm : rettenbe : 16.05.2008
use File::Basename;
use File::Spec;
}
-sub get_server_addresses {
- my $domain= shift;
- my @result;
-
- my $error = 0;
- my $res = Net::DNS::Resolver->new;
- my $query = $res->send("_gosa-si._tcp.".$domain, "SRV");
- my @hits;
-
- if ($query) {
- foreach my $rr ($query->answer) {
- push(@hits, $rr->target.":".$rr->port);
- }
- }
- else {
- #warn "query failed: ", $res->errorstring, "\n";
- $error++;
- }
-
- if( $error == 0 ) {
- foreach my $hit (@hits) {
- my ($hit_name, $hit_port) = split(/:/, $hit);
- chomp($hit_name);
- chomp($hit_port);
-
- my $address_query = $res->send($hit_name);
- if( 1 == length($address_query->answer) ) {
- foreach my $rr ($address_query->answer) {
- push(@result, $rr->address.":".$hit_port);
- }
- }
- }
- }
-
- return @result;
-}
+# moved to GosaSupportDaemon: rettenbe: 16.05.2008
+#sub get_server_addresses {
+# my $domain= shift;
+# my @result;
+#
+# my $error = 0;
+# my $res = Net::DNS::Resolver->new;
+# my $query = $res->send("_gosa-si._tcp.".$domain, "SRV");
+# my @hits;
+#
+# if ($query) {
+# foreach my $rr ($query->answer) {
+# push(@hits, $rr->target.":".$rr->port);
+# }
+# }
+# else {
+# #warn "query failed: ", $res->errorstring, "\n";
+# $error++;
+# }
+#
+# if( $error == 0 ) {
+# foreach my $hit (@hits) {
+# my ($hit_name, $hit_port) = split(/:/, $hit);
+# chomp($hit_name);
+# chomp($hit_port);
+#
+# my $address_query = $res->send($hit_name);
+# if( 1 == length($address_query->answer) ) {
+# foreach my $rr ($address_query->answer) {
+# push(@result, $rr->address.":".$hit_port);
+# }
+# }
+# }
+# }
+#
+# return @result;
+#}
#=== FUNCTION ================================================================
@@ -1276,7 +1277,7 @@ daemon_log("start socket for incoming xml messages at port '$client_port' ", 1);
if( inet_aton($server_ip) ){ $server_ip = inet_ntoa(inet_aton($server_ip)); }
############################################################
# to change
-if( $server_ip eq "127.0.1.1" ) { $server_ip = "127.0.0.1" }
+#if( $server_ip eq "127.0.1.1" ) { $server_ip = "127.0.0.1" }
############################################################
if (defined $server_ip && defined $server_port) {
$server_address = $server_ip.":".$server_port;
index 886d908a1d76939e6126066fa21ea18362b34865..3e96edf461178f9a69630b7f15f58d32f2398035 100755 (executable)
$server_ip, $server_port, $SIPackages_key,
$arp_activ, $gosa_unit_tag,
$GosaPackages_key, $gosa_ip, $gosa_port, $gosa_timeout,
+ $foreign_server_string, $server_domain, $foreign_server_key
);
# additional variable which should be globaly accessable
},
"server" => {
"port" => [\$server_port, "20081"],
- "known-clients" => [\$known_clients_file_name, '/var/lib/gosa-si/clients.db' ],
- "known-servers" => [\$known_server_file_name, '/var/lib/gosa-si/servers.db'],
- "incoming" => [\$incoming_file_name, '/var/lib/gosa-si/incoming.db'],
- "login-users" => [\$login_users_file_name, '/var/lib/gosa-si/users.db'],
- "fai-server" => [\$fai_server_file_name, '/var/lib/gosa-si/fai_server.db'],
- "fai-release" => [\$fai_release_file_name, '/var/lib/gosa-si/fai_release.db'],
- "packages-list" => [\$packages_list_file_name, '/var/lib/gosa-si/packages.db'],
- "messaging" => [\$messaging_file_name, '/var/lib/gosa-si/messaging.db'],
- "source-list" => [\$sources_list, '/etc/apt/sources.list'],
- "repo-path" => [\$repo_path, '/srv/www/repository'],
- "ldap-uri" => [\$ldap_uri, ""],
- "ldap-base" => [\$ldap_base, ""],
- "ldap-admin-dn" => [\$ldap_admin_dn, ""],
- "ldap-admin-password" => [\$ldap_admin_password, ""],
- "gosa-unit-tag" => [\$gosa_unit_tag, ""],
- "max-clients" => [\$max_clients, 10],
+ "known-clients" => [\$known_clients_file_name, '/var/lib/gosa-si/clients.db' ],
+ "known-servers" => [\$known_server_file_name, '/var/lib/gosa-si/servers.db'],
+ "incoming" => [\$incoming_file_name, '/var/lib/gosa-si/incoming.db'],
+ "login-users" => [\$login_users_file_name, '/var/lib/gosa-si/users.db'],
+ "fai-server" => [\$fai_server_file_name, '/var/lib/gosa-si/fai_server.db'],
+ "fai-release" => [\$fai_release_file_name, '/var/lib/gosa-si/fai_release.db'],
+ "packages-list" => [\$packages_list_file_name, '/var/lib/gosa-si/packages.db'],
+ "messaging" => [\$messaging_file_name, '/var/lib/gosa-si/messaging.db'],
+ "source-list" => [\$sources_list, '/etc/apt/sources.list'],
+ "repo-path" => [\$repo_path, '/srv/www/repository'],
+ "ldap-uri" => [\$ldap_uri, ""],
+ "ldap-base" => [\$ldap_base, ""],
+ "ldap-admin-dn" => [\$ldap_admin_dn, ""],
+ "ldap-admin-password" => [\$ldap_admin_password, ""],
+ "gosa-unit-tag" => [\$gosa_unit_tag, ""],
+ "max-clients" => [\$max_clients, 10],
},
"GOsaPackages" => {
"ip" => [\$gosa_ip, "0.0.0.0"],
"SIPackages" => {
"key" => [\$SIPackages_key, "none"],
},
+"foreign-server"=> {
+ "address" => [\$foreign_server_string, ""],
+ "domain" => [\$server_domain, ""],
+ "key" => [\$foreign_server_key, "none"],
+}
);
daemon_log(" ", 1);
if (not -e $modules_path) {
- daemon_log("ERROR: cannot find directory or directory is not readable: $modules_path", 1);
+ daemon_log("0 ERROR: cannot find directory or directory is not readable: $modules_path", 1);
}
opendir (DIR, $modules_path) or die "ERROR while loading modules from directory $modules_path : $!\n";
eval { require $file; };
if ($@) {
- daemon_log("ERROR: gosa-si-server could not load module $file", 1);
+ daemon_log("0 ERROR: gosa-si-server could not load module $file", 1);
daemon_log("$@", 5);
} else {
my $info = eval($mod_name.'::get_module_info()');
if( $info ) {
my ($input_address, $input_key, $input, $input_active, $input_type) = @{$info};
$known_modules->{$mod_name} = $info;
- daemon_log("INFO: module $mod_name loaded", 5);
+ daemon_log("0 INFO: module $mod_name loaded", 5);
}
}
}
# import all modules
&import_modules;
+# 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);
+}
+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();
exit;
index a14d5def0d4621b96c32d9ade846b21e067987f7..c9b6f865ed6d0f774d24f9fdf180c8adf5d32449 100644 (file)
"get_limit_statement",
"get_orderby_statement",
"get_dns_domains",
+ "get_server_addresses",
"get_logged_in_users",
+ "import_events",
);
@EXPORT = @functions;
use strict;
use MIME::Base64;
use XML::Simple;
use Data::Dumper;
+use Net::DNS;
+
my $op_hash = {
'eq' => '=',
sub build_msg ($$$$) {
my ($header, $from, $to, $data) = @_;
+ # data is of form, i.e.
+ # %data= ('ip' => $address, 'mac' => $mac);
+
my $out_hash = &create_xml_hash($header, $from, $to);
while ( my ($key, $value) = each(%$data) ) {
}
+#############################################
+# moved from gosa-si-client: rettenbe, 16.05.2008
+# outcommented at gosa-si-client
+sub get_server_addresses {
+ my $domain= shift;
+ my @result;
+
+ my $error = 0;
+ my $res = Net::DNS::Resolver->new;
+ my $query = $res->send("_gosa-si._tcp.".$domain, "SRV");
+ my @hits;
+
+ if ($query) {
+ foreach my $rr ($query->answer) {
+ push(@hits, $rr->target.":".$rr->port);
+ }
+ }
+ else {
+ #warn "query failed: ", $res->errorstring, "\n";
+ $error++;
+ }
+
+ if( $error == 0 ) {
+ foreach my $hit (@hits) {
+ my ($hit_name, $hit_port) = split(/:/, $hit);
+ chomp($hit_name);
+ chomp($hit_port);
+
+ my $address_query = $res->send($hit_name);
+ if( 1 == length($address_query->answer) ) {
+ foreach my $rr ($address_query->answer) {
+ push(@result, $rr->address.":".$hit_port);
+ }
+ }
+ }
+ }
+
+ return @result;
+}
+
+
sub get_logged_in_users {
my $result = qx(/usr/bin/w -hs);
my @res_lines;
}
+
+sub import_events {
+ my ($event_dir)= @_;
+ my $error = 0;
+ my @result = ();
+
+ if (not -e $event_dir) {
+ $error++;
+ push(@result, "cannot find directory or directory is not readable: $event_dir");
+ }
+
+ my $DIR;
+ if ($error == 0) {
+ opendir (DIR, $event_dir) or sub {
+ $error++;
+ push(@result, "cannot open directory '$event_dir' for reading: $!\n");
+ }
+ }
+
+ if ($error == 0) {
+ while (defined (my $event = readdir (DIR))) {
+ if( $event eq "." || $event eq ".." ) { next; }
+ if ($event ne "server_server_com.pm") { next; }
+
+ # try to import event module
+ eval{ require $event; };
+ if( $@ ) {
+ $error++;
+ push(@result, "import of event module '$event' failed: $@");
+ next;
+ }
+
+ # fetch all single events
+ $event =~ /(\S*?).pm$/;
+ my $event_module = $1;
+ my $events_l = eval( $1."::get_events()") ;
+ foreach my $event_name (@{$events_l}) {
+ $event_hash->{$event_name} = $event_module;
+ }
+ my $events_string = join( ", ", @{$events_l});
+ push(@result, "import of event module '$event' succeed: $events_string");
+ }
+ }
+
+ return ($error, \@result);
+
+}
+
+
1;
diff --git a/gosa-si/modules/ServerPackages.pm b/gosa-si/modules/ServerPackages.pm
--- /dev/null
@@ -0,0 +1,40 @@
+package ServerPackages;
+
+use Exporter;
+@ISA = ("Exporter");
+
+# Each module has to have a function 'process_incoming_msg'. This function works as a interface to gosa-sd and receives the msg hash from gosa-sd. 'process_incoming_function checks, wether it has a function to process the incoming msg and forward the msg to it.
+
+use strict;
+use warnings;
+use GOSA::GosaSupportDaemon;
+
+#use IO::Socket::INET;
+#use XML::Simple;
+#use Data::Dumper;
+#use NetAddr::IP;
+#use Net::LDAP;
+#use Socket;
+#use Net::hostent;
+
+my $event_dir = "/usr/lib/gosa-si/server/events";
+use lib "/usr/lib/gosa-si/server/events";
+
+BEGIN{}
+END {}
+
+
+### START #####################################################################
+
+# read configfile and import variables
+#&read_configfile();
+
+sub get_module_info {
+ my @info = ($server_address,
+ $SIPackages_key,
+ );
+ return \@info;
+}
+
+
+1;
diff --git a/gosa-si/server.conf b/gosa-si/server.conf
index 8225c4fcfa0e7dd6db4a53d70f1493d7819b3732..00a54a2f53cf0b1ef9eb0d9d8781ba7214aa751e 100644 (file)
--- a/gosa-si/server.conf
+++ b/gosa-si/server.conf
enabled = true
key = secret-gosa-password
+[foreign-server]
+key = secret-foreign-key