summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8de469a)
raw | patch | inline | side by side (parent: 8de469a)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 9 May 2008 08:44:13 +0000 (08:44 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 9 May 2008 08:44:13 +0000 (08:44 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10856 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/modules/GosaPackages.pm | patch | blob | history | |
gosa-si/modules/SIPackages.pm | patch | blob | history |
index f03074b18c8fe398cf610294445317ab981cd73c..0202e824ffecf2df3b4a32899cfef80c7687b3d1 100644 (file)
my ($msg, $msg_hash, $session_id) = @_ ;
my $out_msg;
my @out_msg_l = ('nohandler');
-
+ my $sql_events;
+
my $header = @{$msg_hash->{'header'}}[0];
+ my $target = @{$msg_hash->{'target'}}[0];
$header =~ s/gosa_//;
+ # check local installed events
if( exists $event_hash->{$header} ) {
# a event exists with the header as name
&main::daemon_log("$session_id INFO: found event '$header' at event-module '".$event_hash->{$header}."'", 5);
no strict 'refs';
- @out_msg_l = &{$event_hash->{$header}."::$header"}($msg, $msg_hash, $session_id);
+ @out_msg_l = &{$event_hash->{$header}."::$header"}( $msg, $msg_hash, $session_id );
+
+ # check client registered events
+ } else {
+ $sql_events = "SELECT * FROM $main::known_clients_tn WHERE ( (macaddress LIKE '$target') OR (hostname='$target') )";
+ my $res = $main::known_clients_db->select_dbentry( $sql_events );
+ my $l = keys(%$res);
+
+ # set error if no or more than 1 hits are found for sql query
+ if ( $l != 1) {
+ @out_msg_l = ('knownclienterror');
+
+ # found exact 1 hit in db
+ } else {
+ my $client_events = $res->{'1'}->{'events'};
+
+ # client is registered for this event, deliver this message to client
+ if ($client_events =~ /,$header,/) {
+ $msg =~ s/<header>gosa_/<header>/;
+ @out_msg_l = ( $msg );
+
+ # client is not registered for this event, set error
+ } else {
+ @out_msg_l = ('noeventerror');
+ }
+ }
}
# if delivery not possible raise error and return
- if( not defined $out_msg_l[0] ) {
-# &main::daemon_log("WARNING: GosaPackages got no answer from event handler '$header'", 3);
+ if (not defined $out_msg_l[0]) {
@out_msg_l = ();
- } elsif( $out_msg_l[0] eq 'nohandler') {
+ } elsif ($out_msg_l[0] eq 'nohandler') {
&main::daemon_log("$session_id ERROR: GosaPackages: no event handler or core function defined for '$header'", 1);
@out_msg_l = ();
- }
+ } elsif ($out_msg_l[0] eq 'knownclienterror') {
+ &main::daemon_log("$session_id ERROR: no or more than 1 hits are found at known_clients_db with sql query: '$sql_events'", 1);
+ &main::daemon_log("$session_id WARNING: processing is aborted and message will not be forwarded");
+ @out_msg_l = ();
+ } elsif ($out_msg_l[0] eq 'noeventerror') {
+ &main::daemon_log("$session_id WARNING: client '$target' is not registered for event '$header', processing is aborted", 1);
+ @out_msg_l = ();
+ }
return @out_msg_l;
}
index aa040b874c23c75134becb0f2ca574249aaefa33..b14f87ab68a1dca3f1ef88263e74f8ce961fe541 100644 (file)
my $host_name;
my $host_key;
my @out_msg_l = ("nohandler");
+ my $sql_events;
# process incoming msg
my $header = @{$msg_hash->{header}}[0];
+ my $source = @{$msg_hash->{source}}[0];
my @target_l = @{$msg_hash->{target}};
# skip PREFIX
if( 1 == length @target_l) {
my $target = $target_l[0];
if(&server_matches($target)) {
-
-
if ($header eq 'new_key') {
@out_msg_l = &new_key($msg_hash)
} elsif ($header eq 'here_i_am') {
&main::daemon_log("$session_id INFO: found event '$header' at event-module '".$event_hash->{$header}."'", 5);
no strict 'refs';
@out_msg_l = &{$event_hash->{$header}."::$header"}($msg, $msg_hash, $session_id);
+ } else {
+ $sql_events = "SELECT * FROM $main::known_clients_tn WHERE ( (macaddress LIKE '$source') OR (hostname='$source') )";
+ my $res = $main::known_clients_db->select_dbentry( $sql_events );
+ my $l = keys(%$res);
+
+ # set error if no or more than 1 hits are found for sql query
+ if ( $l != 1) {
+ @out_msg_l = ('knownclienterror');
+
+ # found exact 1 hit in db
+ } else {
+ my $client_events = $res->{'1'}->{'events'};
+
+ # client is registered for this event, deliver this message to client
+ $header =~ s/^answer_//;
+ if ($client_events =~ /,$header,/) {
+ $msg =~ s/<header>answer_/<header>/;
+ $msg =~ s/<target>\S+<\/target>/<target>GOSA<\/target>/;
+ @out_msg_l = ( $msg );
+
+ # client is not registered for this event, set error
+ } else {
+ @out_msg_l = ('noeventerror');
+ }
+ }
}
}
} elsif( $out_msg_l[0] eq 'nohandler') {
&main::daemon_log("$session_id ERROR: SIPackages: no event handler or core function defined for '$header'", 1);
@out_msg_l = ();
- }
+ } elsif ($out_msg_l[0] eq 'knownclienterror') {
+ &main::daemon_log("$session_id ERROR: no or more than 1 hits are found at known_clients_db with sql query: '$sql_events'", 1);
+ &main::daemon_log("$session_id WARNING: processing is aborted and message will not be forwarded");
+ @out_msg_l = ();
+ } elsif ($out_msg_l[0] eq 'noeventerror') {
+ &main::daemon_log("$session_id WARNING: client '$target' is not registered for event '$header', processing is aborted", 1);
+ @out_msg_l = ();
+ }
+
+
+
}
else {