From: rettenbe Date: Fri, 5 Jun 2009 08:53:24 +0000 (+0000) Subject: * change regex for outgoing messages, now '-' is allowed X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=41565aa38a22ed8bb1fba7895b16c512058f0e9d;p=gosa.git * change regex for outgoing messages, now '-' is allowed * hostnames as source in outgoing messages are substituted with ip:port git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13695 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 3bce9a9b7..e8dbfae9f 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -655,15 +655,17 @@ sub check_outgoing_xml_validity { die 'source has length 0'; } - # Check if source contains hostname instead of ip address - if($source =~ /^[a-z][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"; - } - } + # Check if source contains hostname instead of ip address + if($source =~ /^[a-z][\w-\.]+:\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"; + $msg_hash->{source}[0] = $source ; + $msg =~ s/.*<\/source>/$source<\/source>/; + } + } unless( $source =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:\d+$/ || $source =~ /^GOSA$/i) { die "source '$source' is neither a complete ip-address with port nor 'GOSA'"; @@ -695,7 +697,7 @@ sub check_outgoing_xml_validity { $msg_hash = undef; } - return ($msg_hash); + return ($msg, $msg_hash); } @@ -1527,7 +1529,7 @@ sub process_task { foreach my $answer ( @{$answer_l} ) { # check outgoing msg to xml validity - my $answer_hash = &check_outgoing_xml_validity($answer, $session_id); + my ($answer, $answer_hash) = &check_outgoing_xml_validity($answer, $session_id); if( not defined $answer_hash ) { next; } $answer_header = @{$answer_hash->{'header'}}[0]; diff --git a/gosa-si/tests/client.php b/gosa-si/tests/client.php index bcf3f3010..a6e88f97a 100755 --- a/gosa-si/tests/client.php +++ b/gosa-si/tests/client.php @@ -77,7 +77,7 @@ for($count = 1; $count <= $zahl; $count++) #$data = "
gosa_get_client_for_login_usr
GOSA GOSA rettenbe
"; # List all si-server providing opsi - $data = "
gosa_get_hosts_with_module
GOSA 00:0C:29:4C:4B:0C mailqueue_com
"; + $data = "
gosa_get_hosts_with_module
GOSA linux-cl-7:20081 opsi
"; # Send messages to a user and displayed message via konch #$data = "
gosa_send_user_msg
GOSA GOSA ".base64_encode("eine wichtige nachricht")." admin polle harald 20130101235959 ".base64_encode("kaffeepause")."
";