From b9b89b054a65e7653045b1258e7fc6a71cf97856 Mon Sep 17 00:00:00 2001 From: rettenbe Date: Fri, 22 Feb 2008 09:04:18 +0000 Subject: [PATCH] new function: GOsa can trigger new ldap config supply to client git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9052 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/client/events/corefunctions.pm | 13 ++++++++++++- gosa-si/gosa-si-server | 5 ++--- gosa-si/modules/GosaPackages.pm | 7 ++++--- gosa-si/modules/SIPackages.pm | 3 ++- gosa-si/server/events/gosaTriggered.pm | 8 +++++--- gosa-si/server/events/siTriggered.pm | 13 +++++++++++++ gosa-si/tests/client.php | 4 ++-- 7 files changed, 40 insertions(+), 13 deletions(-) diff --git a/gosa-si/client/events/corefunctions.pm b/gosa-si/client/events/corefunctions.pm index 72031d649..3a8d24502 100644 --- a/gosa-si/client/events/corefunctions.pm +++ b/gosa-si/client/events/corefunctions.pm @@ -1,7 +1,17 @@ package corefunctions; use Exporter; @ISA = qw(Exporter); -my @events = qw(get_events registered new_ldap_config new_key generate_hw_digest detect_hardware confirm_new_key ping import_events); +my @events = ( + "get_events", + "registered", + "new_ldap_config", + "new_key", + "generate_hw_digest", + "detect_hardware", + "confirm_new_key", + "ping", + "import_events", + ); @EXPORT = @events; use strict; @@ -270,6 +280,7 @@ sub new_ldap_config { } + sub new_key { # my ($msg_hash) = @_ ; my $new_server_key = &main::create_passwd(); diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 2ffe6f7d0..91a627c56 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -785,7 +785,7 @@ sub send_msg_to_target { # opensocket my $socket = &open_socket($address); if( !$socket ) { - daemon_log("cannot send ".$header."msg to $address , host not reachable", 1); + daemon_log("ERROR: cannot send ".$header."msg to $address , host not reachable", 1); $error++; } @@ -793,7 +793,7 @@ sub send_msg_to_target { # send xml msg print $socket $crypted_msg."\n"; - daemon_log("send ".$header."msg to $address", 1); + daemon_log("INFO: send ".$header."msg to $address", 5); daemon_log("message:\n$msg", 8); } @@ -850,7 +850,6 @@ sub send_msg_to_target { } } } - return $error; } diff --git a/gosa-si/modules/GosaPackages.pm b/gosa-si/modules/GosaPackages.pm index 14c5209ae..b3b6e2d84 100644 --- a/gosa-si/modules/GosaPackages.pm +++ b/gosa-si/modules/GosaPackages.pm @@ -229,12 +229,13 @@ sub import_events { while (defined (my $event = readdir (DIR))) { if( $event eq "." || $event eq ".." ) { next; } - if( $event eq "siTriggered.pm" ) { next; } # only SI specific events + 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("import of event module '$event' failed", 1); - &main::daemon_log("$@", 8); + &main::daemon_log("ERROR: import of event module '$event' failed", 1); + &main::daemon_log("$@", 1); next; } diff --git a/gosa-si/modules/SIPackages.pm b/gosa-si/modules/SIPackages.pm index f00ffbd57..933aade81 100644 --- a/gosa-si/modules/SIPackages.pm +++ b/gosa-si/modules/SIPackages.pm @@ -758,7 +758,7 @@ sub who_has_i_do { sub new_ldap_config { my ($address) = @_ ; - my $sql_statement= "SELECT * FROM known_clients WHERE hostname='$address'"; + my $sql_statement= "SELECT * FROM known_clients WHERE hostname='$address' OR macaddress='$address'"; my $res = $main::known_clients_db->select_dbentry( $sql_statement ); # check hit @@ -767,6 +767,7 @@ sub new_ldap_config { &main::daemon_log("ERROR: more or no hit found in known_clients_db by query by '$address'", 1); } + $address = $res->{1}->{hostname}; my $macaddress = $res->{1}->{macaddress}; my $hostkey = $res->{1}->{hostkey}; diff --git a/gosa-si/server/events/gosaTriggered.pm b/gosa-si/server/events/gosaTriggered.pm index 7273673ae..d243faf6b 100644 --- a/gosa-si/server/events/gosaTriggered.pm +++ b/gosa-si/server/events/gosaTriggered.pm @@ -4,7 +4,7 @@ use Exporter; my @events = ( "get_events", "gen_smb_hash", - "reload_ldap_config", + "trigger_reload_ldap_config", "ping", "network_completition", "set_activated_for_installation", @@ -111,12 +111,14 @@ sub detect_hardware { } -sub reload_ldap_config { +sub trigger_reload_ldap_config { my ($msg, $msg_hash) = @_ ; my $target = @{$msg_hash->{target}}[0]; + my $out_hash = &create_xml_hash("reload_ldap_config", $main::server_address, $main::server_address, $target); + my $out_msg = &create_xml_string($out_hash); my @out_msg_l; - push(@out_msg_l, &new_ldap_config($target)); + push(@out_msg_l, $out_msg); return @out_msg_l; } diff --git a/gosa-si/server/events/siTriggered.pm b/gosa-si/server/events/siTriggered.pm index 92f7670f0..dba8993cf 100644 --- a/gosa-si/server/events/siTriggered.pm +++ b/gosa-si/server/events/siTriggered.pm @@ -5,6 +5,7 @@ my @events = ( "got_ping", "detected_hardware", "trigger_wake", + "reload_ldap_config", ); @EXPORT = @events; @@ -62,6 +63,18 @@ sub read_configfile { } } + +sub reload_ldap_config { + my ($msg, $msg_hash, $session_id) = @_; + my $header = @{$msg_hash->{header}}[0]; + my $target = @{$msg_hash->{$header}}[0]; + + my $out_msg = &SIPackages::new_ldap_config($target); + my @out_msg_l = ( $out_msg ); + return @out_msg_l; +} + + sub got_ping { my ($msg, $msg_hash, $session_id) = @_; diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index 02efe6cb9..75aeedbce 100755 --- a/gosa-si/tests/client.php +++ b/gosa-si/tests/client.php @@ -27,10 +27,10 @@ if($sock->connected()){ #$data = "
gosa_gen_smb_hash
GOSAGOSAtester
"; # Reload ldap config -$data = "
gosa_reload_ldap_config
GOSA00:1B:77:04:8A:6C
"; +$data = "
gosa_trigger_reload_ldap_config
GOSA00:01:6c:9d:b9:fa
"; # update -$data = "
gosa_update_status_jobdb_entry
GOSAGOSA 00:01:6c:9d:b9:fa 23450101000000XXXXXXXXXXXXXXx
"; +#$data = "
gosa_update_status_jobdb_entry
GOSAGOSA 00:01:6c:9d:b9:fa 23450101000000XXXXXXXXXXXXXXx
"; #$data = "
gosa_update_status_jobdb_entry
GOSAGOSA waiting processing update
"; # query -- 2.30.2