summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c835a69)
raw | patch | inline | side by side (parent: c835a69)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 7 Nov 2008 09:01:20 +0000 (09:01 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 7 Nov 2008 09:01:20 +0000 (09:01 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@12959 594d385d-05f5-0310-b6e9-bd551577e9d8
index 3caffff15ea00dd70a72826978e8822ff82c72b7..6edc2758f383a9b398898e0db87c36770ca19461 100644 (file)
"trigger_action_reinstall",
"trigger_action_update",
"trigger_action_instant_update",
+ "trigger_goto_settings_reload",
);
@EXPORT = @events;
use GOSA::GosaSupportDaemon;
use Data::Dumper;
use MIME::Base64;
+use Data::Random qw(:all);
BEGIN {}
my $subject = &decode_base64(@{$msg_hash->{'subject'}}[0]);
my $message = &decode_base64(@{$msg_hash->{'message'}}[0]);
- system( "/usr/bin/goto-notify user-message '$to' '$subject' '$message'" );
+ my $rand_file = "/tmp/goto_notify_".join("",rand_chars(set=>'alphanumeric', min=>16, max=>16));
+ open(DATEI, ">$rand_file");
+ print DATEI "source:$source\ntarget:$target\nusr:$to\nsubject:".@{$msg_hash->{'subject'}}[0]."\nmessage:".@{$msg_hash->{'message'}}[0]."\n";
+ close DATEI;
- # give gosa-si-server feedback, that msg was received
- $msg =~ s/<header>usr_msg<\/header>/<header>confirm_usr_msg<\/header>/g;
- my $out_hash = &create_xml_hash("confirm_usr_msg", $target, $source);
- &add_content2xml_hash($out_hash, 'usr', $to);
- &add_content2xml_hash($out_hash, 'subject', @{$msg_hash->{'subject'}}[0]);
- &add_content2xml_hash($out_hash, 'message', @{$msg_hash->{'message'}}[0]);
+ my $feedback = system("/usr/bin/goto-notify user-message '$to' '$subject' '$message' '$rand_file' &" );
-
- return &create_xml_string($out_hash);
+ return
}
return;
}
+sub trigger_goto_settings_reload {
+ my ($msg, $msg_hash) = @_;
+
+ # Execute goto settings reload
+ my $cmd = "/etc/init.d/goto-agents";
+ my $pram = "start";
+ if (-f $cmd){
+ my $feedback = system("$cmd $pram") or &main::daemon_log("ERROR: $@");
+ } else {
+ &main::daemon_log("ERROR: cannot exec $cmd, file not found!");
+ }
+
+ return;
+}
+
1;
diff --git a/gosa-si/gosa-si-client b/gosa-si/gosa-si-client
index ab3fb734ab29e5530153e2305ed00b7a65c0b5ee..933b2fa4ad1e6b6f9c0a1a15674032c01226620e 100755 (executable)
--- a/gosa-si/gosa-si-client
+++ b/gosa-si/gosa-si-client
my $delay_set_time = 10;
our $prg= basename($0);
-# all x seconds the client reports logged_in users to gosa-si-server
+# all n seconds the client reports logged_in users to gosa-si-server
my $trigger_logged_in_users_report_delay = 600;
+# all n seconds the client reports messages seen by user
+my $trigger_seen_messages_delay = 30;
+
# directory where all log files from installation are stored
my $fai_log_dir = "/var/log/fai";
# Check if our ip is resolvable - if not: don't try to register
my $ip= &get_local_ip_for_remote_ip(sprintf("%s", $server =~ /^([0-9\.]*?):.*$/));
my $dnsname= gethostbyaddr(inet_aton($ip), AF_INET);
- if(!defined($dnsname)) {
- if( defined($client_force_hostname) && $client_force_hostname eq "true") {
- $dnsname = `hostname`;
- } else {
- &write_to_file("goto-error-dns:$ip", $fai_logpath);
- exit(1);
- }
- }
+ if(!defined($dnsname)) {
+ if( defined($client_force_hostname) && $client_force_hostname eq "true") {
+ $dnsname = `hostname`;
+ } else {
+ &write_to_file("goto-error-dns:$ip", $fai_logpath);
+ &main::daemon_log("ERROR: ip is not resolvable, no registration possible. Write 'goto-error-dns:$ip' to $fai_logpath", 1);
+ exit(1);
+ }
+ }
# create registration msg
my $local_ip = &get_local_ip_for_remote_ip(sprintf("%s", $server =~ /^([0-9\.]*?):.*$/));
}
+sub trigger_seen_messages {
+ my ($kernel) = $_[KERNEL] ;
+
+ # Select all files under /tmp with prefix 'goto_notify'
+ my $goto_dir = "/tmp";
+ opendir(DIR, $goto_dir);
+ my @goto_files = grep { /^goto_notify_/ && -f "$goto_dir/$_" } readdir(DIR);
+ closedir DIR;
+
+ # Check if file has 'seen' tag
+ foreach my $goto_file (@goto_files) {
+ open(FILE, "$goto_dir/$goto_file");
+ my @lines = <FILE>;
+ close FILE;
+
+ my $source;
+ my $target;
+ my $usr;
+ my $subject;
+ my $message;
+ my $seen = 0;
+ chomp(@lines);
+ foreach my $line (@lines) {
+ if ($line =~ /^source:([\S\s]*)$/) {
+ $source = $1
+ }
+ if ($line =~ /^target:([\S\s]*)$/) {
+ $target = $1;
+ }
+ if ($line =~ /^usr:([\S\s]*)$/) {
+ $usr = $1;
+ }
+ if ($line =~ /^subject:([\S\s]*)$/) {
+ $subject = $1;
+ }
+ if ($line =~ /^message:([\S\s]*)$/) {
+ $message = $1;
+ }
+ if ($line =~ /^seen$/) {
+ $seen++;
+ }
+ }
+
+ # Send 'confirm_usr_msg' back to msg-hosting server
+ if ($seen) {
+ my %data = ('usr'=>$usr, 'subject'=>$subject, 'message'=>$message);
+ my $confirm_msg = &build_msg("confirm_usr_msg", $target, $source, \%data);
+ my $send_error = &send_msg_to_target($confirm_msg, $server_address, $server_key);
+
+ # Delete file
+ if (not $send_error) {
+ system("rm $goto_dir/$goto_file");
+ }
+ }
+ }
+
+ $kernel->delay_set('trigger_seen_messages', $trigger_seen_messages_delay);
+
+ return;
+}
+
+
sub generic_file_error {
my ( $heap, $operation, $errno, $error_string, $wheel_id ) =
@_[ HEAP, ARG0, ARG1, ARG2, ARG3 ];
my $clmsg_hash = &create_xml_hash("CLMSG_$header", $client_address, $server_address, $content);
&add_content2xml_hash($clmsg_hash, "macaddress", $client_mac_address);
+ my $utc_ts = &main::get_utc_time();
+ &add_content2xml_hash($clmsg_hash, "timestamp", $utc_ts);
my $clmsg = &create_xml_string($clmsg_hash);
&send_msg_to_target($clmsg, $server_address, $server_key, "CLMSG_$header");
$heap->{watchers}->{ $watcher->ID } = $watcher;
}
$kernel->yield('trigger_logged_in_users_report');
+ $kernel->yield('trigger_seen_messages');
}
# trigger periodical tasks
trigger_new_key => \&trigger_new_key,
trigger_logged_in_users_report => \&trigger_logged_in_users_report,
+ trigger_seen_messages => \&trigger_seen_messages,
# handle records from each defined file differently
fifo_record => \&fifo_got_record,
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index b09f02411f2e212c99f33ccbc20683d626a61ad7..84de9b7330930296a7f250706784bea817939e41 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
@@ -172,7 +172,7 @@ my @foreign_clients_col_names = ("hostname", "macaddress", "regserver", "timesta
our $login_users_db;
our $login_users_tn = "login_users";
my $login_users_file_name;
-my @login_users_col_names = ("client", "user", "timestamp");
+my @login_users_col_names = ("client", "user", "timestamp", "regserver");
# holds all fai server, the debian release and tag
our $fai_server_db;
index 6d65168db4edba01d3f493c60dab9e5925b161c0..b0497ec599d42b9c10dca62a8f4410fe53314b94 100644 (file)
my $source = @{$msg_hash->{'source'}}[0];
my $login = @{$msg_hash->{$header}}[0];
+ # Add user to login_users_db
my %add_hash = ( table=>$main::login_users_tn,
primkey=> ['client', 'user'],
client=>$source,
user=>$login,
timestamp=>&get_time,
+ regserver=>'localhost',
);
my ($res, $error_str) = $main::login_users_db->add_dbentry( \%add_hash );
if ($res != 0) {
return;
}
- return;
+ # Share login information with all other si-server
+ my %data = ( 'new_user' => "$source;$login" );
+ my $info_msg = &build_msg("information_sharing", $main::server_address, "KNOWN_SERVER", \%data);
+
+ return ($info_msg);
}
client=>$source,
user=>$user,
timestamp=>&get_time,
+ regserver=>'localhost',
);
my ($res, $error_str) = $main::login_users_db->add_dbentry( \%add_hash );
if ($res != 0) {
&main::daemon_log("$session_id INFO: delete user '".$hit->{'user'}."' at client '".$hit->{'client'}."' from login_user_db", 5);
}
- return;
+ # Inform all other server which users are logged in at clients registered at local server
+ my $info_sql = "SELECT * FROM $main::login_users_tn";
+ my $info_res = $main::login_users_db->select_dbentry($info_sql);
+ my $info_msg_hash = &create_xml_hash("information_sharing", $main::server_address, "KNOWN_SERVER");
+ while (my ($hit_id, $hit) = each(%$info_res)) {
+ &add_content2xml_hash($info_msg_hash, 'user_db', $hit->{'client'}.";".$hit->{'user'});
+ }
+ my $info_msg = &create_xml_string($info_msg_hash);
+
+ return ($info_msg);
}