index d429ffe7b28baa017e37b066c4e152055b9498d6..e91aa4639d7eb7ab9ea45362e71116ccc038b3c0 100644 (file)
"get_login_usr_for_client",
"get_client_for_login_usr",
"gen_smb_hash",
+ "trigger_reload_syslog_config",
+ "trigger_reload_ntp_config",
"trigger_reload_ldap_config",
"ping",
"network_completition",
"send_user_msg",
"get_available_kernel",
"trigger_activate_new",
+ "get_hosts_with_module",
# "get_dak_keyring",
# "import_dak_key",
# "remove_dak_key",
#my $subject = &decode_base64(@{$msg_hash->{'subject'}}[0]); # just for debugging
my $subject = @{$msg_hash->{'subject'}}[0];
my $from = @{$msg_hash->{'from'}}[0];
- my @users = exists $msg_hash->{'users'} ? @{$msg_hash->{'users'}} : () ;
- my @groups = exists $msg_hash->{'groups'} ? @{$msg_hash->{'groups'}} : ();
+ my @users = exists $msg_hash->{'user'} ? @{$msg_hash->{'user'}} : () ;
+ my @groups = exists $msg_hash->{'group'} ? @{$msg_hash->{'group'}} : ();
my $delivery_time = @{$msg_hash->{'delivery_time'}}[0];
#my $message = &decode_base64(@{$msg_hash->{'message'}}[0]); # just for debugging
my $message = @{$msg_hash->{'message'}}[0];
# determine new message id
my $new_msg_id = 1;
- my $new_msg_id_sql = "SELECT MAX(CAST(id AS INTEGER)) FROM $main::messaging_tn";
+ my $new_msg_id_sql = "SELECT MAX(id) FROM $main::messaging_tn";
my $new_msg_id_res = $main::messaging_db->exec_statement($new_msg_id_sql);
if (defined @{@{$new_msg_id_res}[0]}[0] ) {
$new_msg_id = int(@{@{$new_msg_id_res}[0]}[0]);
@users = map(push(@receiver_l, "u_$_"), @users);
@groups = map(push(@receiver_l, "g_$_"), @groups);
+ # Sanitiy check of receivers list
+ if (@receiver_l == 0) {
+ &main::daemon_log("$session_id ERROR: 'send_usr_msg'-message contains neither a 'usr' nor a 'group' tag. No receiver specified.", 1);
+ return;
+ }
+
# add incoming message to messaging_db
my $func_dic = {table=>$main::messaging_tn,
primkey=>[],
}
+sub trigger_reload_syslog_config {
+ my ($msg, $msg_hash, $session_id) = @_ ;
+
+ # Sanity check of macaddress
+ # TODO
+
+ my $macaddress = @{$msg_hash->{macaddress}}[0];
+
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id=jobdb_id";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
+
+ my $out_msg = &ClientPackages::new_syslog_config($macaddress, $session_id);
+ my @out_msg_l = ( $out_msg );
+
+ return @out_msg_l;
+
+
+}
+
+sub trigger_reload_ntp_config {
+ my ($msg, $msg_hash, $session_id) = @_ ;
+
+ # Sanity check of macaddress
+ # TODO
+
+ my $macaddress = @{$msg_hash->{macaddress}}[0];
+
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id=jobdb_id";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
+
+ my $out_msg = &ClientPackages::new_ntp_config($macaddress, $session_id);
+ my @out_msg_l = ( $out_msg );
+
+ return @out_msg_l;
+
+}
sub trigger_reload_ldap_config {
my ($msg, $msg_hash, $session_id) = @_ ;
sub get_available_kernel {
- my ($msg, $msg_hash, $session_id) = @_;
-
- my $source = @{$msg_hash->{'source'}}[0];
- my $target = @{$msg_hash->{'target'}}[0];
- my $release= @{$msg_hash->{'release'}}[0];
-
- my @kernel;
- # Get Kernel packages for release
- my $sql_statement = "SELECT * FROM $main::packages_list_tn WHERE distribution='$release' AND package LIKE 'linux\-image\-%'";
- my $res_hash = $main::packages_list_db->select_dbentry($sql_statement);
- my %data;
- my $i=1;
-
- foreach my $package (keys %{$res_hash}) {
- $data{"answer".$i++}= $data{"answer".$i++}= ${$res_hash}{$package}->{'package'};
- }
- $data{"answer".$i++}= "default";
-
- my $out_msg = &build_msg("get_available_kernel", $target, $source, \%data);
- my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
- if (defined $forward_to_gosa) {
- $out_msg =~s/<\/xml>/<forward_to_gosa>$forward_to_gosa<\/forward_to_gosa><\/xml>/;
- }
-
- return ( $out_msg );
+ my ($msg, $msg_hash, $session_id) = @_;
+
+ my $source = @{$msg_hash->{'source'}}[0];
+ my $target = @{$msg_hash->{'target'}}[0];
+ my $fai_release= @{$msg_hash->{'fai_release'}}[0];
+
+ my @kernel;
+ # Get Kernel packages for release
+ my $sql_statement = "SELECT * FROM $main::packages_list_tn WHERE distribution='$fai_release' AND package LIKE 'linux\-image\-%'";
+ my $res_hash = $main::packages_list_db->select_dbentry($sql_statement);
+ my %data;
+ my $i=1;
+
+ foreach my $package (keys %{$res_hash}) {
+ $data{"answer".$i++}= $data{"answer".$i++}= ${$res_hash}{$package}->{'package'};
+ }
+ $data{"answer".$i++}= "default";
+
+ my $out_msg = &build_msg("get_available_kernel", $target, $source, \%data);
+ my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
+ if (defined $forward_to_gosa) {
+ $out_msg =~s/<\/xml>/<forward_to_gosa>$forward_to_gosa<\/forward_to_gosa><\/xml>/;
+ }
+
+ return ( $out_msg );
}
my $ldap_entry;
my $ogroup_entry;
my $changed_attributes_counter = 0;
+
+ my $activate_client = 0;
- eval {
-
- my $ldap_mesg= $ldap_handle->search(
- base => $main::ldap_base,
- scope => 'sub',
- filter => "(&(objectClass=gosaGroupOfnames)(cn=$ogroup))",
- );
- if($ldap_mesg->count == 1) {
- $ogroup_entry= $ldap_mesg->pop_entry();
- } elsif ($ldap_mesg->count == 0) {
- &main::daemon_log("ERROR: A GosaGroupOfNames with cn '$ogroup' was not found in base '".$main::ldap_base."'!", 1);
- } else {
- &main::daemon_log("ERROR: More than one ObjectGroups with cn '$ogroup' was found in base '".$main::ldap_base."'!", 1);
- }
-
- # build the base, use optional base parameter or take it from ogroup
- if(!(defined($base) && (length($base) > 0))) {
- # Subtract the ObjectGroup cn
- $base = $1 if $ogroup_entry->dn =~ /cn=$ogroup,ou=groups,(.*)$/;
- }
-
- # prepend ou=systems (configurable through config)
- $base = $main::new_systems_ou.",".$base;
-
- # Search for an existing entry (should be in ou=incoming)
- $ldap_mesg= $ldap_handle->search(
- base => $main::ldap_base,
- scope => 'sub',
- filter => "(&(objectClass=GOhard)(|(macAddress=$mac)(dhcpHWaddress=$mac)))",
- );
-
- # TODO: Find a way to guess an ip address for hosts with no ldap entry (MAC->ARP->IP)
-
- if($ldap_mesg->count == 1) {
- &main::daemon_log("DEBUG: One system with mac address '$mac' was found in base '".$main::ldap_base."'!", 6);
- # Get the entry from LDAP
- $ldap_entry= $ldap_mesg->pop_entry();
-
- if(!($ldap_entry->dn() eq "cn=".$ldap_entry->get_value('cn').",$base")) {
- # Move the entry to the new ou
- $ldap_entry->changetype('moddn');
- $ldap_entry->add(
- newrdn => "cn=".$ldap_entry->get_value('cn'),
- deleteoldrdn => 1,
- newsuperior => $base,
- );
- }
-
- }
-
- $ldap_mesg= $ldap_handle->search(
- base => $main::ldap_base,
- scope => 'sub',
- filter => "(&(objectClass=GOhard)(|(macAddress=$mac)(dhcpHWaddress=$mac)))",
- );
-
- # TODO: Find a way to guess an ip address for hosts with no ldap entry (MAC->ARP->IP)
-
- if($ldap_mesg->count == 1) {
- $ldap_entry= $ldap_mesg->pop_entry();
- # Check for needed objectClasses
- my $oclasses = $ldap_entry->get_value('objectClass', asref => 1);
- foreach my $oclass ("FAIobject", "GOhard") {
- if(!(scalar grep $_ eq $oclass, map {$_ => 1} @$oclasses)) {
- &main::daemon_log("Adding objectClass $oclass", 1);
- $ldap_entry->add(
- objectClass => $oclass,
- );
- my $oclass_result = $ldap_entry->update($ldap_handle);
- }
- }
-
- # Set FAIstate
- if(defined($ldap_entry->get_value('FAIstate'))) {
- if(!($ldap_entry->get_value('FAIstate') eq 'install')) {
- $ldap_entry->replace(
- 'FAIstate' => 'install'
- );
- my $replace_result = $ldap_entry->update($ldap_handle);
- }
- } else {
- $ldap_entry->add(
- 'FAIstate' => 'install'
- );
- my $add_result = $ldap_entry->update($ldap_handle);
- }
-
-
- } elsif ($ldap_mesg->count == 0) {
- # TODO: Create a new entry
- # $ldap_entry = Net::LDAP::Entry->new();
- # $ldap_entry->dn("cn=$mac,$base");
- &main::daemon_log("WARNING: No System with mac address '$mac' was found in base '".$main::ldap_base."'! Re-queuing job.", 4);
- $main::job_db->exec_statement("UPDATE jobs SET status = 'waiting', timestamp = '".&get_time()."' WHERE id = $jobdb_id");
- } else {
- &main::daemon_log("ERROR: More than one system with mac address '$mac' was found in base '".$main::ldap_base."'!", 1);
- }
-
- # Add to ObjectGroup
- if(!(scalar grep $_, map {$_ => 1} $ogroup_entry->get_value('member', asref => 1))) {
- $ogroup_entry->add (
- 'member' => $ldap_entry->dn(),
- );
- my $ogroup_result = $ogroup_entry->update($ldap_handle);
- if ($ogroup_result->code() != 0) {
- &main::daemon_log("ERROR: Updating the ObjectGroup '$ogroup' failed (code '".$ogroup_result->code()."') with '".$ogroup_result->{'errorMessage'}."'!", 1);
- }
- }
-
- # Finally set gotoMode to active
- if(defined($ldap_entry->get_value('gotoMode'))) {
- if(!($ldap_entry->get_value('gotoMode') eq 'active')) {
- $ldap_entry->replace(
- 'gotoMode' => 'active'
- );
- my $activate_result = $ldap_entry->update($ldap_handle);
- if ($activate_result->code() != 0) {
- &main::daemon_log("ERROR: Activating system '".$ldap_entry->dn()."' failed (code '".$activate_result->code()."') with '".$activate_result->{'errorMessage'}."'!", 1);
- }
- }
- } else {
- $ldap_entry->add(
- 'gotoMode' => 'active'
- );
- my $activate_result = $ldap_entry->update($ldap_handle);
- if ($activate_result->code() != 0) {
- &main::daemon_log("ERROR: Activating system '".$ldap_entry->dn()."' failed (code '".$activate_result->code()."') with '".$activate_result->{'errorMessage'}."'!", 1);
- }
- }
- };
- if($@) {
- &main::daemon_log("ERROR: activate_new failed with '$@'!", 1);
- }
+ if(defined($ogroup)) {
+ my $ldap_mesg= $ldap_handle->search(
+ base => $main::ldap_base,
+ scope => 'sub',
+ filter => "(&(objectClass=gosaGroupOfnames)(cn=$ogroup))",
+ );
+ if($ldap_mesg->count == 1) {
+ $ogroup_entry= $ldap_mesg->pop_entry();
+ } elsif ($ldap_mesg->count == 0) {
+ &main::daemon_log("$session_id ERROR: A GosaGroupOfNames with cn '$ogroup' was not found in base '".$main::ldap_base."'!", 1);
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET status = 'waiting' WHERE id = $jobdb_id");
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET timestamp = '".&get_time(10)."' WHERE id = $jobdb_id");
+ return undef;
+ } else {
+ &main::daemon_log("$session_id ERROR: More than one ObjectGroups with cn '$ogroup' was found in base '".$main::ldap_base."'!", 1);
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET status = 'waiting' WHERE id = $jobdb_id");
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET timestamp = '".&get_time(10)."' WHERE id = $jobdb_id");
+ return undef;
+ }
+
+ # build the base, use optional base parameter or take it from ogroup
+ if(!(defined($base) && (length($base) > 0))) {
+ # Subtract the ObjectGroup cn
+ $base = $1 if $ogroup_entry->dn =~ /cn=$ogroup,ou=groups,(.*)$/;
+ &main::daemon_log("$session_id DEBUG: New base for system with mac address '$mac' is '$base'", 5);
+ }
+ }
- # Delete job
- $main::job_db->exec_statement("DELETE FROM jobs WHERE id = $jobdb_id");
+ # prepend ou=systems (configurable through config)
+ $base = $main::new_systems_ou.",".$base;
- # create set_activated_for_installation message for delivery
- my $out_hash = &create_xml_hash("set_activated_for_installation", $source, $target);
- my $out_msg = &create_xml_string($out_hash);
- my @out_msg_l = ($out_msg);
+ # Search for an existing entry (should be in ou=incoming)
+ my $ldap_mesg= $ldap_handle->search(
+ base => $main::ldap_base,
+ scope => 'sub',
+ filter => "(&(objectClass=GOhard)(|(macAddress=$mac)(dhcpHWaddress=$mac)))",
+ );
- return @out_msg_l;
+ # TODO: Find a way to guess an ip address for hosts with no ldap entry (MAC->ARP->IP)
+ if($ldap_mesg->count == 1) {
+ &main::daemon_log("$session_id DEBUG: One system with mac address '$mac' was found in base '".$main::ldap_base."'!", 5);
+ # Get the entry from LDAP
+ $ldap_entry= $ldap_mesg->pop_entry();
+
+ if(!($ldap_entry->dn() eq "cn=".$ldap_entry->get_value('cn').",$base")) {
+ # Move the entry to the new ou
+ $ldap_entry->changetype('moddn');
+ $ldap_entry->add(
+ newrdn => "cn=".$ldap_entry->get_value('cn'),
+ deleteoldrdn => 1,
+ newsuperior => $base,
+ );
+ # To prevent replication problems just re-queue the job with 10 seconds in the future
+ my $moddn_result = $ldap_entry->update($ldap_handle);
+ if ($moddn_result->code() != 0) {
+ &main::daemon_log("$session_id ERROR: Moving the system with mac address '$mac' to new base '$base' failed (code '".$moddn_result->code()."') with '".$moddn_result->{'errorMessage'}."'!", 1);
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET status = 'waiting' WHERE id = $jobdb_id");
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET timestamp = '".&get_time(10)."' WHERE id = $jobdb_id");
+ return undef;
+ } else {
+ &main::daemon_log("$session_id INFO: System with mac address '$mac' was moved to base '".$main::ldap_base."'! Re-queuing job.", 4);
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET status = 'waiting' WHERE id = $jobdb_id");
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET timestamp = '".&get_time(10)."' WHERE id = $jobdb_id");
+ return undef;
+ }
+ }
+
+ } elsif ($ldap_mesg->count == 0) {
+ &main::daemon_log("$session_id WARNING: No System with mac address '$mac' was found in base '".$main::ldap_base."'! Re-queuing job.", 4);
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET status = 'waiting' WHERE id = $jobdb_id");
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET timestamp = '".&get_time(60)."' WHERE id = $jobdb_id");
+ return undef;
+ }
+
+ $ldap_mesg= $ldap_handle->search(
+ base => $main::ldap_base,
+ scope => 'sub',
+ filter => "(&(objectClass=GOhard)(|(macAddress=$mac)(dhcpHWaddress=$mac)))",
+ );
+
+ # TODO: Find a way to guess an ip address for hosts with no ldap entry (MAC->ARP->IP)
+ if($ldap_mesg->count == 1) {
+ $ldap_entry= $ldap_mesg->pop_entry();
+ # Check for needed objectClasses
+ my $oclasses = $ldap_entry->get_value('objectClass', asref => 1);
+ foreach my $oclass ("FAIobject", "GOhard", "gotoWorkstation") {
+ if(!(scalar grep $_ eq $oclass, map {$_ => 1} @$oclasses)) {
+ &main::daemon_log("$session_id INFO: Adding objectClass '$oclass' to system entry with mac adress '$mac'", 1);
+ $ldap_entry->add(
+ objectClass => $oclass,
+ );
+ my $oclass_result = $ldap_entry->update($ldap_handle);
+ if ($oclass_result->code() != 0) {
+ &main::daemon_log("$session_id ERROR: Adding the ObjectClass '$oclass' failed (code '".$oclass_result->code()."') with '".$oclass_result->{'errorMessage'}."'!", 1);
+ }
+ }
+ }
+
+ # Set FAIstate
+ if(defined($ldap_entry->get_value('FAIstate'))) {
+ if(!($ldap_entry->get_value('FAIstate') eq 'install')) {
+ $ldap_entry->replace(
+ 'FAIstate' => 'install'
+ );
+ my $replace_result = $ldap_entry->update($ldap_handle);
+ if ($replace_result->code() != 0) {
+ &main::daemon_log("$session_id ERROR: Setting the FAIstate to install failed with code '".$replace_result->code()."') and message '".$replace_result->{'errorMessage'}."'!", 1);
+ }
+ }
+ } else {
+ $ldap_entry->add(
+ 'FAIstate' => 'install'
+ );
+ my $add_result = $ldap_entry->update($ldap_handle);
+ if ($add_result->code() != 0) {
+ &main::daemon_log("$session_id ERROR: Setting the FAIstate to install failed with code '".$add_result->code()."') and message '".$add_result->{'errorMessage'}."'!", 1);
+ }
+ }
+
+
+ } elsif ($ldap_mesg->count == 0) {
+ # TODO: Create a new entry
+ # $ldap_entry = Net::LDAP::Entry->new();
+ # $ldap_entry->dn("cn=$mac,$base");
+ &main::daemon_log("$session_id WARNING: No System with mac address '$mac' was found in base '".$main::ldap_base."'! Re-queuing job.", 4);
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET status = 'waiting' WHERE id = $jobdb_id");
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET timestamp = '".&get_time(10)."' WHERE id = $jobdb_id");
+ return undef;
+ } else {
+ &main::daemon_log("$session_id ERROR: More than one system with mac address '$mac' was found in base '".$main::ldap_base."'!", 1);
+ }
+
+ # Add to ObjectGroup
+ if(!(scalar grep $_ eq $ldap_entry->dn, @{$ogroup_entry->get_value('member', asref => 1)})) {
+ $ogroup_entry->add (
+ 'member' => $ldap_entry->dn(),
+ );
+ my $ogroup_result = $ogroup_entry->update($ldap_handle);
+ if ($ogroup_result->code() != 0) {
+ &main::daemon_log("$session_id ERROR: Updating the ObjectGroup '$ogroup' failed (code '".$ogroup_result->code()."') with '".$ogroup_result->{'errorMessage'}."'!", 1);
+ }
+ } else {
+ &main::daemon_log("$session_id DEBUG: System with mac address '$mac' is already a member of ObjectGroup '$ogroup'.", 5);
+ }
+
+ # Finally set gotoMode to active
+ if(defined($ldap_entry->get_value('gotoMode'))) {
+ if(!($ldap_entry->get_value('gotoMode') eq 'active')) {
+ $ldap_entry->replace(
+ 'gotoMode' => 'active'
+ );
+ my $activate_result = $ldap_entry->update($ldap_handle);
+ if ($activate_result->code() != 0) {
+ &main::daemon_log("$session_id ERROR: Activating system '".$ldap_entry->dn()."' failed (code '".$activate_result->code()."') with '".$activate_result->{'errorMessage'}."'!", 1);
+ } else {
+ $activate_client = 1;
+ }
+ } else {
+ $activate_client = 1;
+ }
+ } else {
+ $ldap_entry->add(
+ 'gotoMode' => 'active'
+ );
+ my $activate_result = $ldap_entry->update($ldap_handle);
+ if ($activate_result->code() != 0) {
+ &main::daemon_log("$session_id ERROR: Activating system '".$ldap_entry->dn()."' failed (code '".$activate_result->code()."') with '".$activate_result->{'errorMessage'}."'!", 1);
+ } else {
+ $activate_client = 1;
+ }
+ }
+
+ if($activate_client == 1) {
+
+ # Create delivery list
+ my @out_msg_l;
+
+ # Set job to done
+ $main::job_db->exec_statement("UPDATE jobs SET status = 'done' WHERE id = $jobdb_id");
+
+ # Add new_ldap_config message to delivery list
+ my $ldap_out_msg = &ClientPackages::new_ldap_config($mac, $session_id);
+ push(@out_msg_l, $ldap_out_msg);
+
+ # create set_activated_for_installation message for delivery
+ my $out_hash = &create_xml_hash("set_activated_for_installation", $source, $target);
+ my $out_msg = &create_xml_string($out_hash);
+ push(@out_msg_l, $out_msg);
+
+ return @out_msg_l;
+ } else {
+ &main::daemon_log("$session_id WARNING: Activating system with mac address '$mac' failed! Re-queuing job.", 4);
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET status = 'waiting' WHERE id = $jobdb_id");
+ $main::job_db->exec_statement("UPDATE ".$main::job_queue_tn." SET timestamp = '".&get_time(10)."' WHERE id = $jobdb_id");
+ }
+ return undef;
}
# return @out_msg_l;
#}
+## @method get_hosts_with_module
+# Reports all GOsa-si-server providing the given module.
+# @param msg - STRING - xml message with tag get_hosts_with_module
+# @param msg_hash - HASHREF - message information parsed into a hash
+# @param session_id - INTEGER - POE session id of the processing of this message
+# @return out_msg - STRING - feedback to GOsa in success and error case
+sub get_hosts_with_module {
+ my ($msg, $msg_hash, $session_id) = @_;
+ my $source = @{$msg_hash->{'source'}}[0];
+ my $target = @{$msg_hash->{'target'}}[0];
+ my $header= @{$msg_hash->{'header'}}[0];
+ my $module_name = @{$msg_hash->{'module_name'}}[0];
+ my $out_hash = &create_xml_hash($header, $target, $source);
+
+ # Sanity check of module_name
+ if ((not exists $msg_hash->{'module_name'}) || (@{$msg_hash->{'module_name'}} != 1)) {
+ &add_content2xml_hash($out_hash, "error_string", "no module_name specified or module_name tag invalid");
+ &add_content2xml_hash($out_hash, "error", "module_name");
+ &main::daemon_log("$session_id ERROR: no module_name specified or module_name tag invalid: $msg", 1);
+ return (&create_xml_string($out_hash));
+ }
+
+ # Check localhost for module_name
+ if (exists @{$main::known_modules->{'GosaPackages'}}[2]->{$module_name}) {
+ my ($local_ip, $local_port) = split(/:/, $target);
+ my $network_interface= &get_interface_for_ip($local_ip);
+ my $local_mac = &get_mac_for_interface($network_interface);
+ &add_content2xml_hash($out_hash, "answer0", $local_mac);
+ }
+
+
+ my $out_msg = &create_xml_string($out_hash);
+
+ # Search for opsi hosts in server_db
+ my $sql = "SELECT * FROM $main::known_server_tn WHERE loaded_modules LIKE '%$module_name%'";
+ my $res = $main::known_server_db->select_dbentry($sql);
+ while (my ($hit_id, $hit_hash) = each %$res) {
+ $out_msg =~ s/<\/xml>/<result>host$hit_id<\/result> <\/xml>/;
+ my $host_infos = "<ip>".$hit_hash->{'hostname'}."</ip>";
+ $host_infos .= " <mac>".$hit_hash->{'macaddress'}."</mac>";
+ $out_msg =~ s/<\/xml>/\n<answer$hit_id> $host_infos <\/answer$hit_id> \n <\/xml>/;
+ }
+
+ return $out_msg;
+}
+
+
# vim:ts=4:shiftwidth:expandtab
1;