Code

gosa-si-server accepts mac addresses as answer_targets for own registered clients
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 6 Feb 2008 16:38:14 +0000 (16:38 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 6 Feb 2008 16:38:14 +0000 (16:38 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8761 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/gosa-si-server
gosa-si/tests/client.php

index a3764f4cdedf481179965270c7f6985acd88669c..e03855aa65a5631a58ed04801192914f9f18e27c 100755 (executable)
@@ -744,10 +744,6 @@ sub client_input {
         # for each answer in answer list
         foreach my $answer ( @{$answer_l} ) {
 
-
-            
-
-
             my $error = 0;
             # check answer if gosa-si envelope conform
             my $answer_hash = $xml->XMLin($answer, ForceArray=>1);
@@ -802,12 +798,29 @@ sub client_input {
                         &send_msg_to_target($answer, $host_name, $host_key, $answer_header);
                     }
                 }
+                elsif( $answer_target =~ /([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})/ ) {
+                    daemon_log("target is mac address '$answer_target', looking for host in known_clients", 3);
+                    my $sql_statement = "SELECT * FROM known_clients WHERE macaddress='$answer_target'";
+                    my $query_res = $known_clients_db->select_dbentry( $sql_statement );
+                    my $found_ip_flag = 0;
+                    while( my ($hit_num, $hit) = each %{ $query_res } ) {    
+                        my $host_name = $hit->{hostname};
+                        my $host_key = $hit->{hostkey};
+                        $answer =~ s/$answer_target/$host_name/g;
+                        daemon_log("found host '$host_name', assoziated to '$answer_target'", 3);
+                        &send_msg_to_target($answer, $host_name, $host_key, $answer_header);
+                        $found_ip_flag++ ;
+                    }   
+                    if( $found_ip_flag == 0) {
+                        daemon_log("ERROR: no host found in known_clients with mac address '$answer_target', answer could not be send", 1);
+                    }
+                }
                 else {
                     # answer is for one specific host
                     # get encrypt_key
                     my $encrypt_key = &get_encrypt_key($answer_target);
                     if( !$encrypt_key ) {
-                        daemon_log("ERROR: no encrypt key found for answer target '$answer_target'", 1);
+                        daemon_log("ERROR: no encrypt key found in known_clients or known_server for target '$answer_target'", 1);
                         daemon_log("\n$answer", 8);
                         next;
                     }
index 879de7550bd9bd871cf4b1fe0c953cd81eb44f91..ff33d537da1f0d0a9d94983d494941b2a33f16b5 100755 (executable)
@@ -45,7 +45,7 @@ if($sock->connected()){
 #$data = "<xml> <header>gosa_reinstall</header> <target>10.89.1.31:20083</target> <source>10.89.1.31:20081</source> </xml>";
 #$data = "<xml> <header>gosa_softupdate</header> <target>10.89.1.31:20083</target> <source>10.89.1.31:20081</source> </xml>";
 #$data = "<xml> <header>gosa_halt</header> <target>10.89.1.31:20083</target> <source>10.89.1.31:20081</source> </xml>";
-$data = "<xml> <header>gosa_new_key_for_client</header> <target>10.89.1.31:20083</target> <source>10.89.1.31:20081</source> </xml>";
+$data = "<xml> <header>gosa_new_key_for_client</header> <target>00:01:6c:9d:b9:fa</target> <source>10.89.1.31:20081</source> </xml>";
 
 
     $sock->write($data);