summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b376365)
raw | patch | inline | side by side (parent: b376365)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 10 Dec 2007 08:41:54 +0000 (08:41 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 10 Dec 2007 08:41:54 +0000 (08:41 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8063 594d385d-05f5-0310-b6e9-bd551577e9d8
diff --git a/contrib/daemon/gosa-sc b/contrib/daemon/gosa-sc
index 3be13292237f7992d20e250ee5b2f374ea35b0e5..9f51134272a11739b150b2922601be3df5156120 100755 (executable)
--- a/contrib/daemon/gosa-sc
+++ b/contrib/daemon/gosa-sc
use Fcntl;
use IO::Socket::INET;
-use Crypt::CBC;
+use Crypt::Rijndael;
+use MIME::Base64;
use Digest::MD5 qw(md5 md5_hex md5_base64);
use XML::Simple;
use Data::Dumper;
push(@events, $file_name);
}
my $events = join(",", @events);
+ daemon_log("found events: $events", 1);
# fill in all possible servers
my @servers;
my $msg_hash;
eval {
my $decrypted_msg = &decrypt_msg($crypted_msg, $new_server_cipher);
+ daemon_log("decrypted register msg: $decrypted_msg", 5);
$msg_hash = $xml->XMLin($decrypted_msg, ForceArray=>1);
};
if($@) {
- daemon_log("cannot register at $server", 1);
- daemon_log("ERROR: do not understand the message:\n\t$crypted_msg" , 5);
+ daemon_log("ERROR: do not understand the incoming message:" , 5);
+ daemon_log("$@", 7);
} else {
my $header = &get_content_from_xml_hash($msg_hash, "header");
if($header eq "registered") {
sub encrypt_msg {
my ($msg, $my_cipher) = @_;
if(not defined $my_cipher) { print "no cipher object\n"; }
-
+ $msg = "\0"x(16-length($msg)%16).$msg;
my $crypted_msg = $my_cipher->encrypt($msg);
-
+ chomp($crypted_msg = &encode_base64($crypted_msg));
return $crypted_msg;
}
#===============================================================================
sub decrypt_msg {
my ($crypted_msg, $my_cipher) = @_ ;
+ $crypted_msg = &decode_base64($crypted_msg);
my $msg = $my_cipher->decrypt($crypted_msg);
+ $msg =~ s/\0*//g;
return $msg;
}
#===============================================================================
sub create_ciphering {
my ($passwd) = @_;
- $passwd = substr("$passwd" x 32, 0, 32);
- daemon_log("create_ciphering: new passwd: $passwd", 7);
-
+ $passwd = substr(md5_hex("$passwd") x 32, 0, 32);
my $iv = substr(md5_hex('GONICUS GmbH'),0, 16);
- my $my_cipher = Crypt::CBC->new(-key=>$passwd ,
- -cipher => 'Rijndael',
- -iv => $iv,
- -header => "none",
- );
+ #daemon_log("iv: $iv", 7);
+ #daemon_log("key: $passwd", 7);
+ my $my_cipher = Crypt::Rijndael->new($passwd , Crypt::Rijndael::MODE_CBC());
+ $my_cipher->set_iv($iv);
return $my_cipher;
}
sub read_from_socket {
my ($socket) = @_;
my $result = "";
- my $len = 16;
- while($len == 16){
- my $char;
- $len = sysread($socket, $char, 16);
- if($len != 16) { last }
- if($len != 16) { last }
+
+ $socket->blocking(1);
+ $result = <$socket>;
+
+ $socket->blocking(0);
+ while ( my $char = <$socket> ) {
+ if (not defined $char) { last }
$result .= $char;
}
return $result;
+
+
+
+# my ($socket) = @_;
+# my $result = "";
+# my $len = 16;
+# while($len == 16){
+# my $char;
+# $len = sysread($socket, $char, 16);
+# if($len != 16) { last }
+# if($len != 16) { last }
+# $result .= $char;
+# }
+# return $result;
}
daemon_log("crypted msg:", 7);
daemon_log("\t$crypted_msg", 7);
+ my $act_cipher = &create_ciphering($server_passwd);
+
# try to decrypt incoming msg
my ($msg, $msg_hash);
eval{
- $msg = &decrypt_msg($crypted_msg, $server_cipher);
+ $msg = &decrypt_msg($crypted_msg, $act_cipher);
$msg_hash = $xml->XMLin($msg, ForceArray=>1);
};
if($@) {
diff --git a/contrib/daemon/gosa-sd b/contrib/daemon/gosa-sd
index ee96e6205c06643ab1c10e0ecdc5ea1d412f73da..1b161528e63d72319db7bf774f7a96873e5e5af4 100755 (executable)
--- a/contrib/daemon/gosa-sd
+++ b/contrib/daemon/gosa-sd
my ($xml_hash) = @_ ;
my $xml_string = $xml->XMLout($xml_hash, RootName => 'xml');
$xml_string =~ s/[\n]+//g;
- daemon_log("create_xml_string:",7);
- daemon_log("$xml_string\n", 7);
+ #daemon_log("create_xml_string:",7);
+ #daemon_log("$xml_string\n", 7);
return $xml_string;
}
my ($crypted_msg, $my_cipher) = @_ ;
$crypted_msg = &decode_base64($crypted_msg);
my $msg = $my_cipher->decrypt($crypted_msg);
+ $msg =~ s/\0*//g;
return $msg;
}
$passwd = substr(md5_hex("$passwd") x 32, 0, 32);
my $iv = substr(md5_hex('GONICUS GmbH'),0, 16);
- daemon_log("iv: $iv", 7);
- daemon_log("key: $passwd", 7);
+ #daemon_log("iv: $iv", 7);
+ #daemon_log("key: $passwd", 7);
my $my_cipher = Crypt::Rijndael->new($passwd , Crypt::Rijndael::MODE_CBC());
$my_cipher->set_iv($iv);
return $my_cipher;
}
$in_msg .= $part_in_msg;
}
+ chomp($in_msg);
- daemon_log("process child read: $in_msg\n", 5);
+ daemon_log("process child read: $in_msg", 5);
if (not defined $in_msg) {
next;
- } elsif ($in_msg eq "done") {
+ } elsif ($in_msg =~ "done") {
delete $busy_child{$pid};
$free_child{$pid} = $child_hash;
my $act_client = $busy_child{$pid}{client_ref};
print $act_client $in_msg."\n";
my $act_pipe = $busy_child{$pid}{pipe_rd};
+ sleep(10);
close ($act_client);
delete $busy_child{$pid};
$free_child{$pid} = $child_hash;
index 9987d47f30681a08076658c71278309ba31b3975..7b6dbe3efe5be57fa2c98abb6741feb3500c4636 100755 (executable)
$passwd = substr(md5_hex("$passwd") x 32, 0, 32);
my $iv = substr(md5_hex('GONICUS GmbH'),0, 16);
- daemon_log("iv: $iv", 7);
- daemon_log("key: $passwd", 7);
+ #daemon_log("iv: $iv", 7);
+ #daemon_log("key: $passwd", 7);
my $my_cipher = Crypt::Rijndael->new($passwd , Crypt::Rijndael::MODE_CBC());
$my_cipher->set_iv($iv);
return $my_cipher;
my ($crypted_msg, $my_cipher) = @_ ;
$crypted_msg = &decode_base64($crypted_msg);
my $msg = $my_cipher->decrypt($crypted_msg);
+ $msg =~ s/^\0*//g;
return $msg;
}
my $header = &get_content_from_xml_hash($msg_hash, "header");
my $del_client = (&get_content_from_xml_hash($msg_hash, $header))[0];
- print Dumper $msg_hash;
-
if (not exists $known_daemons->{$source}->{$del_client}) {
daemon_log
}
index 48a9a60d07597cce7aae2c9827f14c199de4d267..fbce4bf9aff955c95032cd05167560084062bc59 100644 (file)
$msg = &main::decrypt_msg($crypted_msg, $gosa_cipher);
&main::daemon_log("GosaPackages: decrypted_msg: $msg", 7);
- #$msg_hash = $main::xml->XMLin($msg, ForceArray=>1);
+ $msg_hash = $main::xml->XMLin($msg, ForceArray=>1);
};
if($@) {
&main::daemon_log("ERROR: GosaPackages do not understand the message: $@", 1);
&main::daemon_log("GosaPackages: msg to process:", 5);
&main::daemon_log("\t$msg", 5);
- $msg = "GosaPackages got msg: ".$msg;
+ $msg = "gosaPackages hat was bekommen";
my $out_cipher = &main::create_ciphering($main::gosa_passwd);
my $out_msg = &main::encrypt_msg($msg, $out_cipher);
index 80d4c54fc05019278593b86a6bab86e22998b88a..78093aa535a8a24c166dced9e58d1f123bd7f621 100644 (file)
&main::daemon_log("ServerPackage: key_passwd: $key_passwd", 7);
my $key_cipher = &main::create_ciphering($key_passwd);
$msg = &main::decrypt_msg($crypted_msg, $key_cipher);
- &main::daemon_log("DEBUG: ServerPackages: decrypted msg: $msg", 7);
+ &main::daemon_log("ServerPackages: decrypted msg: $msg", 7);
$msg_hash = $main::xml->XMLin($msg, ForceArray=>1);
- my $tmp = printf Dumper $msg_hash;
- &main::daemon_log("DEBUG: ServerPackages: xml hash: $tmp", 7);
+ #my $tmp = printf Dumper $msg_hash;
+ #&main::daemon_log("DEBUG: ServerPackages: xml hash: $tmp", 7);
};
if($@) {
&main::daemon_log("ServerPackage: key raise error: $@", 7);