Code

Added optional offset arguments (seconds) to get_time.
[gosa.git] / gosa-si / server / events / clMessages.pm
1 ## @file
2 # @brief Implementation of a GOsa-SI event module. 
3 # @details A GOsa-SI event module containing all functions to handle incoming messages from clients.
5 package clMessages;
6 use Exporter;
7 @ISA = qw(Exporter);
8 my @events = (
9     "confirm_usr_msg",
10     "PROGRESS",
11     "FAIREBOOT",
12     "TASKSKIP",
13     "TASKBEGIN",
14     "TASKEND",
15     "TASKERROR",
16     "HOOK",
17     "GOTOACTIVATION",
18     "LOGIN",
19     "LOGOUT",
20     "CURRENTLY_LOGGED_IN",
21     "save_fai_log",
22     );
23 @EXPORT = @events;
25 use strict;
26 use warnings;
27 use Data::Dumper;
28 use GOSA::GosaSupportDaemon;
29 use MIME::Base64;
32 BEGIN {}
34 END {}
37 ## @method get_events()
38 # @details A brief function returning a list of functions which are exported by importing the module.
39 # @return List of all provided functions
40 sub get_events {
41     return \@events;
42 }
44 ## @method confirm_usr_msg()
45 # @details Confirmed messages are set in the messaging_db from d (deliverd) to s(seen). 
46 # @param msg - STRING - xml message with tags 'message', 'subject' and 'usr'
47 # @param msg_hash - HASHREF - message information parsed into a hash
48 # @param session_id - INTEGER - POE session id of the processing of this message
49 sub confirm_usr_msg {
50     my ($msg, $msg_hash, $session_id) = @_;
51     my $message = @{$msg_hash->{'message'}}[0];
52     my $subject = @{$msg_hash->{'subject'}}[0];
53     my $usr = @{$msg_hash->{'usr'}}[0];
55     # set update for this message
56     my $sql = "UPDATE $main::messaging_tn SET flag='s' WHERE (message='$message' AND subject='$subject' AND message_to='$usr')"; 
57     &main::daemon_log("$session_id DEBUG: $sql", 7);
58     my $res = $main::messaging_db->exec_statement($sql); 
61     return;
62 }
65 ## @method save_fai_log()
66 # @details Creates under /var/log/fai/ the directory '$macaddress' and stores within all FAI log files from client.
67 # @param msg - STRING - xml message with tags 'macaddress' and 'save_fai_log'
68 # @param msg_hash - HASHREF - message information parsed into a hash
69 # @param session_id - INTEGER - POE session id of the processing of this message
70 sub save_fai_log {
71     my ($msg, $msg_hash, $session_id) = @_;
72     my $header = @{$msg_hash->{'header'}}[0];
73     my $source = @{$msg_hash->{'source'}}[0];
74     my $macaddress = @{$msg_hash->{'macaddress'}}[0];
75     my $all_logs = @{$msg_hash->{$header}}[0];
77     # if there is nothing to log
78     if( ref($all_logs) eq "HASH" ) { return; }
79         
80     my $client_fai_log_dir = $main::client_fai_log_dir;
81     if (not -d $client_fai_log_dir) {
82         mkdir($client_fai_log_dir, 0755)
83     }
85     $client_fai_log_dir = File::Spec->catfile( $client_fai_log_dir, $macaddress );
86     if (not -d $client_fai_log_dir) {
87         mkdir($client_fai_log_dir, 0755)
88     }
90     my $time = &get_time;
91     $time = substr($time, 0, 8)."_".substr($time, 8, 6);
92     $client_fai_log_dir = File::Spec->catfile( $client_fai_log_dir, "install_$time" );
93     mkdir($client_fai_log_dir, 0755);
95     my @all_logs = split(/log_file:/, $all_logs); 
96     foreach my $log (@all_logs) {
97         if (length $log == 0) { next; };
98         my ($log_file, $log_string) = split(":", $log);
99         my $client_fai_log_file = File::Spec->catfile( $client_fai_log_dir, $log_file);
101         open(my $LOG_FILE, ">$client_fai_log_file"); 
102         print $LOG_FILE &decode_base64($log_string);
103         close($LOG_FILE);
105     }
106     return;
109 ## @method LOGIN()
110 # @details Reported user from client is added to login_users_db.
111 # @param msg - STRING - xml message with tag 'LOGIN'
112 # @param msg_hash - HASHREF - message information parsed into a hash
113 # @param session_id - INTEGER - POE session id of the processing of this message
114 sub LOGIN {
115     my ($msg, $msg_hash, $session_id) = @_;
116     my $header = @{$msg_hash->{'header'}}[0];
117     my $source = @{$msg_hash->{'source'}}[0];
118     my $login = @{$msg_hash->{$header}}[0];
120     my %add_hash = ( table=>$main::login_users_tn, 
121         primkey=> ['client', 'user'],
122         client=>$source,
123         user=>$login,
124         timestamp=>&get_time,
125         ); 
126     my ($res, $error_str) = $main::login_users_db->add_dbentry( \%add_hash );
127     if ($res != 0)  {
128         &main::daemon_log("$session_id ERROR: cannot add entry to known_clients: $error_str");
129         return;
130     }
132     return;   
136 ## @method LOGOUT()
137 # @details Reported user from client is deleted from login_users_db.
138 # @param msg - STRING - xml message with tag 'LOGOUT'
139 # @param msg_hash - HASHREF - message information parsed into a hash
140 # @param session_id - INTEGER - POE session id of the processing of this message
141 sub LOGOUT {
142     my ($msg, $msg_hash, $session_id) = @_;
143     my $header = @{$msg_hash->{'header'}}[0];
144     my $source = @{$msg_hash->{'source'}}[0];
145     my $login = @{$msg_hash->{$header}}[0];
146     
147     my $sql_statement = "DELETE FROM $main::login_users_tn WHERE (client='$source' AND user='$login')"; 
148     my $res =  $main::login_users_db->del_dbentry($sql_statement);
149     &main::daemon_log("$session_id INFO: delete user '$login' at client '$source' from login_user_db", 5); 
150     
151     return;
155 ## @method CURRENTLY_LOGGED_IN()
156 # @details Reported users from client are updated in login_users_db. Users which are no longer logged in are deleted from DB. 
157 # @param msg - STRING - xml message
158 # @param msg_hash - HASHREF - message information parsed into a hash
159 # @param session_id - INTEGER - POE session id of the processing of this message
160 sub CURRENTLY_LOGGED_IN {
161     my ($msg, $msg_hash, $session_id) = @_;
162     my ($sql_statement, $db_res);
163     my $header = @{$msg_hash->{'header'}}[0];
164     my $source = @{$msg_hash->{'source'}}[0];
165     my $login = @{$msg_hash->{$header}}[0];
167     if(ref $login eq "HASH") { 
168         &main::daemon_log("$session_id INFO: no logged in users reported from host '$source'", 5); 
169         return;     
170     }
171     
172     # fetch all user currently assigned to the client at login_users_db
173     my %currently_logged_in_user = (); 
174     $sql_statement = "SELECT * FROM $main::login_users_tn WHERE client='$source'"; 
175     $db_res = $main::login_users_db->select_dbentry($sql_statement);
176     while( my($hit_id, $hit) = each(%{$db_res}) ) {
177         $currently_logged_in_user{$hit->{'user'}} = 1;
178     }
179     &main::daemon_log("$session_id DEBUG: logged in users from login_user_db: ".join(", ", keys(%currently_logged_in_user)), 7); 
181     # update all reported users in login_user_db
182     my @logged_in_user = split(/\s+/, $login);
183     &main::daemon_log("$session_id DEBUG: logged in users reported from client: ".join(", ", @logged_in_user), 7); 
184     foreach my $user (@logged_in_user) {
185         my %add_hash = ( table=>$main::login_users_tn, 
186                 primkey=> ['client', 'user'],
187                 client=>$source,
188                 user=>$user,
189                 timestamp=>&get_time,
190                 ); 
191         my ($res, $error_str) = $main::login_users_db->add_dbentry( \%add_hash );
192         if ($res != 0)  {
193             &main::daemon_log("$session_id ERROR: cannot add entry to known_clients: $error_str");
194             return;
195         }
197         delete $currently_logged_in_user{$user};
198     }
200     # if there is still a user in %currently_logged_in_user 
201     # although he is not reported by client 
202     # then delete it from $login_user_db
203     foreach my $obsolete_user (keys(%currently_logged_in_user)) {
204         &main::daemon_log("$session_id WARNING: user '$obsolete_user' is currently not logged ".
205                 "in at client '$source' but still found at login_user_db", 3); 
206         my $sql_statement = "DELETE FROM $main::login_users_tn WHERE client='$source' AND user='$obsolete_user'"; 
207         my $res =  $main::login_users_db->del_dbentry($sql_statement);
208         &main::daemon_log("$session_id WARNING: delete user '$obsolete_user' at client '$source' from login_user_db", 3); 
209     }
211     # Delete all users which logged in information is older than their logged_in_user_date_of_expiry
212     my $act_time = &get_time();
213     my $expiry_date = &calc_timestamp($act_time, "minus", $main::logged_in_user_date_of_expiry); 
215     $sql_statement = "SELECT * FROM $main::login_users_tn WHERE CAST(timestamp as INTEGER)<$expiry_date"; 
216     $db_res = $main::login_users_db->select_dbentry($sql_statement);
218     while( my($hit_id, $hit) = each(%{$db_res}) ) {
219         &main::daemon_log("$session_id INFO: user '".$hit->{'user'}."' is no longer reported to be logged in at host '".$hit->{'client'}."'", 5);
220         my $sql = "DELETE FROM $main::login_users_tn WHERE (client='".$hit->{'client'}."' AND user='".$hit->{'user'}."')"; 
221         my $res =  $main::login_users_db->del_dbentry($sql);
222         &main::daemon_log("$session_id INFO: delete user '".$hit->{'user'}."' at client '".$hit->{'client'}."' from login_user_db", 5); 
223     }
225     return;
229 ## @method GOTOACTIVATION()
230 # @details Client is set at job_queue_db to status 'processing' and 'modified'.
231 # @param msg - STRING - xml message with tag 'macaddress'
232 # @param msg_hash - HASHREF - message information parsed into a hash
233 # @param session_id - INTEGER - POE session id of the processing of this message
234 sub GOTOACTIVATION {
235     my ($msg, $msg_hash, $session_id) = @_;
236     my $header = @{$msg_hash->{'header'}}[0];
237     my $source = @{$msg_hash->{'source'}}[0];
238     my $macaddress = @{$msg_hash->{'macaddress'}}[0];
240     # test whether content is an empty hash or a string which is required
241     my $content = @{$msg_hash->{$header}}[0];
242     if(ref($content) eq "HASH") { $content = ""; }
244     # clean up header
245     $header =~ s/CLMSG_//g;
247     my $sql_statement = "UPDATE $main::job_queue_tn ".
248             "SET status='processing', progress='goto-activation', modified='1' ".
249             "WHERE status='processing' AND macaddress LIKE '$macaddress'"; 
250     &main::daemon_log("$session_id DEBUG: $sql_statement", 7);         
251     my $res = $main::job_db->update_dbentry($sql_statement);
252     &main::daemon_log("$session_id INFO: $header at '$macaddress'", 5); 
253     return; 
257 ## @method PROGRESS()
258 # @details Message reports installation progress of the client. Installation job at job_queue_db is going to be updated.
259 # @param msg - STRING - xml message with tags 'macaddress' and 'PROGRESS'
260 # @param msg_hash - HASHREF - message information parsed into a hash
261 # @param session_id - INTEGER - POE session id of the processing of this message
262 sub PROGRESS {
263     my ($msg, $msg_hash, $session_id) = @_;
264     my $header = @{$msg_hash->{'header'}}[0];
265     my $source = @{$msg_hash->{'source'}}[0];
266     my $macaddress = @{$msg_hash->{'macaddress'}}[0];
268     # test whether content is an empty hash or a string which is required
269     my $content = @{$msg_hash->{$header}}[0];
270     if(ref($content) eq "HASH") { $content = ""; }
272     # clean up header
273     $header =~ s/CLMSG_//g;
275     my $sql_statement = "UPDATE $main::job_queue_tn ".
276         "SET progress='$content', modified='1' ".
277         "WHERE status='processing' AND macaddress LIKE '$macaddress'";
278     &main::daemon_log("$session_id DEBUG: $sql_statement", 7);         
279     my $res = $main::job_db->update_dbentry($sql_statement);
280     &main::daemon_log("$session_id INFO: $header at '$macaddress' - $content%", 5); 
282     return;
286 ## @method FAIREBOOT()
287 # @details Message reports a FAI reboot. Job at job_queue_db is going to be updated.
288 # @param msg - STRING - xml message with tag 'macaddress' and 'FAIREBOOT'
289 # @param msg_hash - HASHREF - message information parsed into a hash
290 # @param session_id - INTEGER - POE session id of the processing of this message
291 sub FAIREBOOT {
292     my ($msg, $msg_hash, $session_id) = @_;
293     my $header = @{$msg_hash->{'header'}}[0];
294     my $source = @{$msg_hash->{'source'}}[0];
295     my $macaddress = @{$msg_hash->{'macaddress'}}[0];
297     # test whether content is an empty hash or a string which is required
298         my $content = @{$msg_hash->{$header}}[0];
299     if(ref($content) eq "HASH") { $content = ""; }
301     # clean up header
302     $header =~ s/CLMSG_//g;
304     my $sql_statement = "UPDATE $main::job_queue_tn ".
305             "SET status='processing', result='$header "."$content', modified='1' ".
306             "WHERE status='processing' AND macaddress LIKE '$macaddress'"; 
307     &main::daemon_log("$session_id DEBUG: $sql_statement", 7);         
308     my $res = $main::job_db->update_dbentry($sql_statement);
309     &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5); 
311     return; 
315 ## @method TASKSKIP()
316 # @details Message reports a skipped FAI task. Job at job_queue_db is going to be updated. 
317 # @param msg - STRING - xml message with tag 'macaddress'.
318 # @param msg_hash - HASHREF - message information parsed into a hash
319 # @param session_id - INTEGER - POE session id of the processing of this message
320 sub TASKSKIP {
321     my ($msg, $msg_hash, $session_id) = @_;
322     my $header = @{$msg_hash->{'header'}}[0];
323     my $source = @{$msg_hash->{'source'}}[0];
324     my $macaddress = @{$msg_hash->{'macaddress'}}[0];
326     # test whether content is an empty hash or a string which is required
327         my $content = @{$msg_hash->{$header}}[0];
328     if(ref($content) eq "HASH") { $content = ""; }
330     # clean up header
331     $header =~ s/CLMSG_//g;
333     my $sql_statement = "UPDATE $main::job_queue_tn ".
334             "SET status='processing', result='$header "."$content', modified='1' ".
335             "WHERE status='processing' AND macaddress LIKE '$macaddress'"; 
336     &main::daemon_log("$session_id DEBUG: $sql_statement", 7);         
337     my $res = $main::job_db->update_dbentry($sql_statement);
338     &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5); 
340     return; 
344 ## @method TASKBEGIN()
345 # @details Message reports a starting FAI task. If the task is equal to 'finish', 'faiend' or 'savelog', job at job_queue_db is being set to status 'done' and FAI state is being set to 'localboot'. If task is equal to 'chboot', 'test' or 'confdir', just do nothing. In all other cases, job at job_queue_db is going to be updated or created if not exists. 
346 # @param msg - STRING - xml message with tag 'macaddress'.
347 # @param msg_hash - HASHREF - message information parsed into a hash
348 # @param session_id - INTEGER - POE session id of the processing of this message
349 sub TASKBEGIN {
350     my ($msg, $msg_hash, $session_id) = @_;
351     my $header = @{$msg_hash->{'header'}}[0];
352     my $source = @{$msg_hash->{'source'}}[0];
353     my $target = @{$msg_hash->{'target'}}[0];
354     my $macaddress = @{$msg_hash->{'macaddress'}}[0];
356     # test whether content is an empty hash or a string which is required
357         my $content = @{$msg_hash->{$header}}[0];
358     if(ref($content) eq "HASH") { $content = ""; }
360     # clean up header
361     $header =~ s/CLMSG_//g;
363     # TASKBEGIN eq finish or faiend 
364     if (($content eq 'finish') 
365                         || ($content eq 'faiend')
366                         || ($content eq 'savelog')
367                         ) {
368         my $sql_statement = "UPDATE $main::job_queue_tn ".
369             "SET status='done', result='$header "."$content', modified='1' ".
370             "WHERE status='processing' AND macaddress LIKE '$macaddress'"; 
371         &main::daemon_log("$session_id DEBUG: $sql_statement", 7);         
372         my $res = $main::job_db->update_dbentry($sql_statement);
373         &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5); 
374         
375         # set fai_state to localboot
376         &main::change_fai_state('localboot', \@{$msg_hash->{'macaddress'}}, $session_id);
378         # TASKBEGIN eq chboot
379         } elsif (($content eq 'chboot')
380                 || ($content eq 'test')
381                 || ($content eq 'confdir')
382                 ) {
383                 # just ignor this client message
384                 # do nothing
386         # other TASKBEGIN msgs
387     } else {
388                 # select processing jobs for host
389                 my $sql_statement = "SELECT * FROM $main::job_queue_tn WHERE status='processing' AND macaddress LIKE '$macaddress'"; 
390                 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
391                 my $res = $main::job_db->select_dbentry($sql_statement);
393                 # there is exactly one job entry in queue for this host
394                 if (keys(%$res) == 1) {
395                         &main::daemon_log("$session_id DEBUG: there is already one processing job in queue for host '$macaddress', run an update for this entry", 7);
396                         my $sql_statement = "UPDATE $main::job_queue_tn ".
397                 "SET result='$header $content', modified='1', siserver='localhost' ".
398                 "WHERE status='processing' AND macaddress LIKE '$macaddress'";
399                         my $err = $main::job_db->update_dbentry($sql_statement);
400                         if (not defined  $err) {
401                                 &main::daemon_log("$session_id ERROR: cannot update job_db entry: ".Dumper($err), 1);
402                         }
403                         
404                 # there is no entry or more than one enties
405                 } else {
406                         # in case of more than one running jobs in queue, delete all jobs
407                         if (keys(%$res) > 1) {
408                                 &main::daemon_log("$session_id DEBUG: there are more than one processing job in queue for host '$macaddress', ".
409                                                                 "delete entries", 7); 
411                 # set job to status 'done', job will be deleted automatically
412                 my $sql_statement = "UPDATE $main::job_queue_tn ".
413                     "SET status='done', modified='1'".
414                     "WHERE status='processing' AND macaddress LIKE '$macaddress'";
415                 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
416                 my $res = $main::job_db->update_dbentry( $sql_statement );
418                         }
419                 
420                         # in case of no and more than one running jobs in queue, add one single job
421                         # resolve plain name for host $macaddress
422                         my $plain_name;
423                         my $ldap_handle = &main::get_ldap_handle($session_id);
424                         if( not defined $ldap_handle ) {
425                                 &main::daemon_log("$session_id ERROR: cannot connect to ldap", 1);
426                                 $plain_name = "none";
428                         # try to fetch a 'real name'
429                         } else {
430                                 my $mesg = $ldap_handle->search(
431                                                 base => $main::ldap_base,
432                                                 scope => 'sub',
433                                                 attrs => ['cn'],
434                                                 filter => "(macAddress=$macaddress)");
435                                 if($mesg->code) {
436                                         &main::daemon_log($mesg->error, 1);
437                                         $plain_name = "none";
438                                 } else {
439                                         my $entry= $mesg->entry(0);
440                                         $plain_name = $entry->get_value("cn");
441                                 }
442                         }
444             # In any case add a new job to job queue
445                         &main::daemon_log("$session_id DEBUG: add job to queue for host '$macaddress'", 7); 
446                         my $func_dic = {table=>$main::job_queue_tn,
447                                         primkey=>['macaddress', 'headertag'],
448                                         timestamp=>&get_time,
449                                         status=>'processing',
450                                         result=>"$header $content",
451                                         progress=>'none',
452                                         headertag=>'trigger_action_reinstall',
453                                         targettag=>$target,
454                                         xmlmessage=>'none',
455                                         macaddress=>$macaddress,
456                                         plainname=>$plain_name,
457                     modified=>'1',
458                     siserver=>'localhost',
459                         };
460                         my ($err, $error_str) = $main::job_db->add_dbentry($func_dic);
461                         if ($err != 0)  {
462                                         &main::daemon_log("$session_id ERROR: cannot add entry to job_db: $error_str", 1);
463                         }
464                 }
465     }
467     return; 
471 ## @method TASKEND()
472 # @details Message reports a finished FAI task. If task is equal to 'savelog', job at job_queue_db is going to be set to status 'done'. Otherwise, job is going to be updated. 
473 # @param msg - STRING - xml message with tag 'macaddress'.
474 # @param msg_hash - HASHREF - message information parsed into a hash
475 # @param session_id - INTEGER - POE session id of the processing of this message
476 sub TASKEND {
477     my ($msg, $msg_hash, $session_id) = @_;
478     my $header = @{$msg_hash->{'header'}}[0];
479     my $target = @{$msg_hash->{'target'}}[0];
480     my $source = @{$msg_hash->{'source'}}[0];
481     my $macaddress = @{$msg_hash->{'macaddress'}}[0];
483     # test whether content is an empty hash or a string which is required
484     my $content = @{$msg_hash->{$header}}[0];
485     if(ref($content) eq "HASH") { $content = ""; }
487     # clean up header
488     $header =~ s/CLMSG_//g;
490         if ($content eq "savelog 0") {
491                 &main::daemon_log("$session_id DEBUG: got savelog from host '$target' - job done", 7);
492         
493         # set job to status 'done', job will be deleted automatically
494         my $sql_statement = "UPDATE $main::job_queue_tn ".
495                                         "SET status='done', modified='1'".
496                     "WHERE status='processing' AND macaddress LIKE '$macaddress'";
497         &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
498         my $res = $main::job_db->update_dbentry( $sql_statement );
500         } else {
501         my $sql_statement = "UPDATE $main::job_queue_tn ".
502             "SET status='processing', result='$header "."$content', modified='1' ".
503             "WHERE status='processing' AND macaddress LIKE '$macaddress'"; 
504         &main::daemon_log("$session_id DEBUG: $sql_statement", 7);         
505         my $res = $main::job_db->update_dbentry($sql_statement);
506         &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5); 
507         }
509     return; 
513 ## @method TASKERROR()
514 # @details Message reports a FAI error. Job at job_queue_db is going to be updated. 
515 # @param msg - STRING - xml message with tag 'macaddress' and 'TASKERROR'
516 # @param msg_hash - HASHREF - message information parsed into a hash
517 # @param session_id - INTEGER - POE session id of the processing of this message
518 sub TASKERROR {
519     my ($msg, $msg_hash, $session_id) = @_;
520     my $header = @{$msg_hash->{'header'}}[0];
521     my $source = @{$msg_hash->{'source'}}[0];
522     my $macaddress = @{$msg_hash->{'macaddress'}}[0];
524     # clean up header
525     $header =~ s/CLMSG_//g;
527     # test whether content is an empty hash or a string which is required
528     my $content = @{$msg_hash->{$header}}[0];
529     if(ref($content) eq "HASH") { $content = ""; } 
531         # set fai_state to localboot
532         &main::change_fai_state('error', \@{$msg_hash->{'macaddress'}}, $session_id);
533                 
534     my $sql_statement = "UPDATE $main::job_queue_tn ".
535             "SET status='processing', result='$header "."$content', modified='1' ".
536             "WHERE status='processing' AND macaddress LIKE '$macaddress'"; 
537     &main::daemon_log("$session_id DEBUG: $sql_statement", 7);         
538     my $res = $main::job_db->update_dbentry($sql_statement);
539     &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5); 
541     return; 
545 ## @method HOOK()
546 # @details Message reports a FAI hook. Job at job_queue_db is going to be updated. 
547 # @param msg - STRING - xml message with tag 'macaddress' and 'HOOK'
548 # @param msg_hash - HASHREF - message information parsed into a hash
549 # @param session_id - INTEGER - POE session id of the processing of this message
550 sub HOOK {
551     my ($msg, $msg_hash, $session_id) = @_;
552     my $header = @{$msg_hash->{'header'}}[0];
553     my $source = @{$msg_hash->{'source'}}[0];
554     my $macaddress = @{$msg_hash->{'macaddress'}}[0];
556     # clean up header
557     $header =~ s/CLMSG_//g;
559     # test whether content is an empty hash or a string which is required
560         my $content = @{$msg_hash->{$header}}[0];
561     if(not ref($content) eq "STRING") { $content = ""; }
563     my $sql_statement = "UPDATE $main::job_queue_tn ".
564             "SET status='processing', result='$header "."$content', modified='1' ".
565             "WHERE status='processing' AND macaddress LIKE '$macaddress'"; 
566     &main::daemon_log("$session_id DEBUG: $sql_statement", 7);         
567     my $res = $main::job_db->update_dbentry($sql_statement);
568     &main::daemon_log("$session_id INFO: $header at '$macaddress' - '$content'", 5); 
570     return;
573 =pod
575 =head1 NAME
577 clMessages - Implementation of a GOsa-SI event module for GOsa-SI-server.
579 =head1 SYNOPSIS
581  use GOSA::GosaSupportDaemon;
582  use MIME::Base64;
584 =head1 DESCRIPTION
586 This GOsa-SI event module containing all functions to handle messages coming from GOsa-SI-clients. 
588 This module will be automatically imported by GOsa-SI if it is under F</usr/lib/gosa-si/server/E<lt>PACKAGEMODULEE<gt>/> .
590 =head1 METHODS
592 =over 4
594 =item get_events ( )
596 =item confirm_usr_msg ( )
598 =item PROGRESS ( )
600 =item FAIREBOOT ( )
602 =item TASKSKIP ( )
604 =item TASKBEGIN ( )
606 =item TASKEND ( )
608 =item TASKERROR ( )
610 =item HOOK ( )
612 =item GOTOACTIVATION ( )
614 =item LOGIN ( )
616 =item LOGOUT ( )
618 =item CURRENTLY_LOGGED_IN ( )
620 =item save_fai_log ( )
622 =back
624 =head1 BUGS
626 Please report any bugs, or post any suggestions, to the GOsa mailing list E<lt>gosa-devel@oss.gonicus.deE<gt> or to L<https://oss.gonicus.de/labs/gosa>
628 =head1 COPYRIGHT
630 This code is part of GOsa (L<http://www.gosa-project.org>)
632 Copyright (C) 2003-2008 GONICUS GmbH
634 This program is distributed in the hope that it will be useful,
635 but WITHOUT ANY WARRANTY; without even the implied warranty of
636 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
637 GNU General Public License for more details.
639 =cut
642 1;