1 package GosaPackages;
3 use Exporter;
4 @ISA = ("Exporter");
6 # Each module has to have a function 'process_incoming_msg'. This function works as a interface to gosa-sd and recieves the msg hash from gosa-sd. 'process_incoming_function checks, wether it has a function to process the incoming msg and forward the msg to it.
9 use strict;
10 use warnings;
11 use GosaSupportDaemon;
13 BEGIN{}
15 END{}
18 ### START ##########################
20 # create general settings for this module
21 my $gosa_cipher = &create_ciphering($main::gosa_passwd);
23 sub get_module_tags {
25 # dort stehen drei packettypen, für die sich das modul anmelden kann, gosa-admin-packages,
26 # server-packages, client-packages
27 my %tag_hash = (gosa_admin_packages => "yes",
28 server_packages => "no",
29 client_packages => "no");
30 return \%tag_hash;
31 }
34 sub process_incoming_msg {
35 my ($crypted_msg) = @_ ;
36 if(not defined $crypted_msg) {
37 &main::daemon_log("function 'process_incoming_msg': got no msg", 7);
38 }
39 &main::daemon_log("GosaPackages: crypted_msg:$crypted_msg", 7);
40 &main::daemon_log("GosaPackages: crypted_msg len:".length($crypted_msg), 7);
42 $crypted_msg =~ /^([\s\S]*?)\.(\d{1,3}?)\.(\d{1,3}?)\.(\d{1,3}?)\.(\d{1,3}?)$/;
43 $crypted_msg = $1;
44 my $host = sprintf("%s.%s.%s.%s", $2, $3, $4, $5);
46 &main::daemon_log("GosaPackages: crypted_msg:$crypted_msg", 7);
47 &main::daemon_log("GosaPackages: crypted_msg len:".length($crypted_msg), 7);
50 # collect addresses from possible incoming clients
51 # only gosa is allowd as incoming client
52 &main::daemon_log("GosaPackages: host_key: $host", 7);
53 &main::daemon_log("GosaPackages: key_passwd: $main::gosa_passwd", 7);
55 $gosa_cipher = &main::create_ciphering($main::gosa_passwd);
56 # determine the correct passwd for deciphering of the incoming msgs
57 my $msg = "";
58 my $msg_hash;
59 eval{
60 $msg = &main::decrypt_msg($crypted_msg, $gosa_cipher);
61 &main::daemon_log("GosaPackages: decrypted_msg: $msg", 7);
63 $msg_hash = $main::xml->XMLin($msg, ForceArray=>1);
64 };
65 if($@) {
66 &main::daemon_log("WARNING: GosaPackages do not understand the message:", 5);
67 &main::daemon_log("$@", 7);
68 return;
69 }
71 &main::daemon_log("GosaPackages: msg for daemon from host:", 1);
72 &main::daemon_log("\t$host", 1);
73 &main::daemon_log("GosaPackages: msg to process:", 5);
74 &main::daemon_log("\t$msg", 5);
76 $msg = "gosaPackages hat was bekommen";
78 my $out_cipher = &main::create_ciphering($main::gosa_passwd);
79 my $out_msg = &main::encrypt_msg($msg, $out_cipher);
80 return $out_msg;
82 }
85 #=== FUNCTION ================================================================
86 # NAME: got_ping
87 # PARAMETERS: msg_hash - hash - hash from function create_xml_hash
88 # RETURNS: nothing
89 # DESCRIPTION: process this incoming message
90 #===============================================================================
91 sub got_ping {
92 my ($msg_hash) = @_;
94 my $source = @{$msg_hash->{source}}[0];
95 my $target = @{$msg_hash->{target}}[0];
96 my $header = @{$msg_hash->{header}}[0];
98 if(exists $main::known_daemons->{$source}) {
99 &main::add_content2known_daemons(hostname=>$source, status=>$header);
100 } else {
101 &main::add_content2known_clients(hostname=>$source, status=>$header);
102 }
104 return;
105 }
108 1;