Code

Added DBsqlite to sed rewrite.
[gosa.git] / gosa-si / gosa-si-server
index 2c4770cbc660b47ccc943b87ebe77c327ba41f8d..61528f048d6522cff65ef50d52481509ca95b314 100755 (executable)
@@ -542,7 +542,7 @@ sub check_key_and_xml_validity {
             # check header
             if( not exists $msg_hash->{'header'} ) { die "no header specified"; }
             my $header_l = $msg_hash->{'header'};
-            if( 1 > @{$header_l} ) { die 'empty header tag'; }
+            if( (1 > @{$header_l}) || ( ( 'HASH' eq ref @{$header_l}[0]) && (1 > keys %{@{$header_l}[0]}) ) ) { die 'empty header tag'; }
             if( 1 < @{$header_l} ) { die 'more than one header specified'; }
             my $header = @{$header_l}[0];
             if( 0 == length $header) { die 'empty string in header tag'; }
@@ -551,7 +551,7 @@ sub check_key_and_xml_validity {
             # check source
             if( not exists $msg_hash->{'source'} ) { die "no source specified"; }
             my $source_l = $msg_hash->{'source'};
-            if( 1 > @{$source_l} ) { die 'empty source tag'; }
+            if( (1 > @{$source_l}) || ( ( 'HASH' eq ref @{$source_l}[0]) && (1 > keys %{@{$source_l}[0]}) ) ) { die 'empty source tag'; }
             if( 1 < @{$source_l} ) { die 'more than one source specified'; }
             my $source = @{$source_l}[0];
             if( 0 == length $source) { die 'source error'; }
@@ -560,7 +560,7 @@ sub check_key_and_xml_validity {
             # check target
             if( not exists $msg_hash->{'target'} ) { die "no target specified"; }
             my $target_l = $msg_hash->{'target'};
-            if( 1 > @{$target_l} ) { die 'empty target tag'; }
+            if( (1 > @{$target_l}) || ( ('HASH' eq ref @{$target_l}[0]) && (1 > keys %{@{$target_l}[0]}) ) ) { die 'empty target tag'; }
         }
     };
     if($@) {
@@ -601,8 +601,18 @@ sub check_outgoing_xml_validity {
         if( 0 == length $source) {
             die 'source has length 0';
         }
+
+                               # Check if source contains hostname instead of ip address
+                               if(not $source =~ /^[a-z0-9\.]+:\d+$/i) {
+                                               my ($hostname,$port) = split(/:/, $source);
+                                               my $ip_address = inet_ntoa(scalar gethostbyname($hostname));
+                                               if(defined($ip_address) && $ip_address =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/ && $port =~ /^\d+$/) {
+                                                       # Write ip address to $source variable
+                                                       $source = "$ip_address:$port";
+                                               }
+                               }
         unless( $source =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+$/ ||
-                $source =~ /^GOSA$/i ) {
+                $source =~ /^GOSA$/i) {
             die "source '$source' is neither a complete ip-address with port nor 'GOSA'";
         }