From 92d31c9402790dcff736bc75d1c76edc6e3c5c1e Mon Sep 17 00:00:00 2001 From: janw Date: Fri, 29 Feb 2008 10:58:48 +0000 Subject: [PATCH] Fixed typos. opts-file gets written when client received registration, not when registration message to server has been sended. LDAP_AVAILABLE="true" gets written to opts file when Ldap configuration for client is available. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9210 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/client/events/corefunctions.pm | 23 ++++++++++++++++++++--- gosa-si/gosa-si-client | 21 ++++++--------------- gosa-si/modules/GosaPackages.pm | 2 +- gosa-si/modules/SIPackages.pm | 18 ++++++++++++------ 4 files changed, 39 insertions(+), 25 deletions(-) diff --git a/gosa-si/client/events/corefunctions.pm b/gosa-si/client/events/corefunctions.pm index 074b04f52..6651fcf5d 100644 --- a/gosa-si/client/events/corefunctions.pm +++ b/gosa-si/client/events/corefunctions.pm @@ -90,7 +90,6 @@ sub daemon_log { return; } - sub registered { my ($msg, $msg_hash) = @_ ; @@ -106,12 +105,30 @@ sub registered { # set registration_flag to true my $out_hash = &create_xml_hash("registered", $main::client_address, $main::server_address); + # Write the MAC address to file + if(stat($main::opts_file)) { + unlink($main::opts_file); + } + + &main::daemon_log(Dumper($msg_hash),1); + my $opts_file_FH; + my $hostname= $main::client_dnsname; + $hostname =~ s/\..*$//; + open($opts_file_FH, ">$main::opts_file"); + print $opts_file_FH "MAC=\"$main::client_mac_address\"\n"; + print $opts_file_FH "IPADDRESS=\"$main::client_ip\"\n"; + print $opts_file_FH "HOSTNAME=\"$hostname\"\n"; + print $opts_file_FH "FQDN=\"$main::client_dnsname\"\n"; + if(defined(@{$msg_hash->{'ldap_available'}}) && + @{$msg_hash->{'ldap_available'}}[0] eq "true") { + print $opts_file_FH "LDAP_AVAILABLE=\"true\"\n"; + } + close($opts_file_FH); + my $out_msg = &create_xml_string($out_hash); return $out_msg; - } - sub server_leaving { my ($msg_hash) = @_ ; my $source = @{$msg_hash->{'source'}}[0]; diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index 237470160..afb51ba26 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -41,7 +41,7 @@ use File::Basename; my $event_dir = "/usr/lib/gosa-si/client/events"; use lib "/usr/lib/gosa-si/client/events"; -my ($cfg_file, %cfg_defaults, $foreground, $verbose, $pid_file, $opts_file, $procid, $pid, $log_file, $fai_logpath); +my (%cfg_defaults, $foreground, $verbose, $pid_file, $procid, $pid, $log_file, $fai_logpath); my ($server_ip, $server_port, $server_key, $server_timeout, $server_domain, $server_key_lifetime); my ($client_ip, $client_port, $client_mac_address, $ldap_enabled, $ldap_config, $pam_config, $nss_config); my $xml; @@ -55,8 +55,12 @@ $verbose= 1; # globalise variables which are used in imported events our $cfg_file; +our $opts_file; our $server_address; our $client_address; +our $client_ip; +our $client_mac_address; +our $client_dnsname; our $server_key; # default variables @@ -727,21 +731,8 @@ sub register_at_gosa_si_server { $client_ip= &get_local_ip_for_remote_ip(sprintf("%s", $server =~ /^([0-9\.]*?):.*$/)); $client_address= "$client_ip:$client_port"; $client_mac_address = $local_mac; + $client_dnsname = $dnsname; - # Write the MAC address to file - if(stat($opts_file)) { - unlink($opts_file); - } - - my $opts_file_FH; - my $hostname= $dnsname; - $hostname =~ s/\..*$//; - open($opts_file_FH, ">$opts_file"); - print $opts_file_FH "MAC=\"$local_mac\"\n"; - print $opts_file_FH "IPADDRESS=\"$client_ip\"\n"; - print $opts_file_FH "HOSTNAME=\"$hostname\"\n"; - print $opts_file_FH "FQDN=\"$dnsname\"\n"; - close($opts_file_FH); last; } else { $try_to_register++; diff --git a/gosa-si/modules/GosaPackages.pm b/gosa-si/modules/GosaPackages.pm index a230a309e..b4b37bb9b 100644 --- a/gosa-si/modules/GosaPackages.pm +++ b/gosa-si/modules/GosaPackages.pm @@ -317,7 +317,7 @@ sub process_gosa_msg { # if delivery not possible raise error and return if( not @out_msg_l ) { - &main::daemon_log("WARNING: GosaPackages got not answer from event handler '$header'", 3); + &main::daemon_log("WARNING: GosaPackages got no answer from event handler '$header'", 3); } elsif( 0 == @out_msg_l) { &main::daemon_log("ERROR: GosaPackages: no event handler or core function defined for '$header'", 1); } diff --git a/gosa-si/modules/SIPackages.pm b/gosa-si/modules/SIPackages.pm index 1859b3003..c17608677 100644 --- a/gosa-si/modules/SIPackages.pm +++ b/gosa-si/modules/SIPackages.pm @@ -427,7 +427,7 @@ sub process_incoming_msg { # if delivery not possible raise error and return if( not @out_msg_l ) { - &main::daemon_log("WARNING: SIPackages got not answer from event handler '$header'", 3); + &main::daemon_log("WARNING: SIPackages got no answer from event handler '$header'", 3); } elsif( 0 == @out_msg_l) { &main::daemon_log("ERROR: SIPackages: no event handler or core function defined for '$header'", 1); } @@ -561,8 +561,6 @@ sub here_i_am { # return acknowledgement to client $out_hash = &create_xml_hash("registered", $server_address, $source); - my $register_out = &create_xml_string($out_hash); - push(@out_msg_l, $register_out); # notify registered client to bus if( $bus_activ eq "on") { @@ -581,9 +579,17 @@ sub here_i_am { } # give the new client his ldap config + # Workaround: Send within the registration response, if the client will get an ldap config later my $new_ldap_config_out = &new_ldap_config($source); if( $new_ldap_config_out ) { - push(@out_msg_l, $new_ldap_config_out); + &add_content2xml_hash($out_hash, "ldap_available", "true"); + } + my $register_out = &create_xml_string($out_hash); + push(@out_msg_l, $register_out); + + # Really send the ldap config + if( $new_ldap_config_out ) { + push(@out_msg_l, $new_ldap_config_out); } my $hardware_config_out = &hardware_config($source, $gotoHardwareChecksum); @@ -682,7 +688,7 @@ sub new_ldap_config { $mesg = $main::ldap_handle->search( base => $ldap_base, scope => 'sub', attrs => ['dn', 'gotoLdapServer', 'gosaUnitTag', 'FAIclass'], - filter => "(&(objectClass=GOhard)(macaddress=$macaddress)(gotoMode=active))"); + filter => "(&(objectClass=GOhard)(macaddress=$macaddress)(gotoLdapServer=*))"); #$mesg->code && die $mesg->error; if($mesg->code) { &main::daemon_log($mesg->error, 1); @@ -695,7 +701,7 @@ sub new_ldap_config { &main::daemon_log("\tbase: $ldap_base", 1); &main::daemon_log("\tscope: sub", 1); &main::daemon_log("\tattrs: dn, gotoLdapServer", 1); - &main::daemon_log("\tfilter: (&(objectClass=GOhard)(macaddress=$macaddress))", 1); + &main::daemon_log("\tfilter: (&(objectClass=GOhard)(macaddress=$macaddress)(gotoLdapServer=*))", 1); return; } -- 2.30.2