Code

bugfix: incoming msg with server mac address are now handled appropriatly
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 4 Sep 2008 09:01:46 +0000 (09:01 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 4 Sep 2008 09:01:46 +0000 (09:01 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@12361 594d385d-05f5-0310-b6e9-bd551577e9d8

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

index 0155f08b889ba7213d95e2a686689430f611ff3d..e2ca1c36d8d6a3095c271b594a65c2c8248ee83d 100755 (executable)
@@ -1057,12 +1057,24 @@ sub msg_to_decrypt {
                my $not_found_in_known_server_db = 0;
                my $not_found_in_foreign_clients_db = 0;
         my $local_address;
+        my $local_mac;
         my ($target_ip, $target_port) = split(':', $target);
+        
+        # Determine the local ip address if target is an ip address
                if ($target =~ /^\d+\.\d+\.\d+\.\d+:\d+$/) {
                        $local_address = &get_local_ip_for_remote_ip($target_ip).":$server_port";
                } else {
             $local_address = $server_address;
         }
+        
+        # Determine the local mac address if target is a mac address
+        if ($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})$/i) {
+            my $loc_ip = &get_local_ip_for_remote_ip($heap->{'remote_ip'});
+            my $network_interface= &get_interface_for_ip($loc_ip);
+            $local_mac = &get_mac_for_interface($network_interface);
+        } else {
+            $local_mac = $server_mac_address;
+        }
 
         # target and source is equal to GOSA -> process here
         if (not $done) {
@@ -1073,7 +1085,7 @@ sub msg_to_decrypt {
 
         # target is own address without forward_to_gosa-tag -> process here
         if (not $done) {
-            if (($target eq $local_address) && (not exists $msg_hash->{'forward_to_gosa'})) {
+            if ((($target eq $local_address) || ($target eq $local_mac) ) && (not exists $msg_hash->{'forward_to_gosa'})) {
                 $done = 1;
                 if ($source eq "GOSA") {
                     $msg =~ s/<\/xml>/<forward_to_gosa>$local_address,$session_id<\/forward_to_gosa><\/xml>/;
@@ -1106,7 +1118,7 @@ sub msg_to_decrypt {
             my $forward_to_gosa =  @{$msg_hash->{'forward_to_gosa'}}[0];
             my $gosa_at;
             my $gosa_session_id;
-            if (($target eq $local_address) && (defined $forward_to_gosa)){
+            if ((($target eq $local_address) || ($target eq $local_mac) ) && (defined $forward_to_gosa)){
                 my ($gosa_at, $gosa_session_id) = split(/,/, $forward_to_gosa);
                 if ($gosa_at ne $local_address) {
                     $done = 1;
@@ -1139,7 +1151,7 @@ sub msg_to_decrypt {
             my $forward_to_gosa =  @{$msg_hash->{'forward_to_gosa'}}[0];
             my $gosa_at;
             my $gosa_session_id;
-            if (($target eq $local_address) && (defined $forward_to_gosa)){
+            if ((($target eq $local_address) || ($target eq $local_mac) ) && (defined $forward_to_gosa)){
                 my ($gosa_at, $gosa_session_id) = split(/,/, $forward_to_gosa);
                 if ($gosa_at eq $local_address) {
                     my $session_reference = $kernel->ID_id_to_session($gosa_session_id);
@@ -1187,7 +1199,7 @@ sub msg_to_decrypt {
 
         # target is a server address -> forward to server
         if (not $done) {
-            $sql = "SELECT * FROM $known_server_tn WHERE hostname='$target'";
+            $sql = "SELECT * FROM $known_server_tn WHERE (hostname='$target' OR macaddress LIKE '$target')";
             $res = $known_server_db->select_dbentry($sql);
             if (keys(%$res) > 0) {
                 my $hostkey = $res->{1}->{'hostkey'};
@@ -1200,7 +1212,6 @@ sub msg_to_decrypt {
 
                 &send_msg_to_target($msg, $target, $hostkey, $header, $session_id);
                 $done = 1;
-                #print STDERR "target is a server address -> forward to server\n";
             } else {
                                $not_found_in_known_server_db = 1;
                        }
index 67e038f14478d5a451da728c67ca5988bc804ef0..71d64c2eb4eedcbf95733f9f330db469c0fc9b8a 100755 (executable)
@@ -77,7 +77,7 @@ for($count = 1; $count <= $zahl; $count++)
     #$data = "<xml> <header>gosa_get_client_for_login_usr</header> <target>GOSA</target> <source>GOSA</source> <usr>rettenbe</usr></xml>";
 
     # List all si-server providing opsi
-    #$data = "<xml> <header>gosa_get_hosts_with_module</header> <source>GOSA</source> <target>10.89.1.31:20081</target> <module_name>opsi_com</module_name> </xml>";
+    #$data = "<xml> <header>gosa_get_hosts_with_module</header> <source>GOSA</source> <target>10.3.67.111:20081</target> <module_name>mailqueue_com</module_name> </xml>";
 
     ##################
     # recreate fai dbs
@@ -88,7 +88,8 @@ for($count = 1; $count <= $zahl; $count++)
     ###########
     # messaging 
     #$data = "<xml> <header>gosa_send_user_msg</header> <target>GOSA</target> <source>GOSA</source> <subject>".base64_encode("eine wichtige nachricht")."</subject> <from>admin</from>  <user>polle</user> <user>harald</user> <delivery_time>20130101235959</delivery_time> <message>".base64_encode("kaffeepause")."</message> </xml>"; 
-    #$data = "<xml> <header>gosa_send_user_msg</header> <target>GOSA</target> <source>GOSA</source> <subject>".base64_encode("eine wichtige nachricht")."</subject> <from>admin</from> <delivery_time>20130101235959</delivery_time> <message>".base64_encode("kaffeepause")."</message> </xml>"; 
+    #$data = "<xml> <header>gosa_send_user_msg</header> <target>00:01:6c:9d:aa:16</target> <source>GOSA</source> <subject>".base64_encode("eine wichtige nachricht")."</subject> <from>admin</from> <user>polle</user> <user>harald</user> <delivery_time>20130101235959</delivery_time> <message>".base64_encode("kaffeepause")."</message> </xml>";
+    #$data = "<xml> <header>gosa_send_user_msg</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> <subject>".base64_encode("eine wichtige nachricht")."</subject> <from>admin</from> <user>polle</user> <user>harald</user> <delivery_time>20130101235959</delivery_time> <message>".base64_encode("kaffeepause")."</message> </xml>";
 
     ################
     # logHandling.pm