X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-si%2Fserver%2Fevents%2FclMessages.pm;h=7425bfbac4690a6e232317d12598f3c1f3e17e65;hb=5e702a8304a79ec8eedb695efb79fe0cd3e531ef;hp=c606822f5b46a50956a35afa732e48557208bd21;hpb=e6affacc914e6ebdb0062ee8bea3a50d37367c54;p=gosa.git
diff --git a/gosa-si/server/events/clMessages.pm b/gosa-si/server/events/clMessages.pm
index c606822f5..7425bfbac 100644
--- a/gosa-si/server/events/clMessages.pm
+++ b/gosa-si/server/events/clMessages.pm
@@ -2,6 +2,7 @@ package clMessages;
use Exporter;
@ISA = qw(Exporter);
my @events = (
+ "confirm_usr_msg",
"PROGRESS",
"FAIREBOOT",
"TASKSKIP",
@@ -51,11 +52,28 @@ sub get_events {
}
+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;
- if( defined( $cfg_file) && ( length($cfg_file) > 0 )) {
+ if( defined( $cfg_file) && ( (-s $cfg_file) > 0 )) {
if( -r $cfg_file ) {
$cfg = Config::IniFiles->new( -file => $cfg_file );
} else {
@@ -134,27 +152,16 @@ sub LOGIN {
return;
}
-# TODO umstellen wie bei LOGIN
+
sub LOGOUT {
my ($msg, $msg_hash, $session_id) = @_;
my $header = @{$msg_hash->{'header'}}[0];
my $source = @{$msg_hash->{'source'}}[0];
my $login = @{$msg_hash->{$header}}[0];
-
- my $sql_statement = "SELECT * FROM known_clients WHERE hostname='$source'";
- my $res = $main::known_clients_db->select_dbentry($sql_statement);
- if( 1 != keys(%$res) ) {
- &main::daemon_log("DEBUG: clMessages.pm: LOGOUT: no or more hits found in known_clients_db for host '$source'");
- return;
- }
-
- my $act_login = $res->{'1'}->{'login'};
- $act_login =~ s/$login,?//gi;
-
- if( $act_login eq "" ){ $act_login = "nobody"; }
-
- $sql_statement = "UPDATE known_clients SET login='$act_login' WHERE hostname='$source'";
- $res = $main::known_clients_db->update_dbentry($sql_statement);
+
+ my $sql_statement = "DELETE FROM $main::login_users_tn WHERE (client='$source' AND user='$login')";
+ my $res = $main::login_users_db->del_dbentry($sql_statement);
+ &main::daemon_log("$session_id INFO: delete user '$login' at client '$source' from login_user_db", 5);
return;
}
@@ -365,10 +372,34 @@ sub TASKBEGIN {
}
}
- # in case of no and more than one running jobs in queue, add on single job
+ # in case of no and more than one running jobs in queue, add one single job
+ # resolve plain name for host $macaddress
+ my $plain_name;
+ my $ldap_handle = &main::get_ldap_handle($session_id);
+ if( not defined $ldap_handle ) {
+ &main::daemon_log("$session_id ERROR: cannot connect to ldap", 1);
+ $plain_name = "none";
+
+ # try to fetch a 'real name'
+ } else {
+ my $mesg = $ldap_handle->search(
+ base => $main::ldap_base,
+ scope => 'sub',
+ attrs => ['cn'],
+ filter => "(macAddress=$macaddress)");
+ if($mesg->code) {
+ &main::daemon_log($mesg->error, 1);
+ $plain_name = "none";
+ } else {
+ my $entry= $mesg->entry(0);
+ $plain_name = $entry->get_value("cn");
+ }
+ }
+
+
&main::daemon_log("$session_id DEBUG: add job to queue for host '$macaddress'", 7);
my $func_dic = {table=>$main::job_queue_tn,
- primkey=>['id'],
+ primkey=>[],
timestamp=>&get_time,
status=>'processing',
result=>"$header $content",
@@ -377,6 +408,7 @@ sub TASKBEGIN {
targettag=>$source,
xmlmessage=>'none',
macaddress=>$macaddress,
+ plainname=>$plain_name,
};
my ($err, $error_str) = $main::job_db->add_dbentry($func_dic);
if ($err != 0) {
@@ -385,14 +417,6 @@ sub TASKBEGIN {
}
- #my $sql_statement = "UPDATE $main::job_queue_tn ".
- # "SET status='processing', result='$header "."$content' ".
- # "WHERE status='processing' AND macaddress LIKE '$macaddress'";
- #&main::daemon_log("$session_id DEBUG: $sql_statement", 7);
- #my $res = $main::job_db->update_dbentry($sql_statement);
- #&main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5);
-
-
# -----------------------> Update hier
# finish
#
@@ -417,8 +441,8 @@ sub TASKEND {
# clean up header
$header =~ s/CLMSG_//g;
- if ($header eq "TASKEND softupdate 0") {
- &main::daemon_log("$session_id DEBUG: softupdate at host '$source' successful", 7);
+ if ($content eq "savelog 0") {
+ &main::daemon_log("$session_id DEBUG: got savelog from host '$source' - jub done", 7);
my $sql_statement = "DELETE FROM $main::job_queue_tn WHERE status='processing' AND macaddress LIKE '$macaddress'";
&main::daemon_log("$session_id DEBUG: $sql_statement", 7);
my $res = $main::job_db->del_dbentry($sql_statement);