From 8f6d0e150e9e52f2b88c7d3e3876ed1e361f54be Mon Sep 17 00:00:00 2001 From: rettenbe Date: Thu, 6 Dec 2007 07:48:57 +0000 Subject: [PATCH] gosa-sd-bus - enhanced debugging while decrypting and xml parsing of msgs git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8034 594d385d-05f5-0310-b6e9-bd551577e9d8 --- contrib/daemon/gosa-sc | 2 +- contrib/daemon/gosa-sd | 2 +- contrib/daemon/gosa-sd-bus | 68 ++++++++++++++++++++------------------ 3 files changed, 37 insertions(+), 35 deletions(-) diff --git a/contrib/daemon/gosa-sc b/contrib/daemon/gosa-sc index c8cd0f04a..1cc276f11 100755 --- a/contrib/daemon/gosa-sc +++ b/contrib/daemon/gosa-sc @@ -539,7 +539,7 @@ sub decrypt_msg { #=============================================================================== sub create_ciphering { my ($passwd) = @_; - $passwd = substr("$passwd"x32, 0, 32); + $passwd = substr("$passwd" x 32, 0, 32); my $my_cipher = Crypt::Rijndael->new($passwd , Crypt::Rijndael::MODE_CBC ); return $my_cipher; diff --git a/contrib/daemon/gosa-sd b/contrib/daemon/gosa-sd index ed72ccc5e..ef3eec74c 100755 --- a/contrib/daemon/gosa-sd +++ b/contrib/daemon/gosa-sd @@ -938,7 +938,7 @@ sub decrypt_msg { #=============================================================================== sub create_ciphering { my ($passwd) = @_; - $passwd = substr("$passwd"x32, 0, 32); + $passwd = substr("$passwd" x 32, 0, 32); my $my_cipher = Crypt::Rijndael->new($passwd , Crypt::Rijndael::MODE_CBC ); return $my_cipher; diff --git a/contrib/daemon/gosa-sd-bus b/contrib/daemon/gosa-sd-bus index f4282e39d..6010ff0e5 100755 --- a/contrib/daemon/gosa-sd-bus +++ b/contrib/daemon/gosa-sd-bus @@ -447,7 +447,7 @@ sub process_incoming_msg { } my $l = @valid_keys; - daemon_log("number of valid daemon_keys: $l\n", 7); + daemon_log("number of valid daemons: $l\n", 7); my ($msg, $msg_hash); my $msg_flag = 0; @@ -455,15 +455,17 @@ sub process_incoming_msg { # collect addresses from possible incoming clients foreach my $host_key (@valid_keys) { eval{ - daemon_log( "key: $host_key\n", 7); + daemon_log( "daemon: $host_key\n", 7); my $key_passwd = $known_daemons->{$host_key}->{passwd}; - daemon_log("key_passwd: $key_passwd\n", 7); + daemon_log("daemon_passwd: $key_passwd\n", 7); my $key_cipher = &create_ciphering($key_passwd); $msg = &decrypt_msg($crypted_msg, $key_cipher); + daemon_log("daemon decrypted msg: $msg", 7); $msg_hash = $xml->XMLin($msg, ForceArray=>1); }; if($@) { - daemon_log("key raise error", 7); + daemon_log("msg processing raise error", 7); + daemon_log("error string: $@", 7); $msg_flag += 1; } else { last; @@ -555,6 +557,35 @@ sub process_incoming_msg { #} +#=== FUNCTION ================================================================ +# NAME: create_passwd +# PARAMETERS: nothing +# RETURNS: new_passwd - string +# DESCRIPTION: creates a 32 bit long random passwd out of "a".."z","A".."Z",0..9 +#=============================================================================== +sub create_passwd { + my $new_passwd = ""; + for(my $i=0; $i<31; $i++) { + $new_passwd .= ("a".."z","A".."Z",0..9)[int(rand(62))] + } + return $new_passwd; +} + + +#=== FUNCTION ================================================================ +# NAME: create_ciphering +# PARAMETERS: passwd - string - used to create ciphering +# RETURNS: cipher - object +# DESCRIPTION: creates a Crypt::Rijndael::MODE_CBC object with passwd as key +#=============================================================================== +sub create_ciphering { + my ($passwd) = @_; + $passwd = substr("$passwd" x 32, 0, 32); + my $my_cipher = Crypt::Rijndael->new($passwd , Crypt::Rijndael::MODE_CBC ); + return $my_cipher; +} + + #=== FUNCTION ================================================================ # NAME: encrypt_msg # PARAMETERS: msg - string - message to encrypt @@ -811,35 +842,6 @@ sub send_msg_hash2all { } -#=== FUNCTION ================================================================ -# NAME: create_ciphering -# PARAMETERS: passwd - string - used to create ciphering -# RETURNS: cipher - object -# DESCRIPTION: creates a Crypt::Rijndael::MODE_CBC object with passwd as key -#=============================================================================== -sub create_ciphering { - my ($passwd) = @_; - $passwd = substr("$passwd"x32, 0, 32); - my $my_cipher = Crypt::Rijndael->new($passwd , Crypt::Rijndael::MODE_CBC ); - return $my_cipher; -} - - -#=== FUNCTION ================================================================ -# NAME: create_passwd -# PARAMETERS: nothing -# RETURNS: new_passwd - string -# DESCRIPTION: creates a 32 bit long random passwd out of "a".."z","A".."Z",0..9 -#=============================================================================== -sub create_passwd { - my $new_passwd = ""; - for(my $i=0; $i<31; $i++) { - $new_passwd .= ("a".."z","A".."Z",0..9)[int(rand(62))] - } - return $new_passwd; -} - - #=== FUNCTION ================================================================ # NAME: here_i_am # PARAMETERS: msg_hash - hash - hash from function create_xml_hash -- 2.30.2