summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5f691b7)
raw | patch | inline | side by side (parent: 5f691b7)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 11 Apr 2008 08:12:30 +0000 (08:12 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 11 Apr 2008 08:12:30 +0000 (08:12 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10346 594d385d-05f5-0310-b6e9-bd551577e9d8
index 9e57a5460aa794d0f90c5d514ef5ae6a21b236b5..38c969b4a4e407fb62a1113f47a240a996bcbfd4 100644 (file)
close(FILE);
}
else {
- system( "/sbin/shutdown -r +$timeout &" );
+ #system( "/sbin/shutdown -r +$timeout &" );
}
return;
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index b93f07cc7a58c9c717e13303941b4b720f0f92a0..5ee945afe0e9cf7af2abbedaef1f1339cbec1171 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
my ($bus_activ, $bus, $msg_to_bus, $bus_cipher);
my ($server);
my ($gosa_server, $job_queue_timeout, $job_queue_loop_delay);
+my ($messaging_db_loop_delay);
my ($known_modules);
my ($pid_file, $procid, $pid, $log_file);
my ($arp_activ, $arp_fifo);
# holds all messages which should be delivered to a user
our $messaging_db;
our $messaging_tn = "messaging";
-our @messaging_col_names = ('subject', 'from', 'to', 'flag', 'direction', 'delivery_time', 'message', 'timestamp', 'id INTEGER', );
+our @messaging_col_names = ('subject', 'message_from', 'message_to', 'flag', 'direction', 'delivery_time', 'message', 'timestamp', 'id INTEGER' );
my $messaging_file_name;
# path to directory to store client install log files
"port" => [\$gosa_port, "20082"],
"job-queue" => [\$job_queue_file_name, '/var/lib/gosa-si/jobs.db'],
"job-queue-loop-delay" => [\$job_queue_loop_delay, 3],
+ "messaging-db-loop-delay" => [\$messaging_db_loop_delay, 3],
"key" => [\$GosaPackages_key, "none"],
},
"SIPackages" => {
my ($kernel) = @_ ;
$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_done_messages', $messaging_db_loop_delay);
}
sub watch_for_done_jobs {
}
+sub watch_for_new_messages {
+ my ($kernel,$heap) = @_[KERNEL, HEAP];
+ my @coll_user_msg; # collection list of outgoing messages
+
+ # check messaging_db for new incoming messages with executable timestamp
+ my $timestamp = &get_time();
+ #my $sql_statement = "SELECT * FROM $messaging_tn WHERE (CAST (delivery_time AS INTEGER) + 120) < $timestamp";
+ my $sql_statement = "SELECT * FROM $messaging_tn WHERE ( (CAST(timestamp AS INTEGER))<$timestamp AND flag='n' AND direction='in' )";
+ my $res = $messaging_db->exec_statement( $sql_statement );
+
+ foreach my $hit (@{$res}) {
+
+ # create outgoing messages
+ my $message_to = @{$hit}[2];
+
+ # translate message_to to plain login name
+ my @reciever_l = ($message_to);
+ my $message_id = @{$hit}[8];
+
+ #add each outgoing msg to messaging_db
+ my $reciever;
+ foreach $reciever (@reciever_l) {
+ my $sql_statement = "INSERT INTO $messaging_tn (subject, message_from, message_to, flag, direction, delivery_time, message, timestamp, id) ".
+ "VALUES ('".
+ @{$hit}[0]."', '". # subject
+ @{$hit}[1]."', '". # message_from
+ $reciever."', '". # message_to
+ "none"."', '". # flag
+ "out"."', '". # direction
+ @{$hit}[5]."', '". # delivery_time
+ @{$hit}[6]."', '". # message
+ $timestamp."', '". # timestamp
+ @{$hit}[8]. # id
+ "')";
+ &daemon_log("M DEBUG: $sql_statement", 1);
+ my $res = $messaging_db->exec_statement($sql_statement);
+ &daemon_log("M INFO: message '".@{$hit}[8]."' 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}[0], @{$hit}[1], $reciever, @{$hit}[6]];
+ 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 '".@{$hit}[8]."' is set to flag 'p' (processed)", 5);
+
+ }
+
+ $kernel->delay_set('watch_for_new_messages', $messaging_db_loop_delay);
+
+
+ return;
+}
+
+
+sub watch_for_done_messages {
+ my ($kernel,$heap) = @_[KERNEL, HEAP];
+
+ $kernel->delay_set('watch_for_done_messages', $messaging_db_loop_delay);
+ return;
+}
+
+
sub get_ldap_handle {
my ($session_id) = @_;
my $heap;
inline_states => {
_start => \&_start,
sig_handler => \&sig_handler,
+ watch_for_new_messages => \&watch_for_new_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,
create_packages_list_db => \&run_create_packages_list_db,
index 30f9464243534e05a2f606df350a7e6f093cacf5..3f651b8becfa02dbeac9d5cc32b5938674ae1305 100644 (file)
}
sub send_user_msg {
+ my ($msg, $msg_hash, $session_id) = @_ ;
+ my $header = @{$msg_hash->{'header'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
+ my $target = @{$msg_hash->{'target'}}[0];
+
+ #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 $delivery_time = @{$msg_hash->{'delivery_time'}}[0];
+ #my $message = &decode_base64(@{$msg_hash->{'message'}}[0]);
+ my $message = @{$msg_hash->{'message'}}[0];
+
+ # keep job queue uptodate if necessary
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
+
+ # error handling
+ if (not $delivery_time =~ /^\d{14}$/) {
+ my $error_string = "delivery_time '$delivery_time' is not a valid timestamp, please use format 'yyyymmddhhmmss'";
+ &main::daemon_log("$session_id ERROR: $error_string", 1);
+ return &create_xml_string(&create_xml_hash($header, $target, $source, $error_string));
+ }
+
+ # add incoming message to messaging_db
+ my $func_dic = {table=>$main::messaging_tn,
+ primkey=>['id'],
+ subject=>$subject,
+ message_from=>$from,
+ message_to=>$to,
+ flag=>"n",
+ direction=>"in",
+ delivery_time=>$delivery_time,
+ message=>$message,
+ timestamp=>&get_time(),
+ };
+ my $res = $main::messaging_db->add_dbentry($func_dic);
+ if (not $res == 0) {
+ &main::daemon_log("$session_id ERROR: gosaTriggered.pm: cannot add message to message_db: $res", 1);
+ } else {
+ &main::daemon_log("$session_id INFO: gosaTriggered.pm: message with subject '$subject' successfully added to message_db", 5);
+ }
+
+ return;
+}
+
+sub send_user_msg_OLD {
my ($msg, $msg_hash, $session_id) = @_ ;
my @out_msg_l;
my @user_list;
}
- my $ldap_handle = &main::get_ldap_handle($session_id);
# resolve groups to users
+ my $ldap_handle = &main::get_ldap_handle($session_id);
if( @group_list ) {
- # build ldap connection
if( not defined $ldap_handle ) {
&main::daemon_log("$session_id ERROR: cannot connect to ldap", 1);
return ();
}
- foreach my $group (@group_list) {
- # Perform search
+ foreach my $group (@group_list) { # Perform search
my $mesg = $ldap_handle->search(
base => $main::ldap_base,
scope => 'sub',
index 3301212494078c12f105906856a55624e15c872d..b3e63b2ac5c7efd8765541acb5e001fa61cd0c91 100755 (executable)
--- a/gosa-si/tests/client.php
+++ b/gosa-si/tests/client.php
#$data = "<xml> <header>gosa_new_key_for_client</header> <target>00:01:6c:9d:b9:fa</target> <source>10.89.1.31:20081</source> </xml>";
#$data = "<xml> <header>job_trigger_action_wake</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> <timestamp>19700101000000</timestamp></xml>";
#$data = "<xml> <header>gosa_trigger_action_faireboot</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
+#$data = "<xml> <header>gosa_trigger_action_reboot</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
#$data = "<xml> <header>job_trigger_action_reinstall</header> <source>GOSA</source> <target>00:01:6c:9d:b9:fa</target> <macaddress>00:01:6c:9d:b9:fa</macaddress> <timestamp>19700101000000</timestamp> </xml>";
#$data = "<xml> <header>job_trigger_action_instant_update</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> <timestamp>19700101000000</timestamp> </xml>";
#$data = "<xml> <header>gosa_ping</header> <target>00:01:6c:9d:b9:fa</target> <source>GOSA</source> </xml>";
# recreate_fai_server_db
#$data = "<xml> <header>gosa_recreate_fai_server_db</header> <target>GOSA</target> <source>GOSA</source></xml>";
-# testing
+###########
+# messaging
#$data = "<xml> <header>gosa_send_user_msg</header> <target>GOSA</target> <source>GOSA</source> <user>susi</user> <user>harald</user> <user>susi</user> <group>gosa-admins-all</group> </xml>";
#$data = "<xml> <header>gosa_send_user_msg</header> <target>GOSA</target> <source>GOSA</source> <group>gosa-admins-all</group> <usrmesg>kaffeepause</usrmesg> </xml>";
-#$data = "<xml> <header>gosa_send_user_msg</header> <target>GOSA</target> <source>GOSA</source> <user>cajus.pollmeier</user> <message>kaffeepause</message> </xml>";
+#$data = "<xml> <header>gosa_send_user_msg</header> <target>GOSA</target> <source>GOSA</source> <user>rettenbe</user> <message>kaffeepause</message> </xml>";
+$data = "<xml> <header>gosa_send_user_msg</header> <target>GOSA</target> <source>GOSA</source> <subject>eine wichtige nachricht</subject> <from>me</from> <to>you</to> <delivery_time>20130101235959</delivery_time> <message>kaffeepause</message> </xml>";
################
# all date and mac parameter accept regular expression as input unless other instructions are given
# show_log_by_mac, show_log_by_date, show_log_by_date_and_mac, show_log_files_by_date_and_mac,
# get_log_file_by_date_and_mac, delete_log_by_date_and_mac, get_recent_log_by_mac
-$data = "<xml> <header>gosa_show_log_by_mac</header> <target>GOSA</target> <source>GOSA</source> <mac>00:01:6C:9D:B9:FA</mac> <mac>00:01:6c:9d:b9:fb</mac> </xml>";
+#$data = "<xml> <header>gosa_show_log_by_mac</header> <target>GOSA</target> <source>GOSA</source> <mac>00:01:6C:9D:B9:FA</mac> <mac>00:01:6c:9d:b9:fb</mac> </xml>";
#$data = "<xml> <header>gosa_show_log_by_date</header> <target>GOSA</target> <source>GOSA</source> <date>20080313</date> <date>20080323</date> </xml>";
#$data = "<xml> <header>gosa_show_log_by_date_and_mac</header> <target>GOSA</target> <source>GOSA</source> <date>200803</date> <mac>00:01:6c:9d:b9:FA</mac> </xml>";
#$data = "<xml> <header>gosa_delete_log_by_date_and_mac</header> <target>GOSA</target> <source>GOSA</source> <mac>00:01:6c:9d:b9:fa</mac></xml>";
#$data = "<xml> <header>gosa_get_recent_log_by_mac</header> <target>GOSA</target> <source>GOSA</source> <mac>00:01:6c:9d:b9:fa</mac></xml>";
-
# exact date and mac are required as input
#$data = "<xml> <header>gosa_show_log_files_by_date_and_mac</header> <target>GOSA</target> <source>GOSA</source> <date>install_20080311_090900</date> <mac>00:01:6c:9d:b9:fa</mac> </xml>";
#$data = "<xml> <header>gosa_get_log_file_by_date_and_mac</header> <target>GOSA</target> <source>GOSA</source> <date>install_20080311_090900</date> <mac>00:01:6c:9d:b9:fa</mac> <log_file>boot.log</log_file></xml>";