3f651b8becfa02dbeac9d5cc32b5938674ae1305
1 package gosaTriggered;
2 use Exporter;
3 @ISA = qw(Exporter);
4 my @events = (
5 "get_events",
6 "get_login_usr_for_client",
7 "get_client_for_login_usr",
8 "gen_smb_hash",
9 "trigger_reload_ldap_config",
10 "ping",
11 "network_completition",
12 "set_activated_for_installation",
13 "new_key_for_client",
14 "detect_hardware",
15 "get_login_usr",
16 "get_login_client",
17 "trigger_action_localboot",
18 "trigger_action_faireboot",
19 "trigger_action_reboot",
20 "trigger_action_activate",
21 "trigger_action_lock",
22 "trigger_action_halt",
23 "trigger_action_update",
24 "trigger_action_reinstall",
25 "trigger_action_memcheck",
26 "trigger_action_sysinfo",
27 "trigger_action_instant_update",
28 "trigger_action_rescan",
29 "trigger_action_wake",
30 "recreate_fai_server_db",
31 "send_user_msg",
32 );
33 @EXPORT = @events;
35 use strict;
36 use warnings;
37 use GOSA::GosaSupportDaemon;
38 use Data::Dumper;
39 use Crypt::SmbHash;
40 use Net::ARP;
41 use Net::Ping;
42 use Socket;
44 BEGIN {}
46 END {}
48 ### Start ######################################################################
50 #&main::read_configfile($main::cfg_file, %cfg_defaults);
52 sub get_events {
53 return \@events;
54 }
56 sub send_user_msg {
57 my ($msg, $msg_hash, $session_id) = @_ ;
58 my $header = @{$msg_hash->{'header'}}[0];
59 my $source = @{$msg_hash->{'source'}}[0];
60 my $target = @{$msg_hash->{'target'}}[0];
62 #my $subject = &decode_base64(@{$msg_hash->{'subject'}}[0]);
63 my $subject = @{$msg_hash->{'subject'}}[0];
64 my $from = @{$msg_hash->{'from'}}[0];
65 my $to = @{$msg_hash->{'to'}}[0];
66 my $delivery_time = @{$msg_hash->{'delivery_time'}}[0];
67 #my $message = &decode_base64(@{$msg_hash->{'message'}}[0]);
68 my $message = @{$msg_hash->{'message'}}[0];
70 # keep job queue uptodate if necessary
71 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
72 if( defined $jobdb_id) {
73 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
74 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
75 my $res = $main::job_db->exec_statement($sql_statement);
76 }
78 # error handling
79 if (not $delivery_time =~ /^\d{14}$/) {
80 my $error_string = "delivery_time '$delivery_time' is not a valid timestamp, please use format 'yyyymmddhhmmss'";
81 &main::daemon_log("$session_id ERROR: $error_string", 1);
82 return &create_xml_string(&create_xml_hash($header, $target, $source, $error_string));
83 }
85 # add incoming message to messaging_db
86 my $func_dic = {table=>$main::messaging_tn,
87 primkey=>['id'],
88 subject=>$subject,
89 message_from=>$from,
90 message_to=>$to,
91 flag=>"n",
92 direction=>"in",
93 delivery_time=>$delivery_time,
94 message=>$message,
95 timestamp=>&get_time(),
96 };
97 my $res = $main::messaging_db->add_dbentry($func_dic);
98 if (not $res == 0) {
99 &main::daemon_log("$session_id ERROR: gosaTriggered.pm: cannot add message to message_db: $res", 1);
100 } else {
101 &main::daemon_log("$session_id INFO: gosaTriggered.pm: message with subject '$subject' successfully added to message_db", 5);
102 }
104 return;
105 }
107 sub send_user_msg_OLD {
108 my ($msg, $msg_hash, $session_id) = @_ ;
109 my @out_msg_l;
110 my @user_list;
111 my @group_list;
113 my $header = @{$msg_hash->{'header'}}[0];
114 my $source = @{$msg_hash->{'source'}}[0];
115 my $target = @{$msg_hash->{'target'}}[0];
116 my $message = @{$msg_hash->{'message'}}[0];
117 if( exists $msg_hash->{'user'} ) { @user_list = @{$msg_hash->{'user'}}; }
118 if( exists $msg_hash->{'group'} ) { @group_list = @{$msg_hash->{'group'}}; }
120 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
121 if( defined $jobdb_id) {
122 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
123 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
124 my $res = $main::job_db->exec_statement($sql_statement);
125 }
127 # error handling
128 if( not @user_list && not @group_list ) {
129 &main::daemon_log("$session_id WARNING: no user-tag or a group-tag specified in 'send_user_msg'", 3);
130 return ("<xml><header>$header</header><source>GOSA</source><target>GOSA</target>".
131 "<error_string>no user-tag or a group-tag specified in 'send_user_msg'</error_string></xml>");
132 }
133 if( not defined $message ) {
134 &main::daemon_log("$session_id WARNING: no message-tag specified in 'send_user_msg'", 3);
135 return ("<xml><header>$header</header><source>GOSA</source><target>GOSA</target>".
136 "<error_string>no message-tag specified in 'send_user_msg'</error_string></xml>");
138 }
140 # resolve groups to users
141 my $ldap_handle = &main::get_ldap_handle($session_id);
142 if( @group_list ) {
143 if( not defined $ldap_handle ) {
144 &main::daemon_log("$session_id ERROR: cannot connect to ldap", 1);
145 return ();
146 }
147 foreach my $group (@group_list) { # Perform search
148 my $mesg = $ldap_handle->search(
149 base => $main::ldap_base,
150 scope => 'sub',
151 attrs => ['memberUid'],
152 filter => "(&(objectClass=posixGroup)(cn=$group)(memberUid=*))");
153 if($mesg->code) {
154 &main::daemon_log($mesg->error, 1);
155 return ();
156 }
157 my $entry= $mesg->entry(0);
158 my @users= $entry->get_value("memberUid");
159 foreach my $user (@users) { push(@user_list, $user); }
160 }
161 }
163 # drop multiple users in @user_list
164 my %seen = ();
165 foreach my $user (@user_list) {
166 $seen{$user}++;
167 }
168 @user_list = keys %seen;
170 # build xml messages sended to client where user is logged in
171 foreach my $user (@user_list) {
172 my $sql_statement = "SELECT * FROM $main::login_users_tn WHERE user='$user'";
173 my $db_res = $main::login_users_db->select_dbentry($sql_statement);
175 if(0 == keys(%{$db_res})) {
177 } else {
178 while( my($hit, $content) = each %{$db_res} ) {
179 my $out_hash = &create_xml_hash('send_user_msg', $main::server_address, $content->{'client'});
180 &add_content2xml_hash($out_hash, 'message', $message);
181 &add_content2xml_hash($out_hash, 'user', $user);
182 if( exists $msg_hash->{'jobdb_id'} ) {
183 &add_content2xml_hash($out_hash, 'jobdb_id', @{$msg_hash->{'jobdb_id'}}[0]);
184 }
185 my $out_msg = &create_xml_string($out_hash);
186 push(@out_msg_l, $out_msg);
187 }
188 }
189 }
191 return @out_msg_l;
192 }
195 sub recreate_fai_server_db {
196 my ($msg, $msg_hash, $session_id) = @_ ;
197 my $out_msg;
199 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
200 if( defined $jobdb_id) {
201 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
202 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
203 my $res = $main::job_db->exec_statement($sql_statement);
204 }
206 $main::fai_server_db->create_table("new_fai_server", \@main::fai_server_col_names);
207 &main::create_fai_server_db("new_fai_server");
208 $main::fai_server_db->move_table("new_fai_server", $main::fai_server_tn);
210 my @out_msg_l = ( $out_msg );
211 return @out_msg_l;
212 }
215 sub get_login_usr_for_client {
216 my ($msg, $msg_hash, $session_id) = @_ ;
217 my $header = @{$msg_hash->{'header'}}[0];
218 my $source = @{$msg_hash->{'source'}}[0];
219 my $target = @{$msg_hash->{'target'}}[0];
220 my $client = @{$msg_hash->{'client'}}[0];
222 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
223 if( defined $jobdb_id) {
224 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
225 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
226 my $res = $main::job_db->exec_statement($sql_statement);
227 }
229 $header =~ s/^gosa_//;
231 my $sql_statement = "SELECT * FROM known_clients WHERE hostname='$client' OR macaddress LIKE '$client'";
232 my $res = $main::known_clients_db->select_dbentry($sql_statement);
234 my $out_msg = "<xml><header>$header</header><source>$target</source><target>$source</target>";
235 $out_msg .= &db_res2xml($res);
236 $out_msg .= "</xml>";
238 my @out_msg_l = ( $out_msg );
239 return @out_msg_l;
240 }
243 sub get_client_for_login_usr {
244 my ($msg, $msg_hash, $session_id) = @_ ;
245 my $header = @{$msg_hash->{'header'}}[0];
246 my $source = @{$msg_hash->{'source'}}[0];
247 my $target = @{$msg_hash->{'target'}}[0];
249 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
250 if( defined $jobdb_id) {
251 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
252 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
253 my $res = $main::job_db->exec_statement($sql_statement);
254 }
256 my $usr = @{$msg_hash->{'usr'}}[0];
257 $header =~ s/^gosa_//;
259 my $sql_statement = "SELECT * FROM known_clients WHERE login LIKE '%$usr%'";
260 my $res = $main::known_clients_db->select_dbentry($sql_statement);
262 my $out_msg = "<xml><header>$header</header><source>$target</source><target>$source</target>";
263 $out_msg .= &db_res2xml($res);
264 $out_msg .= "</xml>";
265 my @out_msg_l = ( $out_msg );
266 return @out_msg_l;
268 }
271 sub ping {
272 my ($msg, $msg_hash, $session_id) = @_ ;
273 my $out_msg = $msg;
274 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
275 if( defined $jobdb_id) {
276 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
277 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
278 my $res = $main::job_db->exec_statement($sql_statement);
279 }
281 $out_msg =~ s/<header>gosa_/<header>/;
283 my @out_msg_l = ( $out_msg );
284 return @out_msg_l;
285 }
287 sub gen_smb_hash {
288 my ($msg, $msg_hash, $session_id) = @_ ;
289 my $source = @{$msg_hash->{source}}[0];
290 my $target = @{$msg_hash->{target}}[0];
291 my $password = @{$msg_hash->{password}}[0];
293 my %data= ('hash' => join(q[:], ntlmgen $password));
294 my $out_msg = &build_msg("gen_smb_hash", $target, 'GOSA', \%data );
295 return ( $out_msg );
296 }
299 sub network_completition {
300 my ($msg, $msg_hash, $session_id) = @_ ;
301 my $source = @{$msg_hash->{source}}[0];
302 my $target = @{$msg_hash->{target}}[0];
303 my $name = @{$msg_hash->{hostname}}[0];
305 # Can we resolv the name?
306 my %data;
307 if (inet_aton($name)){
308 my $address = inet_ntoa(inet_aton($name));
309 my $p = Net::Ping->new('tcp');
310 my $mac= "";
311 if ($p->ping($address, 1)){
312 $mac = Net::ARP::arp_lookup("", $address);
313 }
315 %data= ('ip' => $address, 'mac' => $mac);
316 } else {
317 %data= ('ip' => '', 'mac' => '');
318 }
320 my $out_msg = &build_msg("network_completition", $target, 'GOSA', \%data );
322 return ( $out_msg );
323 }
326 sub detect_hardware {
327 my ($msg, $msg_hash, $session_id) = @_ ;
328 # just forward msg to client, but dont forget to split off 'gosa_' in header
329 my $source = @{$msg_hash->{source}}[0];
330 my $target = @{$msg_hash->{target}}[0];
331 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
332 if( defined $jobdb_id) {
333 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
334 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
335 my $res = $main::job_db->exec_statement($sql_statement);
336 }
338 my $out_hash = &create_xml_hash("detect_hardware", $source, $target);
339 if( defined $jobdb_id ) {
340 &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
341 }
342 my $out_msg = &create_xml_string($out_hash);
344 my @out_msg_l = ( $out_msg );
345 return @out_msg_l;
347 }
350 sub trigger_reload_ldap_config {
351 my ($msg, $msg_hash, $session_id) = @_ ;
352 my $target = @{$msg_hash->{target}}[0];
354 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
355 if( defined $jobdb_id) {
356 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
357 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
358 my $res = $main::job_db->exec_statement($sql_statement);
359 }
361 my $out_hash = &create_xml_hash("reload_ldap_config", $main::server_address, $main::server_address, $target);
362 if( defined ) {
363 &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
364 }
365 my $out_msg = &create_xml_string($out_hash);
366 my @out_msg_l;
367 push(@out_msg_l, $out_msg);
368 return @out_msg_l;
369 }
372 sub set_activated_for_installation {
373 my ($msg, $msg_hash, $session_id) = @_;
374 my $header = @{$msg_hash->{header}}[0];
375 my $source = @{$msg_hash->{source}}[0];
376 my $target = @{$msg_hash->{target}}[0];
378 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
379 if( defined $jobdb_id) {
380 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
381 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
382 my $res = $main::job_db->exec_statement($sql_statement);
383 }
385 my $out_hash = &create_xml_hash("set_activated_for_installation", $source, $target);
386 if( defined $jobdb_id ) {
387 &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
388 }
389 my $out_msg = &create_xml_string($out_hash);
390 my @out_msg_l = ( $out_msg );
391 return @out_msg_l;
392 }
395 sub trigger_action_faireboot {
396 my ($msg, $msg_hash, $session_id) = @_;
397 my $macaddress = @{$msg_hash->{target}}[0];
398 my $source = @{$msg_hash->{source}}[0];
400 my @out_msg_l;
401 $msg =~ s/<header>gosa_trigger_action_faireboot<\/header>/<header>trigger_action_faireboot<\/header>/;
402 push(@out_msg_l, $msg);
404 &main::change_goto_state('locked', \@{$msg_hash->{target}}, $session_id);
405 &main::change_fai_state('install', \@{$msg_hash->{target}}, $session_id);
407 # delete all jobs from jobqueue which correspond to fai
408 my $sql_statement = "DELETE FROM $main::job_queue_tn WHERE (macaddress='$macaddress' AND ".
409 "status='processing')";
410 $main::job_db->del_dbentry($sql_statement );
412 return @out_msg_l;
413 }
416 sub trigger_action_lock {
417 my ($msg, $msg_hash, $session_id) = @_;
418 my $macaddress = @{$msg_hash->{target}}[0];
419 my $source = @{$msg_hash->{source}}[0];
421 &main::change_goto_state('locked', \@{$msg_hash->{target}}, $session_id);
422 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
423 if( defined $jobdb_id) {
424 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
425 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
426 my $res = $main::job_db->exec_statement($sql_statement);
427 }
429 my @out_msg_l;
430 return @out_msg_l;
431 }
434 sub trigger_action_activate {
435 my ($msg, $msg_hash, $session_id) = @_;
436 my $macaddress = @{$msg_hash->{target}}[0];
437 my $source = @{$msg_hash->{source}}[0];
439 &main::change_goto_state('active', \@{$msg_hash->{target}}, $session_id);
440 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
441 if( defined $jobdb_id) {
442 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
443 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
444 my $res = $main::job_db->exec_statement($sql_statement);
445 }
447 my $out_hash = &create_xml_hash("set_activated_for_installation", $source, $macaddress);
448 if( exists $msg_hash->{'jobdb_id'} ) {
449 &add_content2xml_hash($out_hash, 'jobdb_id', @{$msg_hash->{'jobdb_id'}}[0]);
450 }
451 my $out_msg = &create_xml_string($out_hash);
453 return ( $out_msg );
454 }
457 sub trigger_action_localboot {
458 my ($msg, $msg_hash, $session_id) = @_;
459 $msg =~ s/<header>gosa_trigger_action_localboot<\/header>/<header>trigger_action_localboot<\/header>/;
460 &main::change_fai_state('localboot', \@{$msg_hash->{target}}, $session_id);
461 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
462 if( defined $jobdb_id) {
463 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
464 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
465 my $res = $main::job_db->exec_statement($sql_statement);
466 }
468 my @out_msg_l = ($msg);
469 return @out_msg_l;
470 }
473 sub trigger_action_halt {
474 my ($msg, $msg_hash, $session_id) = @_;
475 $msg =~ s/<header>gosa_trigger_action_halt<\/header>/<header>trigger_action_halt<\/header>/;
477 &main::change_fai_state('halt', \@{$msg_hash->{target}}, $session_id);
478 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
479 if( defined $jobdb_id) {
480 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
481 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
482 my $res = $main::job_db->exec_statement($sql_statement);
483 }
485 my @out_msg_l = ($msg);
486 return @out_msg_l;
487 }
490 sub trigger_action_reboot {
491 my ($msg, $msg_hash, $session_id) = @_;
492 $msg =~ s/<header>gosa_trigger_action_reboot<\/header>/<header>trigger_action_reboot<\/header>/;
494 &main::change_fai_state('reboot', \@{$msg_hash->{target}}, $session_id);
495 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
496 if( defined $jobdb_id) {
497 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
498 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
499 my $res = $main::job_db->exec_statement($sql_statement);
500 }
502 my @out_msg_l = ($msg);
503 return @out_msg_l;
504 }
507 sub trigger_action_memcheck {
508 my ($msg, $msg_hash, $session_id) = @_ ;
509 $msg =~ s/<header>gosa_trigger_action_memcheck<\/header>/<header>trigger_action_memcheck<\/header>/;
511 &main::change_fai_state('memcheck', \@{$msg_hash->{target}}, $session_id);
512 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
513 if( defined $jobdb_id) {
514 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
515 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
516 my $res = $main::job_db->exec_statement($sql_statement);
517 }
519 my @out_msg_l = ($msg);
520 return @out_msg_l;
521 }
524 sub trigger_action_reinstall {
525 my ($msg, $msg_hash, $session_id) = @_;
526 $msg =~ s/<header>gosa_trigger_action_reinstall<\/header>/<header>trigger_action_reinstall<\/header>/;
528 &main::change_fai_state('reinstall', \@{$msg_hash->{target}}, $session_id);
530 my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
531 my $wake_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
532 my @out_msg_l = ($wake_msg, $msg);
533 return @out_msg_l;
534 }
537 sub trigger_action_update {
538 my ($msg, $msg_hash, $session_id) = @_;
539 $msg =~ s/<header>gosa_trigger_action_update<\/header>/<header>trigger_action_update<\/header>/;
541 &main::change_fai_state('update', \@{$msg_hash->{target}}, $session_id);
543 my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
544 my $wake_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
545 my @out_msg_l = ($wake_msg, $msg);
546 return @out_msg_l;
547 }
550 sub trigger_action_instant_update {
551 my ($msg, $msg_hash, $session_id) = @_;
552 $msg =~ s/<header>gosa_trigger_action_instant_update<\/header>/<header>trigger_action_instant_update<\/header>/;
554 &main::change_fai_state('update', \@{$msg_hash->{target}}, $session_id);
556 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
557 if( defined $jobdb_id) {
558 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
559 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
560 my $res = $main::job_db->exec_statement($sql_statement);
561 }
563 my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
564 my $wake_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
565 my @out_msg_l = ($wake_msg, $msg);
566 return @out_msg_l;
567 }
570 sub trigger_action_sysinfo {
571 my ($msg, $msg_hash, $session_id) = @_;
572 $msg =~ s/<header>gosa_trigger_action_sysinfo<\/header>/<header>trigger_action_sysinfo<\/header>/;
574 &main::change_fai_state('sysinfo', \@{$msg_hash->{target}}, $session_id);
575 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
576 if( defined $jobdb_id) {
577 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
578 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
579 my $res = $main::job_db->exec_statement($sql_statement);
580 }
582 my @out_msg_l = ($msg);
583 return @out_msg_l;
584 }
587 sub new_key_for_client {
588 my ($msg, $msg_hash, $session_id) = @_;
590 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
591 if( defined $jobdb_id) {
592 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
593 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
594 my $res = $main::job_db->exec_statement($sql_statement);
595 }
597 $msg =~ s/<header>gosa_new_key_for_client<\/header>/<header>new_key<\/header>/;
598 my @out_msg_l = ($msg);
599 return @out_msg_l;
600 }
603 sub trigger_action_rescan {
604 my ($msg, $msg_hash, $session_id) = @_;
606 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
607 if( defined $jobdb_id) {
608 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
609 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
610 my $res = $main::job_db->exec_statement($sql_statement);
611 }
614 $msg =~ s/<header>gosa_trigger_action_rescan<\/header>/<header>trigger_action_rescan<\/header>/;
615 my @out_msg_l = ($msg);
616 return @out_msg_l;
617 }
620 sub trigger_action_wake {
621 my ($msg, $msg_hash, $session_id) = @_;
623 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
624 if( defined $jobdb_id) {
625 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
626 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
627 my $res = $main::job_db->exec_statement($sql_statement);
628 }
631 my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
632 my $out_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
633 my @out_msg_l = ($out_msg);
634 return @out_msg_l;
635 }
638 1;