summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e30f55b)
raw | patch | inline | side by side (parent: e30f55b)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 24 Apr 2008 14:30:33 +0000 (14:30 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 24 Apr 2008 14:30:33 +0000 (14:30 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10676 594d385d-05f5-0310-b6e9-bd551577e9d8
index 9de869af8e75b2397bced71a25b83f5070fc1cad..b63aa8fc61a2498a7c5aecec25292f2ba1978489 100644 (file)
@ISA = qw(Exporter);
my @events = (
"get_events",
+ "usr_msg",
"trigger_action_localboot",
"trigger_action_halt",
"trigger_action_faireboot",
use strict;
use warnings;
use GOSA::GosaSupportDaemon;
+use Data::Dumper;
+use MIME::Base64;
BEGIN {}
sub get_events { return \@events; }
+sub usr_msg {
+ my ($msg, $msg_hash) = @_;
+
+
+ my $to = @{$msg_hash->{'usr'}}[0];
+ my $subject = &decode_base64(@{$msg_hash->{'subject'}}[0]);
+ my $message = &decode_base64(@{$msg_hash->{'message'}}[0]);
+
+print STDERR "\n\n\n##############################\n";
+print STDERR "message to: $to\n";
+print STDERR "subject: $subject\n";
+print STDERR "message: $message\n";
+print STDERR "##############################\n\n\n";
+# do, what ever you want
+# konch
+# kdialog
+# ...
+
+
+
+ # give gosa-si-server feedback, that msg was received
+ $msg =~ s/<header>usr_msg<\/header>/<header>confirm_usr_msg<\/header>/g;
+ return $msg;
+}
+
sub trigger_action_localboot {
my ($msg, $msg_hash) = @_;
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 067bce56e81e550f2a6dafe7859f3e120cf518c8..9fcbf6aff09fc838c5d0d0828ace98029169b4aa 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
$kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay);
$kernel->delay_set('watch_for_done_jobs', $job_queue_loop_delay);
$kernel->delay_set('watch_for_new_messages', $messaging_db_loop_delay);
+ $kernel->delay_set('watch_for_delivery_messages', $messaging_db_loop_delay);
$kernel->delay_set('watch_for_done_messages', $messaging_db_loop_delay);
}
# translate message_to to plain login name
# TODO implement reciever translation
- my @reciever_l = ($message_to);
+ my @reciever_l = split(/,/, $message_to);
my $message_id = @{$hit}[0];
#add each outgoing msg to messaging_db
&daemon_log("M INFO: message '".@{$hit}[0]."' is prepared for delivery to reciever '$reciever'", 5);
}
- # send outgoing messages
- my $sql_statement = "SELECT * FROM $messaging_tn WHERE ( flag='p' AND direction='out' )";
- my $res = $messaging_db->exec_statement( $sql_statement );
- foreach my $hit (@{$res}) {
- # add subject, from, to and message to list coll_user_msg
- my @user_msg = [@{$hit}[1], @{$hit}[2], $reciever, @{$hit}[7]];
- push( @coll_user_msg, \@user_msg);
- }
-
- # send outgoing list to myself (gosa-si-server) to deliver each message to user
- # reason for this workaround: if to much messages have to be delivered, it can come to
- # denial of service problems of the server. so, the incoming message list can be processed
- # by a forked child and gosa-si-server is always ready to work.
- my $collection_out_msg = &create_xml_hash("collection_user_messages", $server_address, $server_address);
- # add to hash 'msg1' => [subject, from, to, message]
- # hash to string
- # send msg to myself
-# TODO
-
# set incoming message to flag d=deliverd
$sql_statement = "UPDATE $messaging_tn SET flag='p' WHERE id='$message_id'";
&daemon_log("M DEBUG: $sql_statement", 7);
$res = $messaging_db->update_dbentry($sql_statement);
&daemon_log("M INFO: message '$message_id' is set to flag 'p' (processed)", 5);
-
}
-
+
$kernel->delay_set('watch_for_new_messages', $messaging_db_loop_delay);
+ return;
+}
+sub watch_for_delivery_messages {
+ my ($kernel, $heap) = @_[KERNEL, HEAP];
+
+ # select outgoing messages
+ my $sql_statement = "SELECT * FROM $messaging_tn WHERE ( flag='p' AND direction='out' )";
+ #&daemon_log("0 DEBUG: $sql", 7);
+ my $res = $messaging_db->exec_statement( $sql_statement );
+
+ # build out msg for each usr
+ foreach my $hit (@{$res}) {
+ my $receiver = @{$hit}[3];
+ my $msg_id = @{$hit}[0];
+ my $subject = @{$hit}[1];
+ my $message = @{$hit}[7];
+
+ # resolve usr -> host where usr is logged in
+ my $sql = "SELECT * FROM $login_users_tn WHERE (user='$receiver')";
+ #&daemon_log("0 DEBUG: $sql", 7);
+ my $res = $login_users_db->exec_statement($sql);
+
+ # reciver is logged in nowhere
+ if (not ref(@$res[0]) eq "ARRAY") { next; }
+
+ # receiver is logged in at host
+ my $receiver_host = @{@{$res}[0]}[0];
+
+ # fetch key to encrypt msg propperly for usr/host
+ $sql = "SELECT * FROM $known_clients_tn WHERE (hostname='$receiver_host')";
+ &daemon_log("0 DEBUG: $sql", 7);
+ $res = $known_clients_db->exec_statement($sql);
+ my $receiver_key = @{@{$res}[0]}[2];
+
+ my %data = ('subject' => $subject, 'message' => $message, 'usr' => $receiver);
+ my $out_msg = &build_msg("usr_msg", $server_address, $receiver_host, \%data );
+ my $error_state = &send_msg_to_target($out_msg, $receiver_host, $receiver_key, "usr_msg", 0);
+
+ if ($error_state == 0) {
+ # set outgoing msg at db to deliverd
+ my $sql = "UPDATE $messaging_tn SET flag='d' WHERE (id='$msg_id' AND direction='out' AND message_to='$receiver')";
+ &daemon_log("0 DEBUG: $sql", 7);
+ my $res = $messaging_db->exec_statement($sql);
+ }
+ }
+ $kernel->delay_set('watch_for_delivery_messages', $messaging_db_loop_delay);
return;
}
sub watch_for_done_messages {
my ($kernel,$heap) = @_[KERNEL, HEAP];
+ my $sql = "SELECT * FROM $messaging_tn WHERE (flag='p' AND direction='in')";
+ #&daemon_log("0 DEBUG: $sql", 7);
+ my $res = $messaging_db->exec_statement($sql);
+
+ foreach my $hit (@{$res}) {
+ my $msg_id = @{$hit}[0];
+
+ my $sql = "SELECT * FROM $messaging_tn WHERE (id='$msg_id' AND direction='out' AND (NOT flag='s'))";
+ #&daemon_log("0 DEBUG: $sql", 7);
+ my $res = $messaging_db->exec_statement($sql);
+
+ # not all usr msgs have been seen till now
+ if ( ref(@$res[0]) eq "ARRAY") { next; }
+
+ $sql = "DELETE FROM $messaging_tn WHERE (id='$msg_id')";
+ #&daemon_log("0 DEBUG: $sql", 7);
+ $res = $messaging_db->exec_statement($sql);
+
+ }
+
$kernel->delay_set('watch_for_done_messages', $messaging_db_loop_delay);
return;
}
_start => \&_start,
sig_handler => \&sig_handler,
watch_for_new_messages => \&watch_for_new_messages,
+ watch_for_delivery_messages => \&watch_for_delivery_messages,
watch_for_done_messages => \&watch_for_done_messages,
watch_for_new_jobs => \&watch_for_new_jobs,
watch_for_done_jobs => \&watch_for_done_jobs,
index 576fca207dfcbbdbc274c9efef6372221451b429..b566687623c15df941f43bdb860b2ef32c996481 100644 (file)
use Exporter;
@ISA = qw(Exporter);
my @events = (
+ "confirm_usr_msg",
"PROGRESS",
"FAIREBOOT",
"TASKSKIP",
}
+sub confirm_usr_msg {
+ my ($msg, $msg_hash, $session_id) = @_;
+ my $message = @{$msg_hash->{'message'}}[0];
+ my $subject = @{$msg_hash->{'subject'}}[0];
+ my $usr = @{$msg_hash->{'usr'}}[0];
+
+ # set update for this message
+ my $sql = "UPDATE $main::messaging_tn SET flag='s' WHERE (message='$message' AND subject='$subject' AND message_to='$usr')";
+ &main::daemon_log("$session_id DEBUG: $sql", 7);
+ my $res = $main::messaging_db->exec_statement($sql);
+
+
+ return;
+}
+
+
+
sub read_configfile {
my ($cfg_file, %cfg_defaults) = @_;
my $cfg;
index 4fba9bec67fe6a5eafa37c7f5005c71f2ae62837..c788754e2e9ccf216a4d32b167235f4dcad9e7c3 100644 (file)
#my $subject = &decode_base64(@{$msg_hash->{'subject'}}[0]);
my $subject = @{$msg_hash->{'subject'}}[0];
my $from = @{$msg_hash->{'from'}}[0];
- my $to = @{$msg_hash->{'to'}}[0];
+ my @to = @{$msg_hash->{'to'}};
my $delivery_time = @{$msg_hash->{'delivery_time'}}[0];
#my $message = &decode_base64(@{$msg_hash->{'message'}}[0]);
my $message = @{$msg_hash->{'message'}}[0];
id=>$new_msg_id,
subject=>$subject,
message_from=>$from,
- message_to=>$to,
+ message_to=>join(",",@to),
flag=>"n",
direction=>"in",
delivery_time=>$delivery_time,
index 52ff3c9cd64eed3245ae713dd0c3e75e4a271ba9..20af16b995caf2a0772d83f5a1d4b0bec3c71332 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
for($count = 1; $count <= $zahl; $count++)
{
- $sock = new Socket_Client("10.3.67.111","20081",TRUE,5);
- $sock->setEncryptionKey("UldOjon9gra");
+ $sock = new Socket_Client("127.0.0.1","20081",TRUE,5);
+ $sock->setEncryptionKey("secret-gosa-password");
+ #$sock = new Socket_Client("10.3.67.111","20081",TRUE,5);
+ #$sock->setEncryptionKey("UldOjon9gra");
if($sock->connected()){
#$data = "<xml> <header>job_ping</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:01:6c:9d:b9:fa</macaddress><timestamp>19700101000000</timestamp> </xml>";
# jobdb delete
- $data = "<xml> <header>gosa_delete_jobdb_entry</header> <source>GOSA</source> <target>GOSA</target> <where><clause><phrase><id>3</id></phrase></clause></where></xml>";
+ #$data = "<xml> <header>gosa_delete_jobdb_entry</header> <source>GOSA</source> <target>GOSA</target> <where><clause><phrase><id>3</id></phrase></clause></where></xml>";
# smbhash
#$data = "<xml> <header>gosa_gen_smb_hash</header> <source>GOSA</source><target>GOSA</target><password>tester</password></xml>";
###########
# messaging
- #$data = "<xml> <header>gosa_send_user_msg</header> <target>GOSA</target> <source>GOSA</source> <subject>eine wichtige nachricht</subject> <from>admin</from> <to>rettenbe</to> <delivery_time>20130101235959</delivery_time> <message>kaffeepause</message> </xml>";
+
+ $data = "<xml> <header>gosa_send_user_msg</header> <target>GOSA</target> <source>GOSA</source> <subject>".base64_encode("eine wichtige nachricht")."</subject> <from>admin</from> <to>polle</to> <to>rettenbe</to> <delivery_time>20130101235959</delivery_time> <message>".base64_encode("kaffeepause")."</message> </xml>";
################
# logHandling.pm
#########
# Kerberos test query
- $data = "<xml> <header>gosa_krb5_get_principal</header> <target>00:01:6c:9d:aa:16</target> <principal>cajus@WIRECARD.SYS</principal><source>GOSA</source></xml>";
+ #$data = "<xml> <header>gosa_krb5_get_principal</header> <target>00:01:6c:9d:aa:16</target> <principal>cajus@WIRECARD.SYS</principal><source>GOSA</source></xml>";
$sock->write($data);
$answer = "nothing";