63e7ce832937e59d7c0a6d5e36309f7f2abe5af8
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 "recreate_fai_release_db",
32 "recreate_packages_list_db",
33 "send_user_msg",
34 "get_available_kernel",
35 "krb5_list_principals",
36 "krb5_list_policies",
37 "krb5_get_principal",
38 "krb5_set_principal",
39 "krb5_del_principal",
40 "krb5_get_policy",
41 "krb5_set_policy",
42 "krb5_del_policy",
43 );
44 @EXPORT = @events;
46 use strict;
47 use warnings;
48 use GOSA::GosaSupportDaemon;
49 use Data::Dumper;
50 use Crypt::SmbHash;
51 use Net::ARP;
52 use Net::Ping;
53 use Socket;
55 BEGIN {}
57 END {}
59 ### Start ######################################################################
61 #&main::read_configfile($main::cfg_file, %cfg_defaults);
63 sub get_events {
64 return \@events;
65 }
67 sub send_user_msg {
68 my ($msg, $msg_hash, $session_id) = @_ ;
69 my $header = @{$msg_hash->{'header'}}[0];
70 my $source = @{$msg_hash->{'source'}}[0];
71 my $target = @{$msg_hash->{'target'}}[0];
73 #my $subject = &decode_base64(@{$msg_hash->{'subject'}}[0]);
74 my $subject = @{$msg_hash->{'subject'}}[0];
75 my $from = @{$msg_hash->{'from'}}[0];
76 my $to = @{$msg_hash->{'to'}}[0];
77 my $delivery_time = @{$msg_hash->{'delivery_time'}}[0];
78 #my $message = &decode_base64(@{$msg_hash->{'message'}}[0]);
79 my $message = @{$msg_hash->{'message'}}[0];
81 # keep job queue uptodate if necessary
82 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
83 if( defined $jobdb_id) {
84 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
85 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
86 my $res = $main::job_db->exec_statement($sql_statement);
87 }
89 # error handling
90 if (not $delivery_time =~ /^\d{14}$/) {
91 my $error_string = "delivery_time '$delivery_time' is not a valid timestamp, please use format 'yyyymmddhhmmss'";
92 &main::daemon_log("$session_id ERROR: $error_string", 1);
93 return &create_xml_string(&create_xml_hash($header, $target, $source, $error_string));
94 }
96 # add incoming message to messaging_db
97 my $new_msg_id = 1;
98 my $new_msg_id_sql = "SELECT MAX(id) FROM $main::messaging_tn";
99 my $new_msg_id_res = $main::messaging_db->exec_statement($new_msg_id_sql);
100 if (defined @{@{$new_msg_id_res}[0]}[0] ) {
101 $new_msg_id = int(@{@{$new_msg_id_res}[0]}[0]);
102 $new_msg_id += 1;
103 }
105 my $func_dic = {table=>$main::messaging_tn,
106 primkey=>[],
107 id=>$new_msg_id,
108 subject=>$subject,
109 message_from=>$from,
110 message_to=>$to,
111 flag=>"n",
112 direction=>"in",
113 delivery_time=>$delivery_time,
114 message=>$message,
115 timestamp=>&get_time(),
116 };
117 my $res = $main::messaging_db->add_dbentry($func_dic);
118 if (not $res == 0) {
119 &main::daemon_log("$session_id ERROR: gosaTriggered.pm: cannot add message to message_db: $res", 1);
120 } else {
121 &main::daemon_log("$session_id INFO: gosaTriggered.pm: message with subject '$subject' successfully added to message_db", 5);
122 }
124 return;
125 }
127 sub send_user_msg_OLD {
128 my ($msg, $msg_hash, $session_id) = @_ ;
129 my @out_msg_l;
130 my @user_list;
131 my @group_list;
133 my $header = @{$msg_hash->{'header'}}[0];
134 my $source = @{$msg_hash->{'source'}}[0];
135 my $target = @{$msg_hash->{'target'}}[0];
136 my $message = @{$msg_hash->{'message'}}[0];
137 if( exists $msg_hash->{'user'} ) { @user_list = @{$msg_hash->{'user'}}; }
138 if( exists $msg_hash->{'group'} ) { @group_list = @{$msg_hash->{'group'}}; }
140 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
141 if( defined $jobdb_id) {
142 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
143 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
144 my $res = $main::job_db->exec_statement($sql_statement);
145 }
147 # error handling
148 if( not @user_list && not @group_list ) {
149 &main::daemon_log("$session_id WARNING: no user-tag or a group-tag specified in 'send_user_msg'", 3);
150 return ("<xml><header>$header</header><source>GOSA</source><target>GOSA</target>".
151 "<error_string>no user-tag or a group-tag specified in 'send_user_msg'</error_string></xml>");
152 }
153 if( not defined $message ) {
154 &main::daemon_log("$session_id WARNING: no message-tag specified in 'send_user_msg'", 3);
155 return ("<xml><header>$header</header><source>GOSA</source><target>GOSA</target>".
156 "<error_string>no message-tag specified in 'send_user_msg'</error_string></xml>");
158 }
160 # resolve groups to users
161 my $ldap_handle = &main::get_ldap_handle($session_id);
162 if( @group_list ) {
163 if( not defined $ldap_handle ) {
164 &main::daemon_log("$session_id ERROR: cannot connect to ldap", 1);
165 return ();
166 }
167 foreach my $group (@group_list) { # Perform search
168 my $mesg = $ldap_handle->search(
169 base => $main::ldap_base,
170 scope => 'sub',
171 attrs => ['memberUid'],
172 filter => "(&(objectClass=posixGroup)(cn=$group)(memberUid=*))");
173 if($mesg->code) {
174 &main::daemon_log($mesg->error, 1);
175 return ();
176 }
177 my $entry= $mesg->entry(0);
178 my @users= $entry->get_value("memberUid");
179 foreach my $user (@users) { push(@user_list, $user); }
180 }
181 }
183 # drop multiple users in @user_list
184 my %seen = ();
185 foreach my $user (@user_list) {
186 $seen{$user}++;
187 }
188 @user_list = keys %seen;
190 # build xml messages sended to client where user is logged in
191 foreach my $user (@user_list) {
192 my $sql_statement = "SELECT * FROM $main::login_users_tn WHERE user='$user'";
193 my $db_res = $main::login_users_db->select_dbentry($sql_statement);
195 if(0 == keys(%{$db_res})) {
197 } else {
198 while( my($hit, $content) = each %{$db_res} ) {
199 my $out_hash = &create_xml_hash('send_user_msg', $main::server_address, $content->{'client'});
200 &add_content2xml_hash($out_hash, 'message', $message);
201 &add_content2xml_hash($out_hash, 'user', $user);
202 if( exists $msg_hash->{'jobdb_id'} ) {
203 &add_content2xml_hash($out_hash, 'jobdb_id', @{$msg_hash->{'jobdb_id'}}[0]);
204 }
205 my $out_msg = &create_xml_string($out_hash);
206 push(@out_msg_l, $out_msg);
207 }
208 }
209 }
211 return @out_msg_l;
212 }
215 sub recreate_fai_server_db {
216 my ($msg, $msg_hash, $session_id) = @_ ;
217 my $out_msg;
219 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
220 if( defined $jobdb_id) {
221 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
222 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
223 my $res = $main::job_db->exec_statement($sql_statement);
224 }
226 $main::fai_server_db->create_table("new_fai_server", \@main::fai_server_col_names);
227 &main::create_fai_server_db("new_fai_server",undef,"dont", $session_id);
228 $main::fai_server_db->move_table("new_fai_server", $main::fai_server_tn);
230 my @out_msg_l = ( $out_msg );
231 return @out_msg_l;
232 }
235 sub recreate_fai_release_db {
236 my ($msg, $msg_hash, $session_id) = @_ ;
237 my $out_msg;
239 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
240 if( defined $jobdb_id) {
241 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
242 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
243 my $res = $main::job_db->exec_statement($sql_statement);
244 }
246 $main::fai_release_db->create_table("new_fai_release", \@main::fai_release_col_names);
247 &main::create_fai_release_db("new_fai_release", $session_id);
248 $main::fai_release_db->move_table("new_fai_release", $main::fai_release_tn);
250 my @out_msg_l = ( $out_msg );
251 return @out_msg_l;
252 }
255 sub recreate_packages_list_db {
256 my ($msg, $msg_hash, $session_id) = @_ ;
257 my $out_msg;
259 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
260 if( defined $jobdb_id) {
261 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
262 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
263 my $res = $main::job_db->exec_statement($sql_statement);
264 }
266 &main::create_packages_list_db;
268 my @out_msg_l = ( $out_msg );
269 return @out_msg_l;
270 }
273 sub get_login_usr_for_client {
274 my ($msg, $msg_hash, $session_id) = @_ ;
275 my $header = @{$msg_hash->{'header'}}[0];
276 my $source = @{$msg_hash->{'source'}}[0];
277 my $target = @{$msg_hash->{'target'}}[0];
278 my $client = @{$msg_hash->{'client'}}[0];
280 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
281 if( defined $jobdb_id) {
282 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
283 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
284 my $res = $main::job_db->exec_statement($sql_statement);
285 }
287 $header =~ s/^gosa_//;
289 my $sql_statement = "SELECT * FROM known_clients WHERE hostname='$client' OR macaddress LIKE '$client'";
290 my $res = $main::known_clients_db->select_dbentry($sql_statement);
292 my $out_msg = "<xml><header>$header</header><source>$target</source><target>$source</target>";
293 $out_msg .= &db_res2xml($res);
294 $out_msg .= "</xml>";
296 my @out_msg_l = ( $out_msg );
297 return @out_msg_l;
298 }
301 sub get_client_for_login_usr {
302 my ($msg, $msg_hash, $session_id) = @_ ;
303 my $header = @{$msg_hash->{'header'}}[0];
304 my $source = @{$msg_hash->{'source'}}[0];
305 my $target = @{$msg_hash->{'target'}}[0];
307 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
308 if( defined $jobdb_id) {
309 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
310 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
311 my $res = $main::job_db->exec_statement($sql_statement);
312 }
314 my $usr = @{$msg_hash->{'usr'}}[0];
315 $header =~ s/^gosa_//;
317 my $sql_statement = "SELECT * FROM known_clients WHERE login LIKE '%$usr%'";
318 my $res = $main::known_clients_db->select_dbentry($sql_statement);
320 my $out_msg = "<xml><header>$header</header><source>$target</source><target>$source</target>";
321 $out_msg .= &db_res2xml($res);
322 $out_msg .= "</xml>";
323 my @out_msg_l = ( $out_msg );
324 return @out_msg_l;
326 }
329 sub ping {
330 my ($msg, $msg_hash, $session_id) = @_ ;
331 my $out_msg = $msg;
332 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
333 if( defined $jobdb_id) {
334 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
335 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
336 my $res = $main::job_db->exec_statement($sql_statement);
337 }
339 $out_msg =~ s/<header>gosa_/<header>/;
341 my @out_msg_l = ( $out_msg );
342 return @out_msg_l;
343 }
345 sub gen_smb_hash {
346 my ($msg, $msg_hash, $session_id) = @_ ;
347 my $source = @{$msg_hash->{source}}[0];
348 my $target = @{$msg_hash->{target}}[0];
349 my $password = @{$msg_hash->{password}}[0];
351 my %data= ('hash' => join(q[:], ntlmgen $password));
352 my $out_msg = &build_msg("gen_smb_hash", $target, 'GOSA', \%data );
353 return ( $out_msg );
354 }
357 sub network_completition {
358 my ($msg, $msg_hash, $session_id) = @_ ;
359 my $source = @{$msg_hash->{source}}[0];
360 my $target = @{$msg_hash->{target}}[0];
361 my $name = @{$msg_hash->{hostname}}[0];
363 # Can we resolv the name?
364 my %data;
365 if (inet_aton($name)){
366 my $address = inet_ntoa(inet_aton($name));
367 my $p = Net::Ping->new('tcp');
368 my $mac= "";
369 if ($p->ping($address, 1)){
370 $mac = Net::ARP::arp_lookup("", $address);
371 }
373 %data= ('ip' => $address, 'mac' => $mac);
374 } else {
375 %data= ('ip' => '', 'mac' => '');
376 }
378 my $out_msg = &build_msg("network_completition", $target, 'GOSA', \%data );
380 return ( $out_msg );
381 }
384 sub detect_hardware {
385 my ($msg, $msg_hash, $session_id) = @_ ;
386 # just forward msg to client, but dont forget to split off 'gosa_' in header
387 my $source = @{$msg_hash->{source}}[0];
388 my $target = @{$msg_hash->{target}}[0];
389 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
390 if( defined $jobdb_id) {
391 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
392 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
393 my $res = $main::job_db->exec_statement($sql_statement);
394 }
396 my $out_hash = &create_xml_hash("detect_hardware", $source, $target);
397 if( defined $jobdb_id ) {
398 &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
399 }
400 my $out_msg = &create_xml_string($out_hash);
402 my @out_msg_l = ( $out_msg );
403 return @out_msg_l;
405 }
408 sub trigger_reload_ldap_config {
409 my ($msg, $msg_hash, $session_id) = @_ ;
410 my $target = @{$msg_hash->{target}}[0];
412 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
413 if( defined $jobdb_id) {
414 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
415 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
416 my $res = $main::job_db->exec_statement($sql_statement);
417 }
419 my $out_hash = &create_xml_hash("reload_ldap_config", $main::server_address, $main::server_address, $target);
420 if( defined ) {
421 &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
422 }
423 my $out_msg = &create_xml_string($out_hash);
424 my @out_msg_l;
425 push(@out_msg_l, $out_msg);
426 return @out_msg_l;
427 }
430 sub set_activated_for_installation {
431 my ($msg, $msg_hash, $session_id) = @_;
432 my $header = @{$msg_hash->{header}}[0];
433 my $source = @{$msg_hash->{source}}[0];
434 my $target = @{$msg_hash->{target}}[0];
435 my @out_msg_l;
437 # update status of job
438 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
439 if( defined $jobdb_id) {
440 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
441 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
442 my $res = $main::job_db->exec_statement($sql_statement);
443 }
445 # create set_activated_for_installation message for delivery
446 my $out_hash = &create_xml_hash("set_activated_for_installation", $source, $target);
447 if( defined $jobdb_id ) {
448 &add_content2xml_hash($out_hash, 'jobdb_id', $jobdb_id);
449 }
450 my $out_msg = &create_xml_string($out_hash);
451 push(@out_msg_l, $out_msg);
453 return @out_msg_l;
454 }
457 sub trigger_action_faireboot {
458 my ($msg, $msg_hash, $session_id) = @_;
459 my $macaddress = @{$msg_hash->{target}}[0];
460 my $source = @{$msg_hash->{source}}[0];
462 my @out_msg_l;
463 $msg =~ s/<header>gosa_trigger_action_faireboot<\/header>/<header>trigger_action_faireboot<\/header>/;
464 push(@out_msg_l, $msg);
466 &main::change_goto_state('locked', \@{$msg_hash->{target}}, $session_id);
467 &main::change_fai_state('install', \@{$msg_hash->{target}}, $session_id);
469 # delete all jobs from jobqueue which correspond to fai
470 my $sql_statement = "DELETE FROM $main::job_queue_tn WHERE (macaddress='$macaddress' AND ".
471 "status='processing')";
472 $main::job_db->del_dbentry($sql_statement );
474 return @out_msg_l;
475 }
478 sub trigger_action_lock {
479 my ($msg, $msg_hash, $session_id) = @_;
480 my $macaddress = @{$msg_hash->{target}}[0];
481 my $source = @{$msg_hash->{source}}[0];
483 &main::change_goto_state('locked', \@{$msg_hash->{target}}, $session_id);
484 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
485 if( defined $jobdb_id) {
486 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
487 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
488 my $res = $main::job_db->exec_statement($sql_statement);
489 }
491 my @out_msg_l;
492 return @out_msg_l;
493 }
496 sub trigger_action_activate {
497 my ($msg, $msg_hash, $session_id) = @_;
498 my $macaddress = @{$msg_hash->{target}}[0];
499 my $source = @{$msg_hash->{source}}[0];
501 &main::change_goto_state('active', \@{$msg_hash->{target}}, $session_id);
502 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
503 if( defined $jobdb_id) {
504 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
505 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
506 my $res = $main::job_db->exec_statement($sql_statement);
507 }
509 my $out_hash = &create_xml_hash("set_activated_for_installation", $source, $macaddress);
510 if( exists $msg_hash->{'jobdb_id'} ) {
511 &add_content2xml_hash($out_hash, 'jobdb_id', @{$msg_hash->{'jobdb_id'}}[0]);
512 }
513 my $out_msg = &create_xml_string($out_hash);
515 return ( $out_msg );
516 }
519 sub trigger_action_localboot {
520 my ($msg, $msg_hash, $session_id) = @_;
521 $msg =~ s/<header>gosa_trigger_action_localboot<\/header>/<header>trigger_action_localboot<\/header>/;
522 &main::change_fai_state('localboot', \@{$msg_hash->{target}}, $session_id);
523 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
524 if( defined $jobdb_id) {
525 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
526 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
527 my $res = $main::job_db->exec_statement($sql_statement);
528 }
530 my @out_msg_l = ($msg);
531 return @out_msg_l;
532 }
535 sub trigger_action_halt {
536 my ($msg, $msg_hash, $session_id) = @_;
537 $msg =~ s/<header>gosa_trigger_action_halt<\/header>/<header>trigger_action_halt<\/header>/;
539 &main::change_fai_state('halt', \@{$msg_hash->{target}}, $session_id);
540 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
541 if( defined $jobdb_id) {
542 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
543 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
544 my $res = $main::job_db->exec_statement($sql_statement);
545 }
547 my @out_msg_l = ($msg);
548 return @out_msg_l;
549 }
552 sub trigger_action_reboot {
553 my ($msg, $msg_hash, $session_id) = @_;
554 $msg =~ s/<header>gosa_trigger_action_reboot<\/header>/<header>trigger_action_reboot<\/header>/;
556 &main::change_fai_state('reboot', \@{$msg_hash->{target}}, $session_id);
557 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
558 if( defined $jobdb_id) {
559 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
560 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
561 my $res = $main::job_db->exec_statement($sql_statement);
562 }
564 my @out_msg_l = ($msg);
565 return @out_msg_l;
566 }
569 sub trigger_action_memcheck {
570 my ($msg, $msg_hash, $session_id) = @_ ;
571 $msg =~ s/<header>gosa_trigger_action_memcheck<\/header>/<header>trigger_action_memcheck<\/header>/;
573 &main::change_fai_state('memcheck', \@{$msg_hash->{target}}, $session_id);
574 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
575 if( defined $jobdb_id) {
576 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
577 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
578 my $res = $main::job_db->exec_statement($sql_statement);
579 }
581 my @out_msg_l = ($msg);
582 return @out_msg_l;
583 }
586 sub trigger_action_reinstall {
587 my ($msg, $msg_hash, $session_id) = @_;
588 $msg =~ s/<header>gosa_trigger_action_reinstall<\/header>/<header>trigger_action_reinstall<\/header>/;
590 &main::change_fai_state('reinstall', \@{$msg_hash->{target}}, $session_id);
592 my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
593 my $wake_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
594 my @out_msg_l = ($wake_msg, $msg);
595 return @out_msg_l;
596 }
599 sub trigger_action_update {
600 my ($msg, $msg_hash, $session_id) = @_;
601 $msg =~ s/<header>gosa_trigger_action_update<\/header>/<header>trigger_action_update<\/header>/;
603 &main::change_fai_state('update', \@{$msg_hash->{target}}, $session_id);
605 my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
606 my $wake_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
607 my @out_msg_l = ($wake_msg, $msg);
608 return @out_msg_l;
609 }
612 sub trigger_action_instant_update {
613 my ($msg, $msg_hash, $session_id) = @_;
614 $msg =~ s/<header>gosa_trigger_action_instant_update<\/header>/<header>trigger_action_instant_update<\/header>/;
616 &main::change_fai_state('update', \@{$msg_hash->{target}}, $session_id);
618 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
619 if( defined $jobdb_id) {
620 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
621 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
622 my $res = $main::job_db->exec_statement($sql_statement);
623 }
625 my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
626 my $wake_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
627 my @out_msg_l = ($wake_msg, $msg);
628 return @out_msg_l;
629 }
632 sub trigger_action_sysinfo {
633 my ($msg, $msg_hash, $session_id) = @_;
634 $msg =~ s/<header>gosa_trigger_action_sysinfo<\/header>/<header>trigger_action_sysinfo<\/header>/;
636 &main::change_fai_state('sysinfo', \@{$msg_hash->{target}}, $session_id);
637 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
638 if( defined $jobdb_id) {
639 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
640 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
641 my $res = $main::job_db->exec_statement($sql_statement);
642 }
644 my @out_msg_l = ($msg);
645 return @out_msg_l;
646 }
649 sub new_key_for_client {
650 my ($msg, $msg_hash, $session_id) = @_;
652 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
653 if( defined $jobdb_id) {
654 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
655 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
656 my $res = $main::job_db->exec_statement($sql_statement);
657 }
659 $msg =~ s/<header>gosa_new_key_for_client<\/header>/<header>new_key<\/header>/;
660 my @out_msg_l = ($msg);
661 return @out_msg_l;
662 }
665 sub trigger_action_rescan {
666 my ($msg, $msg_hash, $session_id) = @_;
668 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
669 if( defined $jobdb_id) {
670 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
671 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
672 my $res = $main::job_db->exec_statement($sql_statement);
673 }
676 $msg =~ s/<header>gosa_trigger_action_rescan<\/header>/<header>trigger_action_rescan<\/header>/;
677 my @out_msg_l = ($msg);
678 return @out_msg_l;
679 }
682 sub trigger_action_wake {
683 my ($msg, $msg_hash, $session_id) = @_;
685 my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
686 if( defined $jobdb_id) {
687 my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id='$jobdb_id'";
688 &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
689 my $res = $main::job_db->exec_statement($sql_statement);
690 }
693 my %data = ( 'macAddress' => \@{$msg_hash->{target}} );
694 my $out_msg = &build_msg("trigger_wake", "GOSA", "KNOWN_SERVER", \%data);
695 my @out_msg_l = ($out_msg);
696 return @out_msg_l;
697 }
700 sub get_available_kernel {
701 my ($msg, $msg_hash, $session_id) = @_;
703 my $source = @{$msg_hash->{'source'}}[0];
704 my $target = @{$msg_hash->{'target'}}[0];
705 my $release= @{$msg_hash->{'release'}}[0];
707 my @kernel;
708 # Get Kernel packages for release
709 my $sql_statement = "SELECT * FROM $main::packages_list_tn WHERE distribution='$release' AND package LIKE 'linux\-image\-%'";
710 my $res_hash = $main::packages_list_db->select_dbentry($sql_statement);
711 my %data;
712 my $i=1;
714 foreach my $package (keys %{$res_hash}) {
715 $data{"answer".$i++}= $data{"answer".$i++}= ${$res_hash}{$package}->{'package'};
716 }
717 $data{"answer".$i++}= "default";
719 my $out_msg = &build_msg("get_available_kernel", $target, "GOSA", \%data);
720 return ( $out_msg );
721 }
724 sub krb5_list_principals {
725 my ($msg, $msg_hash, $session_id) = @_;
726 $msg =~ s/gosa_krb5/krb5/g;
727 return ( $msg );
728 }
731 sub krb5_set_principal {
732 my ($msg, $msg_hash, $session_id) = @_;
733 $msg =~ s/gosa_krb5/krb5/g;
734 return ( $msg );
735 }
738 sub krb5_get_principal {
739 my ($msg, $msg_hash, $session_id) = @_;
740 $msg =~ s/gosa_krb5/krb5/g;
741 return ( $msg );
742 }
745 sub krb5_del_principal {
746 my ($msg, $msg_hash, $session_id) = @_;
747 $msg =~ s/gosa_krb5/krb5/g;
748 return ( $msg );
749 }
752 sub krb5_list_policies {
753 my ($msg, $msg_hash, $session_id) = @_;
754 $msg =~ s/gosa_krb5/krb5/g;
755 return ( $msg );
756 }
759 sub krb5_get_policy {
760 my ($msg, $msg_hash, $session_id) = @_;
761 $msg =~ s/gosa_krb5/krb5/g;
762 return ( $msg );
763 }
766 sub krb5_set_policy {
767 my ($msg, $msg_hash, $session_id) = @_;
768 $msg =~ s/gosa_krb5/krb5/g;
769 return ( $msg );
770 }
773 sub krb5_del_policy {
774 my ($msg, $msg_hash, $session_id) = @_;
775 $msg =~ s/gosa_krb5/krb5/g;
776 return ( $msg );
777 }
780 1;