From 5b1032e073b74baac4d255a8e45761c2d1cee82d Mon Sep 17 00:00:00 2001 From: rettenbe Date: Wed, 16 Jan 2008 16:08:06 +0000 Subject: [PATCH] bugfix: transform_msg2hash: xml_tags without a content are created as an empty hash in a list instead of an empty list workaround: all empty hashes in a xml_content are substituted with "none" git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8402 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-client | 12 ++++++------ gosa-si/modules/GosaSupportDaemon.pm | 19 +++++++++++++++++++ gosa-si/modules/ServerPackages.pm | 2 +- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client index 2e9fc52d7..69a5f7ffd 100755 --- a/gosa-si/gosa-si-client +++ b/gosa-si/gosa-si-client @@ -46,7 +46,7 @@ my ($input_socket, $rbits, $wbits, $ebits, $xml, $known_hosts, $ldap_enabled); my (@events); # default variables -my $event_dir = "/etc/gosa-si/client/events"; +my $event_dir = "/usr/lib/gosa-si/client/events"; $known_hosts = {}; $foreground = 0 ; %cfg_defaults = @@ -454,14 +454,14 @@ sub register_at_server { opendir(DIR, $event_dir) or daemon_log("cannot find directory $event_dir!\ngosa-si-client starts without any accepting events!", 1); my $file_name; - @events = (); + my @events_list = (); while(defined($file_name = readdir(DIR))){ if ($file_name eq "." || $file_name eq "..") { next; } - push(@events, $file_name); + push(@events_list, $file_name); } - my $events = join(",", @events); + my $events = join(",", @events_list); daemon_log("found events: $events", 1); # fill in all possible servers @@ -482,14 +482,14 @@ sub register_at_server { my ($rout, $wout, $reg_server); foreach my $server (@servers) { -# TODO : server abhängige macadress und ipadresse eintragen - # create msg hash my $register_hash = &create_xml_hash("here_i_am", $client_address, $server); &add_content2xml_hash($register_hash, "new_passwd", $new_server_passwd); &add_content2xml_hash($register_hash, "mac_address", $client_mac_address); &add_content2xml_hash($register_hash, "events", $events); + my $tmp = print Dumper $register_hash; + # send xml hash to server with general server passwd my $answer = &send_msg_hash2address($register_hash, $server, $server_passwd); diff --git a/gosa-si/modules/GosaSupportDaemon.pm b/gosa-si/modules/GosaSupportDaemon.pm index 002308e53..cf26ca49f 100644 --- a/gosa-si/modules/GosaSupportDaemon.pm +++ b/gosa-si/modules/GosaSupportDaemon.pm @@ -57,6 +57,25 @@ sub create_xml_hash { sub transform_msg2hash { my ($msg) = @_ ; my $hash = $xml->XMLin($msg, ForceArray=>1); + + # xml tags without a content are created as an empty hash + # substitute it with an empty list + while( my ($xml_tag, $xml_content) = each %{ $hash } ) { + if( 1 == @{ $xml_content } ) { + # there is only one element in xml_content list ... + my $element = @{ $xml_content }[0]; + if( ref($element) eq "HASH" ) { + # and this element is an hash ... + my $len_element = keys %{ $element }; + if( $len_element == 0 ) { + # and this hash is empty, then substitute the xml_content + # with an empty string in list + $hash->{$xml_tag} = [ "none" ]; + } + } + } + } + return $hash; } diff --git a/gosa-si/modules/ServerPackages.pm b/gosa-si/modules/ServerPackages.pm index 80b34bb16..350619f84 100644 --- a/gosa-si/modules/ServerPackages.pm +++ b/gosa-si/modules/ServerPackages.pm @@ -442,7 +442,7 @@ sub process_incoming_msg { my $header = @{$msg_hash->{header}}[0]; my $source = @{$msg_hash->{source}}[0]; - &main::daemon_log("receive '$header' at ServerPackages from $host", 1); + &main::daemon_log("recieve '$header' at ServerPackages from $host", 1); &main::daemon_log("ServerPackages: msg to process: \n$msg", 7); my @targets = @{$msg_hash->{target}}; -- 2.30.2