index d4ec76321c87bb9fb53b66929b8b38028194d559..b21fb33032e32616c13cdb62aed9c4726032ca73 100644 (file)
&main::daemon_log("0 ERROR: ClientPackages - $log_line", 1);
}
}
+# build vice versa event_hash, event_name => module
+my $event2module_hash = {};
+while (my ($module, $mod_events) = each %$event_hash) {
+ while (my ($event_name, $nothing) = each %$mod_events) {
+ $event2module_hash->{$event_name} = $module;
+ }
+
+}
# Unit tag can be defined in config
if((not defined($main::gosa_unit_tag)) || length($main::gosa_unit_tag) == 0) {
sub get_module_info {
my @info = ($server_address,
$ClientPackages_key,
+ $event_hash,
);
return \@info;
}
@out_msg_l = &here_i_am($msg, $msg_hash, $session_id)
} else {
# a event exists with the header as name
- if( exists $event_hash->{$header} ) {
- &main::daemon_log("$session_id INFO: found event '$header' at event-module '".$event_hash->{$header}."'", 5);
+ if( exists $event2module_hash->{$header} ) {
+ &main::daemon_log("$session_id INFO: found event '$header' at event-module '".$event2module_hash->{$header}."'", 5);
no strict 'refs';
- @out_msg_l = &{$event_hash->{$header}."::$header"}($msg, $msg_hash, $session_id);
+ @out_msg_l = &{$event2module_hash->{$header}."::$header"}($msg, $msg_hash, $session_id);
# if no event handler is implemented
} else {
push(@out_msg_l, $new_ldap_config_out);
}
+ # Send client hardware configuration
my $hardware_config_out = &hardware_config($msg, $msg_hash, $session_id);
if( $hardware_config_out ) {
push(@out_msg_l, $hardware_config_out);
}
# Send client ntp server
+ my $ntp_config_out = &new_ntp_config($mac_address, $session_id);
+ if ($ntp_config_out) {
+ push(@out_msg_l, $ntp_config_out);
+ }
-
+ # Send client syslog server
+ my $syslog_config_out = &new_syslog_config($mac_address, $session_id);
+ if ($syslog_config_out) {
+ push(@out_msg_l, $syslog_config_out);
+ }
# notify registered client to all other server
my %mydata = ( 'client' => $source, 'macaddress' => $mac_address);
}
+sub new_syslog_config {
+ my ($mac_address, $session_id) = @_;
+ my $syslog_msg;
+
+ # Build LDAP connection
+ my $ldap_handle = &main::get_ldap_handle($session_id);
+ if( not defined $ldap_handle ) {
+ &main::daemon_log("$session_id ERROR: cannot connect to ldap: $ldap_uri", 1);
+ return;
+ }
+
+ # Perform search
+ my $ldap_res = $ldap_handle->search( base => $ldap_base,
+ scope => 'sub',
+ attrs => ['gotoSyslogServer'],
+ filter => "(&(objectClass=GOhard)(macaddress=$mac_address))");
+ if($ldap_res->code) {
+ &main::daemon_log("$session_id ".$ldap_res->error, 1);
+ return;
+ }
+
+ # Sanity check
+ if ($ldap_res->count != 1) {
+ &main::daemon_log("$session_id ERROR: client with mac address $mac_address not found/unique/active - not sending syslog config".
+ "\n\tbase: $ldap_base".
+ "\n\tscope: sub".
+ "\n\tattrs: gotoSyslogServer".
+ "\n\tfilter: (&(objectClass=GOhard)(macaddress=$mac_address))", 1);
+ return;
+ }
+
+ my $entry= $ldap_res->entry(0);
+ my $dn = &Net::LDAP::Util::escape_dn_value($entry->dn);
+ my $syslog_server = $entry->get_value("gotoSyslogServer");
+
+ # If no syslog server is specified at host, just have a look at the object group of the host
+ # Perform object group search
+ if (not defined $syslog_server) {
+ my $ldap_res = $ldap_handle->search( base => $ldap_base,
+ scope => 'sub',
+ attrs => ['gotoSyslogServer'],
+ filter => "(&(objectClass=gosaGroupOfNames)(member=$dn))");
+ if($ldap_res->code) {
+ &main::daemon_log("$session_id ".$ldap_res->error, 1);
+ return;
+ }
+
+ # Sanity check
+ if ($ldap_res->count != 1) {
+ &main::daemon_log("$session_id ERROR: client with mac address $mac_address not found/unique/active - not sending syslog config".
+ "\n\tbase: $ldap_base".
+ "\n\tscope: sub".
+ "\n\tattrs: gotoSyslogServer".
+ "\n\tfilter: (&(objectClass=gosaGroupOfNames)(member=$dn))", 1);
+ return;
+ }
+
+ my $entry= $ldap_res->entry(0);
+ $syslog_server= $entry->get_value("gotoSyslogServer");
+ }
+
+ # Return if no syslog server specified
+ if (not defined $syslog_server) {
+ &main::daemon_log("$session_id WARNING: no syslog server specified for this host '$mac_address'", 3);
+ return;
+ }
+
+ # Add syslog server to 'syslog_config' message
+ my $syslog_msg_hash = &create_xml_hash("new_syslog_config", $server_address, $mac_address);
+ &add_content2xml_hash($syslog_msg_hash, "server", $syslog_server);
+
+ return &create_xml_string($syslog_msg_hash);
+}
+
+
sub new_ntp_config {
my ($address, $session_id) = @_;
my $ntp_msg;
}
my $entry= $ldap_res->entry(0);
- my $dn= $entry->dn;
+ my $dn = &Net::LDAP::Util::escape_dn_value($entry->dn);
my @ntp_servers= $entry->get_value("gotoNtpServer");
# If no ntp server is specified at host, just have a look at the object group of the host
# Sanity check
if ($mesg->count != 1) {
- &main::daemon_log("$session_id WARNING: client with mac address $macaddress not found/unique/active - not sending ldap config".
+ &main::daemon_log("$session_id ERROR: client with mac address $macaddress not found/unique/active - not sending ldap config".
"\n\tbase: $ldap_base".
"\n\tscope: sub".
"\n\tattrs: dn, gotoLdapServer".
}
# Sanity check
- if ($mesg->count == 0) {
- &main::daemon_log("$session_id WARNING: no LDAP informations found for client with filter '(&(objectClass=gosaGroupOfNames)(member=$dn))'", 3);
- return;
- } elsif ($mesg->count >= 2) {
- &main::daemon_log("$session_id ERROR: multiple LDAP informations found for client with filter '(&(objectClass=gosaGroupOfNames)(member=$dn))'", 1);
+ if ($mesg->count != 1) {
+ &main::daemon_log("$session_id ERROR: client with mac address $macaddress not found/unique/active - not sending ldap config".
+ "\n\tbase: $ldap_base".
+ "\n\tscope: sub".
+ "\n\tattrs: dn, gotoLdapServer, FAIclass".
+ "\n\tfilter: (&(objectClass=gosaGroupOfNames)(member=$escaped_dn))", 1);
return;
}
# complain if no ldap information found
if (@servers == 0) {
- &main::daemon_log("$session_id ERROR: no gotoLdapServer information for LDAP entry with filter '(&(objectClass=gosaGroupOfNames)(member=$dn))'");
+ &main::daemon_log("$session_id ERROR: no gotoLdapServer information for LDAP entry '$dn'", 1);
}
foreach $server (@servers){