X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-si%2Fgosa-si-server;h=f1e33172f6f830ac16bc535e8481f4d85a9030d2;hb=a09f1309a687df67d091c7eea50f168f69a7fa14;hp=7b1a5569b8e2b1822344cce134106065910582c7;hpb=16a702a978751915c4bf79553489f1154da9ccaa;p=gosa.git diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 7b1a5569b..f1e33172f 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -39,7 +39,7 @@ use Digest::MD5 qw(md5 md5_hex md5_base64); use XML::Simple; use Data::Dumper; use Sys::Syslog qw( :DEFAULT setlogsock); -use Time::HiRes qw( usleep); +use Time::HiRes qw( usleep clock_gettime ); use Cwd; use File::Spec; use File::Basename; @@ -51,6 +51,7 @@ use POE qw(Component::Server::TCP Wheel::Run Filter::Reference); use Net::LDAP; use Net::LDAP::Util qw(:escape); + # revision number of server and program name my $server_headURL; my $server_revision; @@ -318,10 +319,10 @@ usage: $prg [-hvf] [-c config] [-d number] 'vvvvvvv': debug plus info logs -no-arp : starts $prg without connection to arp module -d : if verbose level is higher than 7x 'v' specified parts can be debugged - 1 : receiving messages - 2 : sending messages - 4 : encrypting/decrypting messages - 8 : verification if a message complies gosa-si requirements + 1 : report incoming messages + 2 : report unencrypted outgoing messages + 4 : report encrypting key for messages + 8 : report decrypted incoming message and verification if the message complies gosa-si requirements 16 : message processing 32 : ldap connectivity 64 : database status and connectivity @@ -387,10 +388,13 @@ sub daemon_log { $monthday = $monthday < 10 ? $monthday = "0".$monthday : $monthday; $year+=1900; - + # Microseconds since epoch + my $microSeconds = sprintf("%.2f", &Time::HiRes::clock_gettime()); + $microSeconds =~ s/^\d*(.\d\d)$/$1/; + # Build log message and write it to log file and commandline chomp($msg); - my $log_msg = "$month $monthday $hours:$minutes:$seconds $prg $msg\n"; + my $log_msg = "$month $monthday $hours:$minutes:$seconds$microSeconds $prg $msg\n"; flock(LOG_HANDLE, LOCK_EX); seek(LOG_HANDLE, 0, 2); print LOG_HANDLE $log_msg; @@ -1311,7 +1315,7 @@ sub msg_to_decrypt { module=>$module, sessionid=>$session_id, } ); - + $kernel->yield('watch_for_next_tasks'); } # target is own address with forward_to_gosa-tag pointing at myself -> forward to gosa @@ -1431,6 +1435,7 @@ sub msg_to_decrypt { sessionid=>$session_id, } ); $done = 1; + $kernel->yield('watch_for_next_tasks'); } @@ -1543,8 +1548,7 @@ sub process_task { while ($answer_str =~ /
(\w+)<\/header>/g) { push(@headers, $1); } - daemon_log("$session_id INFO: got answer message(s) with header: '".join("', '", @headers)."'", 5); - daemon_log("$session_id DEBUG: $module: got answer from module: \n".$answer_str,26); + daemon_log("$session_id DEBUG: got answer message(s) with header: '".join("', '", @headers)."'", 26); } else { daemon_log("$session_id DEBUG: $module: got no answer from module!" ,26); } @@ -1602,6 +1606,9 @@ sub process_task { if( defined $session_id ) { $add_on = ".session_id=$session_id"; } + my $header = ($1) if $answer =~ /
(\S*)<\/header>/; + daemon_log("$session_id INFO: send ".$header." message to GOsa", 5); + daemon_log("$session_id DEBUG: message:\n$answer", 12); # answer is for GOSA and has to returned to connected client my $gosa_answer = &encrypt_msg($answer, $GosaPackages_key); $client_answer = $gosa_answer.$add_on; @@ -1705,7 +1712,6 @@ sub session_start { $kernel->yield('register_at_foreign_servers'); $kernel->yield('create_fai_server_db', $fai_server_tn ); $kernel->yield('create_fai_release_db', $fai_release_tn ); - $kernel->yield('watch_for_next_tasks'); $kernel->sig(USR1 => "sig_handler"); $kernel->sig(USR2 => "recreate_packages_db"); $kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay); @@ -1762,7 +1768,6 @@ sub watch_for_done_jobs { sub watch_for_opsi_jobs { my ($kernel) = $_[KERNEL]; - # This is not very nice to look for opsi install jobs, but headertag has to be trigger_action_reinstall. The only way to identify a # opsi install job is to parse the xml message. There is still the correct header. my $sql_statement = "SELECT * FROM ".$job_queue_tn." WHERE ((xmlmessage LIKE '%opsi_install_client
%') AND (status='processing') AND (siserver='localhost'))"; @@ -1786,10 +1791,14 @@ sub watch_for_opsi_jobs { }; my $hres = $opsi_client->call($opsi_url, $callobj); - #my ($hres_err, $hres_err_string) = &check_opsi_res($hres); + # TODO : move all opsi relevant statments to opsi plugin + # The following 3 lines must be tested befor they can replace the rubbish above and below !!! + #my ($res, $err) = &opsi_com::_getProductStates_hash(hostId=>$hostId) + #if (not $err) { + # my $htmp = $res->{$hostId}; + # if (not &check_opsi_res($hres)) { my $htmp= $hres->result->{$hostId}; - # Check state != not_installed or action == setup -> load and add my $products= 0; my $installed= 0; @@ -2277,8 +2286,6 @@ sub watch_for_next_tasks { my $sql = "DELETE FROM $incoming_tn WHERE id=$message_id"; my $res = $incoming_db->exec_statement($sql); } - - $kernel->delay_set('watch_for_next_tasks', 1); } @@ -3696,6 +3703,7 @@ POE::Component::Server::TCP->new( }, InlineStates => { msg_to_decrypt => \&msg_to_decrypt, + watch_for_next_tasks => \&watch_for_next_tasks, next_task => \&next_task, task_result => \&handle_task_result, task_done => \&handle_task_done, @@ -3717,7 +3725,6 @@ POE::Session->create( task_result => \&handle_task_result, task_done => \&handle_task_done, task_debug => \&handle_task_debug, - watch_for_next_tasks => \&watch_for_next_tasks, watch_for_new_messages => \&watch_for_new_messages, watch_for_delivery_messages => \&watch_for_delivery_messages, watch_for_done_messages => \&watch_for_done_messages,