summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c50934f)
raw | patch | inline | side by side (parent: c50934f)
author | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 16 May 2008 10:04:52 +0000 (10:04 +0000) | ||
committer | rettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Fri, 16 May 2008 10:04:52 +0000 (10:04 +0000) |
* not jet finished
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10928 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10928 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-si/gosa-si-server-nobus | patch | blob | history | |
gosa-si/modules/DBsqlite.pm | patch | blob | history | |
gosa-si/server/events/gosaTriggered.pm | patch | blob | history |
index 9da1bca0c8d84c5af9a866cafaf9aafff8d8831f..886d908a1d76939e6126066fa21ea18362b34865 100755 (executable)
use POE qw(Component::Server::TCP Wheel::Run Filter::Reference);
use Net::LDAP;
use Net::LDAP::Util qw(:escape);
+use Time::HiRes qw( usleep);
my $modules_path = "/usr/lib/gosa-si/modules";
use lib "/usr/lib/gosa-si/modules";
daemon_log("shutting down gosa-si-server", 1);
- system("kill `ps -C gosa-si-server -o pid=`");
+ system("kill `ps -C gosa-si-server-nobus -o pid=`");
}
$SIG{INT} = \&sig_int_handler;
}
my $host_key = $hit->{hostkey};
daemon_log("$session_id DEBUG: input_from_known_server: host_name: $host_name", 7);
- daemon_log("DEBUG: input_from_known_server: host_key: $host_key", 7);
+ daemon_log("$session_id DEBUG: input_from_known_server: host_key: $host_key", 7);
# check if module can open msg envelope with module key
my ($tmp_msg, $tmp_msg_hash) = &check_key_and_xml_validity($input, $host_key, $session_id);
sub next_task {
my ($session, $heap) = @_[SESSION, HEAP];
-# if (keys( %{ $heap->{task} } ) < $max_children ) {
- my $task = POE::Wheel::Run->new(
- Program => sub { process_task($session, $heap) },
- StdioFilter => POE::Filter::Reference->new(),
- StdoutEvent => "task_result",
- StderrEvent => "task_debug",
- CloseEvent => "task_done",
- );
+ my $task = POE::Wheel::Run->new(
+ Program => sub { process_task($session, $heap) },
+ StdioFilter => POE::Filter::Reference->new(),
+ StdoutEvent => "task_result",
+ StderrEvent => "task_debug",
+ CloseEvent => "task_done",
+ );
- $heap->{task}->{ $task->ID } = $task;
-# }
+ $heap->{task}->{ $task->ID } = $task;
}
sub handle_task_result {
my ($answer_header, @answer_target_l, $answer_source);
my $client_answer = "";
- daemon_log("", 5);
- daemon_log("$session_id INFO: Incoming msg with session ID $session_id from '".$heap->{'remote_ip'}."'", 5);
- #daemon_log("$session_id DEBUG: Incoming msg:\n$input", 9);
-
##################################################
# fetch first unprocessed message from incoming_db
# sometimes the program is faster than sqlite, so wait until informations are present at db
$id_res = $incoming_db->exec_statement($id_sql);
$message_id = @{@$id_res[0]}[0];
if (defined $message_id) { last }
+ usleep(100000);
}
# fetch new message from incoming_db
my $res = $incoming_db->exec_statement($sql);
# prepare all variables needed to process message
- my $msg = @{@$res[0]}[3];
+ my $msg = @{@$res[0]}[4];
my $incoming_id = @{@$res[0]}[0];
- my $module = @{@$res[0]}[4];
+ my $module = @{@$res[0]}[5];
my $header = @{@$res[0]}[2];
my $msg_hash = $xml->XMLin($msg, ForceArray=>1);
######################
# process incoming msg
if( $error == 0) {
- daemon_log("$session_id INFO: Incoming msg with header '".@{$msg_hash->{'header'}}[0].
+ daemon_log("$session_id INFO: Incoming msg (session_id=$session_id) with header '".@{$msg_hash->{'header'}}[0].
"' from '".$heap->{'remote_ip'}."'", 5);
daemon_log("$session_id DEBUG: Processing module ".$module, 7);
$answer_l = &{ $module."::process_incoming_msg" }($msg, $msg_hash, $session_id);
if ( 0 < @{$answer_l} ) {
my $answer_str = join("\n", @{$answer_l});
- daemon_log("$session_id DEBUG: $module: Got answer from module: \n".$answer_str,8);
+ while ($answer_str =~ /<header>(\w+)<\/header>/g) {
+ daemon_log("$session_id INFO: got answer message with header '$1'", 5);
+ }
+ daemon_log("$session_id DEBUG: $module: got answer from module: \n".$answer_str,8);
} else {
- daemon_log("$session_id DEBUG: $module: Got no answer from module!" ,8);
+ daemon_log("$session_id DEBUG: $module: got no answer from module!" ,8);
}
}
foreach my $answer ( @{$answer_l} ) {
# check outgoing msg to xml validity
my $answer_hash = &check_outgoing_xml_validity($answer);
- if( not defined $answer_hash ) {
- next;
- }
+ if( not defined $answer_hash ) { next; }
$answer_header = @{$answer_hash->{'header'}}[0];
@answer_target_l = @{$answer_hash->{'target'}};
} elsif ($receiver =~ /^g_([\s\S]*)$/) {
my $group_name = $1;
# fetch all group members from ldap and add them to receiver hash
- my $ldap_handle = &get_ldap_handle($session_id);
+ my $ldap_handle = &get_ldap_handle();
if (defined $ldap_handle) {
my $mesg = $ldap_handle->search(
base => $ldap_base,
scope => 'sub',
attrs => ['memberUid'],
- filter => "cn=$group_name";
+ filter => "cn=$group_name",
);
if ($mesg->count) {
my @entries = $mesg->entries;
}
# translating errors ?
if ($mesg->code) {
- daemon_log("$session_id ERROR: unable to translate group '$group_name' to user list for message delivery: $mesg->error", 1);
+ daemon_log("M ERROR: unable to translate group '$group_name' to user list for message delivery: $mesg->error", 1);
}
# ldap handle error ?
} else {
- daemon_log("$session_id ERROR: unable to translate group '$group_name' to user list for message delivery: no ldap handle available", 1);
+ daemon_log("M ERROR: unable to translate group '$group_name' to user list for message delivery: no ldap handle available", 1);
}
} else {
my $sbjct = &encode_base64(@{$hit}[1]);
my ($kernel, $input) = @_[KERNEL, ARG0];
push(@tasks, $input);
push(@msgs_to_decrypt, $input);
- $kernel->yield("next_task");
$kernel->yield("msg_to_decrypt");
+ $kernel->yield("next_task");
},
InlineStates => {
next_task => \&next_task,
index 5421f099b5545dd18085dbc74c9bbdcb6a36e355..d1bd03d23ab77882702dbccd206922c89c833a89 100644 (file)
my $create_id=0;
foreach my $col_name (@{$col_names}) {
if($col_name eq "id" && (! exists $arg->{$col_name})) {
- &main::daemon_log("DEBUG: id field found without value! Creating autoincrement statement!");
+ &main::daemon_log("0 DEBUG: id field found without value! Creating autoincrement statement!", 7);
$create_id=1;
}
}
index bb49c9b3ec0cfa2d1ecacb682a7128a87ce1b427..7e36769746f05c4b74d002713306c6f39f0df1a5 100644 (file)
"gen_smb_hash",
"trigger_reload_ldap_config",
"ping",
+ "new_ping",
"network_completition",
"set_activated_for_installation",
"new_key_for_client",
use Net::ARP;
use Net::Ping;
use Socket;
+use Time::HiRes qw( usleep);
BEGIN {}
my @out_msg_l = ( $out_msg );
return @out_msg_l;
}
+sub new_ping {
+ my ($msg, $msg_hash, $session_id) = @_ ;
+ my ($sql, $res);
+ my $out_msg = $msg;
+ my $jobdb_id = @{$msg_hash->{'jobdb_id'}}[0];
+ if( defined $jobdb_id) {
+ my $sql_statement = "UPDATE $main::job_queue_tn SET status='processed' WHERE id=jobdb_id";
+ &main::daemon_log("$session_id DEBUG: $sql_statement", 7);
+ my $res = $main::job_db->exec_statement($sql_statement);
+ }
+
+ $out_msg =~ s/<header>gosa_/<header>/;
+
+ # send message
+ my $header = @{$msg_hash->{header}}[0];
+ my $target = @{$msg_hash->{target}}[0];
+
+ $sql = "SELECT * FROM $main::known_clients_tn WHERE ((hostname='$target') || (macaddress LIKE '$target'))";
+ #&main::daemon_log("$sql",1);
+ $res = $main::known_clients_db->exec_statement($sql);
+ #&main::daemon_log(Dumper($res), 1);
+ my $host_name = @{@$res[0]}[0];
+ $out_msg =~ s/<target>\S+<\/target>/<target>$host_name<\/target>/;
+ $out_msg =~ s/<source>\S+<\/source>/<source>$main::server_address<\/source>/;
+ $out_msg =~ s/<\/xml>/<session_id>$session_id<\/session_id><\/xml>/;
+ my $host_key = @{@$res[0]}[2];
+
+ my $error = &main::send_msg_to_target($out_msg, $host_name, $host_key, $header, $session_id);
+ #if ($error != 0) {}
+
+ my $message_id;
+ while (1) {
+ $sql = "SELECT * FROM $main::incoming_tn WHERE headertag='answer_$session_id'";
+ $res = $main::incoming_db->exec_statement($sql);
+ if (ref @$res[0] eq "ARRAY") {
+ $message_id = @{@$res[0]}[0];
+ last;
+ }
+ usleep(100000);
+ }
+ my $answer_xml = @{@$res[0]}[3];
+ my %data = ( 'answer_xml' => 'bin noch da' );
+ my $answer_msg = &build_msg("got_ping", "$main::server_address", "GOSA", \%data);
+
+ $sql = "DELETE FROM $main::incoming_tn WHERE id=$message_id";
+ $res = $main::incoming_db->exec_statement($sql);
+
+
+ my @answer_msg_l = ( $answer_msg );
+ return @answer_msg_l;
+}
+
+
sub gen_smb_hash {
my ($msg, $msg_hash, $session_id) = @_ ;