From 92c2ea728675c34651fcd4f70bca7329fb3b3f90 Mon Sep 17 00:00:00 2001 From: rettenbe Date: Mon, 19 May 2008 10:51:05 +0000 Subject: [PATCH] * gosa-si-server-nobus * under construction git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10949 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-server-nobus | 5 +- gosa-si/modules/GosaPackages.pm | 72 +++++++++++++----------- gosa-si/modules/GosaSupportDaemon.pm | 14 +++-- gosa-si/modules/SIPackages.pm | 83 ++++++++++++++++------------ gosa-si/modules/ServerPackages.pm | 20 +++++-- gosa-si/tests/client.php | 8 +-- 6 files changed, 119 insertions(+), 83 deletions(-) diff --git a/gosa-si/gosa-si-server-nobus b/gosa-si/gosa-si-server-nobus index 3e96edf46..b48fe22a3 100755 --- a/gosa-si/gosa-si-server-nobus +++ b/gosa-si/gosa-si-server-nobus @@ -2772,6 +2772,9 @@ if ( !$server_domain) { 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); @@ -2783,7 +2786,7 @@ foreach my $foreign_server (@foreign_server_list) { 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 ) { diff --git a/gosa-si/modules/GosaPackages.pm b/gosa-si/modules/GosaPackages.pm index 0202e824f..56f0d6178 100644 --- a/gosa-si/modules/GosaPackages.pm +++ b/gosa-si/modules/GosaPackages.pm @@ -24,9 +24,6 @@ my ($server_ip, $server_port, $server_passwd, $max_clients); my ($gosa_ip, $gosa_mac_address, $gosa_port, $gosa_passwd, $network_interface); my ($job_queue_timeout, $job_queue_file_name); -my $gosa_server; -my $event_hash; - my %cfg_defaults = ( "server" => { "ip" => [\$server_ip, "0.0.0.0"], @@ -60,9 +57,18 @@ my $gosa_address = "$gosa_ip:$gosa_port"; #y $gosa_cipher = &create_ciphering($gosa_passwd); my $xml = new XML::Simple(); +# import local events +my ($error, $result, $event_hash) = &import_events($event_dir); +if ($error == 0) { + foreach my $log_line (@$result) { + &main::daemon_log("0 INFO: GosaPackages - $log_line", 5); + } +} else { + foreach my $log_line (@$result) { + &main::daemon_log("0 ERROR: GosaPackages - $log_line", 1); + } +} -# import events -&import_events(); ## FUNCTIONS ################################################################# @@ -221,34 +227,34 @@ sub get_ip { } -sub import_events { - if (not -e $event_dir) { - &main::daemon_log("G ERROR: cannot find directory or directory is not readable: $event_dir", 1); - } - opendir (DIR, $event_dir) or die "ERROR while loading gosa-si-events from directory $event_dir : $!\n"; - - while (defined (my $event = readdir (DIR))) { - if( $event eq "." || $event eq ".." ) { next; } - if( $event eq "siTriggered.pm" ) { next; } # SI specific events not needed in GosaPackages.pm - if( $event eq "clMessages.pm" ) { next; } # SI specific events not needed in GosaPackages.pm - - eval{ require $event; }; - if( $@ ) { - &main::daemon_log("G ERROR: import of event module '$event' failed", 1); - &main::daemon_log("$@", 1); - next; - } - - $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}); - &main::daemon_log("G DEBUG: GosaPackages from '$1' imported events $events_string", 8); - } -} +#sub import_events { +# if (not -e $event_dir) { +# &main::daemon_log("G ERROR: cannot find directory or directory is not readable: $event_dir", 1); +# } +# opendir (DIR, $event_dir) or die "ERROR while loading gosa-si-events from directory $event_dir : $!\n"; +# +# while (defined (my $event = readdir (DIR))) { +# if( $event eq "." || $event eq ".." ) { next; } +# if( $event eq "siTriggered.pm" ) { next; } # SI specific events not needed in GosaPackages.pm +# if( $event eq "clMessages.pm" ) { next; } # SI specific events not needed in GosaPackages.pm +# +# eval{ require $event; }; +# if( $@ ) { +# &main::daemon_log("G ERROR: import of event module '$event' failed", 1); +# &main::daemon_log("$@", 1); +# next; +# } +# +# $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}); +# &main::daemon_log("G DEBUG: GosaPackages from '$1' imported events $events_string", 8); +# } +#} #=== FUNCTION ================================================================ diff --git a/gosa-si/modules/GosaSupportDaemon.pm b/gosa-si/modules/GosaSupportDaemon.pm index c9b6f865e..41e02ac61 100644 --- a/gosa-si/modules/GosaSupportDaemon.pm +++ b/gosa-si/modules/GosaSupportDaemon.pm @@ -21,6 +21,7 @@ my @functions = ( "get_server_addresses", "get_logged_in_users", "import_events", + "del_doubles", ); @EXPORT = @functions; use strict; @@ -59,7 +60,11 @@ sub daemon_log { return; } - +sub del_doubles { + my %all; + $all{$_}=0 for @_; + return (keys %all); +} #=== FUNCTION ================================================================ @@ -465,10 +470,10 @@ sub get_logged_in_users { sub import_events { - my ($event_dir)= @_; + my ($event_dir) = @_; + my $event_hash; my $error = 0; my @result = (); - if (not -e $event_dir) { $error++; push(@result, "cannot find directory or directory is not readable: $event_dir"); @@ -485,7 +490,6 @@ sub import_events { 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; }; @@ -507,7 +511,7 @@ sub import_events { } } - return ($error, \@result); + return ($error, \@result, $event_hash); } diff --git a/gosa-si/modules/SIPackages.pm b/gosa-si/modules/SIPackages.pm index 39c26cf44..5e6fdeebb 100644 --- a/gosa-si/modules/SIPackages.pm +++ b/gosa-si/modules/SIPackages.pm @@ -25,7 +25,6 @@ END {} my ($server_ip, $server_port, $SIPackages_key, $max_clients, $ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $server_interface); my ($bus_activ, $bus_key, $bus_ip, $bus_port); my $server; -my $event_hash; my $network_interface; my $no_bus; my (@ldap_cfg, @pam_cfg, @nss_cfg, $goto_admin, $goto_secret); @@ -64,7 +63,19 @@ if( inet_aton($server_ip) ){ $server_ip = inet_ntoa(inet_aton($server_ip)); } $network_interface= &get_interface_for_ip($server_ip); $main::server_mac_address= &get_mac($network_interface); -&import_events(); + +# import local events +my ($error, $result, $event_hash) = &import_events($event_dir); +if ($error == 0) { + foreach my $log_line (@$result) { + &main::daemon_log("0 INFO: SIPackages - $log_line", 5); + } +} else { + foreach my $log_line (@$result) { + &main::daemon_log("0 ERROR: SIPackages - $log_line", 1); + } + +} # Unit tag can be defined in config if((not defined($main::gosa_unit_tag)) || length($main::gosa_unit_tag) == 0) { @@ -72,7 +83,7 @@ if((not defined($main::gosa_unit_tag)) || length($main::gosa_unit_tag) == 0) { my $ldap_handle = &main::get_ldap_handle(); if( defined($ldap_handle) ) { - &main::daemon_log("INFO: Searching for servers gosaUnitTag with mac address $main::server_mac_address",5); + &main::daemon_log("0 INFO: Searching for servers gosaUnitTag with mac address $main::server_mac_address",5); # Perform search for Unit Tag $mesg = $ldap_handle->search( base => $ldap_base, @@ -86,14 +97,14 @@ if((not defined($main::gosa_unit_tag)) || length($main::gosa_unit_tag) == 0) { my $unit_tag= $entry->get_value("gosaUnitTag"); $main::ldap_server_dn= $mesg->entry(0)->dn; if(defined($unit_tag) && length($unit_tag) > 0) { - &main::daemon_log("INFO: Detected gosaUnitTag $unit_tag for creating entries", 5); + &main::daemon_log("0 INFO: Detected gosaUnitTag $unit_tag for creating entries", 5); $main::gosa_unit_tag= $unit_tag; } } else { # Perform another search for Unit Tag my $hostname= `hostname -f`; chomp($hostname); - &main::daemon_log("INFO: Searching for servers gosaUnitTag with hostname $hostname",5); + &main::daemon_log("0 INFO: Searching for servers gosaUnitTag with hostname $hostname",5); $mesg = $ldap_handle->search( base => $ldap_base, scope => 'sub', @@ -105,14 +116,14 @@ if((not defined($main::gosa_unit_tag)) || length($main::gosa_unit_tag) == 0) { my $unit_tag= $entry->get_value("gosaUnitTag"); $main::ldap_server_dn= $mesg->entry(0)->dn; if(defined($unit_tag) && length($unit_tag) > 0) { - &main::daemon_log("INFO: Detected gosaUnitTag $unit_tag for creating entries", 5); + &main::daemon_log("0 INFO: Detected gosaUnitTag $unit_tag for creating entries", 5); $main::gosa_unit_tag= $unit_tag; } } else { # Perform another search for Unit Tag $hostname= `hostname -s`; chomp($hostname); - &main::daemon_log("INFO: Searching for servers gosaUnitTag with hostname $hostname",5); + &main::daemon_log("0 INFO: Searching for servers gosaUnitTag with hostname $hostname",5); $mesg = $ldap_handle->search( base => $ldap_base, scope => 'sub', @@ -128,12 +139,12 @@ if((not defined($main::gosa_unit_tag)) || length($main::gosa_unit_tag) == 0) { $main::gosa_unit_tag= $unit_tag; } } else { - &main::daemon_log("WARNING: No gosaUnitTag detected. Not using gosaUnitTag", 3); + &main::daemon_log("0 WARNING: No gosaUnitTag detected. Not using gosaUnitTag", 3); } } } } else { - &main::daemon_log("INFO: Using gosaUnitTag from config-file: $main::gosa_unit_tag",5); + &main::daemon_log("0 INFO: Using gosaUnitTag from config-file: $main::gosa_unit_tag",5); } } @@ -352,33 +363,35 @@ sub register_at_bus { } -sub import_events { - if (not -e $event_dir) { - &main::daemon_log("S ERROR: cannot find directory or directory is not readable: $event_dir", 1); - } - opendir (DIR, $event_dir) or die "ERROR while loading gosa-si-events from directory $event_dir : $!\n"; - - while (defined (my $event = readdir (DIR))) { - if( $event eq "." || $event eq ".." ) { next; } - if( $event eq "gosaTriggered.pm" ) { next; } # only GOsa specific events - - eval{ require $event; }; - if( $@ ) { - &main::daemon_log("S ERROR: import of event module '$event' failed", 1); - &main::daemon_log("$@", 8); - next; - } - $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}); - &main::daemon_log("S DEBUG: SIPackages imported events $events_string", 8); - } -} +# outcommented from rettenbe: moved to GosaSupportDaemon.pm +#sub import_events { +# if (not -e $event_dir) { +# &main::daemon_log("S ERROR: cannot find directory or directory is not readable: $event_dir", 1); +# } +# opendir (DIR, $event_dir) or die "ERROR while loading gosa-si-events from directory $event_dir : $!\n"; +# +# while (defined (my $event = readdir (DIR))) { +# if( $event eq "." || $event eq ".." ) { next; } +# if( $event eq "gosaTriggered.pm" ) { next; } # only GOsa specific events +# +# eval{ require $event; }; +# if( $@ ) { +# &main::daemon_log("S ERROR: import of event module '$event' failed", 1); +# &main::daemon_log("$@", 8); +# next; +# } +# +# $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}); +# &main::daemon_log("S DEBUG: SIPackages imported events $events_string", 8); +# } +#} #=== FUNCTION ================================================================ diff --git a/gosa-si/modules/ServerPackages.pm b/gosa-si/modules/ServerPackages.pm index 6c4f27583..4a4ddf643 100644 --- a/gosa-si/modules/ServerPackages.pm +++ b/gosa-si/modules/ServerPackages.pm @@ -26,13 +26,23 @@ END {} ### START ##################################################################### -# read configfile and import variables -#&read_configfile(); +# import local events +my ($error, $result, $event_hash) = &import_events($event_dir); +if ($error == 0) { + foreach my $log_line (@$result) { + &main::daemon_log("0 INFO: ServerPackages - $log_line", 5); + } +} else { + foreach my $log_line (@$result) { + &main::daemon_log("0 ERROR: ServerPackages - $log_line", 1); + } +} + +### FUNCTIONS ##################################################################### sub get_module_info { - my @info = ($server_address, - $SIPackages_key, - ); + my @info = ($main::server_address, + ); return \@info; } diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index bd44acbe5..5b4145f51 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_ping
00:01:6c:9d:b9:fa GOSA
"; + $data = "
gosa_new_ping
00:01:6c:9d:b9:fa GOSA
"; # get_login_usr_for_client @@ -83,7 +83,7 @@ for($count = 1; $count <= $zahl; $count++) ########### # messaging - + #$data = "
gosa_send_user_msg
GOSA GOSA ".base64_encode("eine wichtige nachricht")." admin polle rettenbe 20130101235959 ".base64_encode("kaffeepause")."
"; #$data = "
gosa_send_user_msg
GOSA GOSA ".base64_encode("eine wichtige nachricht")." admin polle rettenbe 20130101235959 ".base64_encode("kaffeepause")."
"; ################ @@ -102,8 +102,8 @@ for($count = 1; $count <= $zahl; $count++) ######### # Kerberos test query -# $data = "
gosa_krb5_create_principal
00:01:6c:9d:aa:16 horst@WIRECARD.SYSGOSA666
"; - $data = "
gosa_krb5_modify_principal
00:01:6c:9d:aa:16 horst@WIRECARD.SYSGOSA666
"; + #$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
"; $sock->write($data); $answer = "nothing"; -- 2.30.2