From bda15ae2d1a5632b62c26030a32d9cd652a32d5d Mon Sep 17 00:00:00 2001 From: rettenbe Date: Fri, 29 May 2009 12:36:26 +0000 Subject: [PATCH] * diffrent delivery handling for incoming messages * bugfixing functions get_login_usr_for_client and get_client_for_login_usr -- Diese und die folgenden Zeilen werde -- M server/events/gosaTriggered.pm M gosa-si-server git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13680 594d385d-05f5-0310-b6e9-bd551577e9d8 --- gosa-si/gosa-si-server | 50 +++++++++++++++++++++++--- gosa-si/server/events/gosaTriggered.pm | 11 +++--- 2 files changed, 49 insertions(+), 12 deletions(-) diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server index 2f50b6a52..e1fa9767f 100755 --- a/gosa-si/gosa-si-server +++ b/gosa-si/gosa-si-server @@ -105,6 +105,7 @@ our $cfg_file; our ($ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $ldap_server_dn, $ldap_version); our ($mysql_username, $mysql_password, $mysql_database, $mysql_host); our $known_modules; +our $known_functions; our $root_uid; our $adm_gid; @@ -1027,7 +1028,7 @@ sub update_jobdb_status_for_send_msgs { } } } else { - &daemon_log("$session_id DEBUG: cannot update job status, msg has no jobdb_id-tag: $answer", 7); + &daemon_log("$session_id DEBUG: cannot update job status, msg has no jobdb_id-tag.", 7); } } @@ -1172,7 +1173,7 @@ sub msg_to_decrypt { } } - # target ist own address with forward_to_gosa-tag not pointing to myself -> process here + # target is own address with forward_to_gosa-tag not pointing to myself -> process here if (not $done) { my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0]; my $gosa_at; @@ -1186,6 +1187,27 @@ sub msg_to_decrypt { } } + # Target is a client address and there is a processing function within a plugin -> process loaclly + if (not $done) + { + # Check if target is a client address + $sql = "SELECT * FROM $known_clients_tn WHERE (hostname='$target' OR macaddress LIKE '$target')"; + $res = $known_clients_db->select_dbentry($sql); + if ((keys(%$res) > 0) ) + { + my $hostname = $res->{1}->{'hostname'}; + my $reduced_header = $header; + $reduced_header =~ s/gosa_//; + # Check if there is a processing function within a plugin + if (exists $known_functions->{$reduced_header}) + { + $msg =~ s/\S*<\/target>/$hostname<\/target>/; + $done = 1; + &daemon_log("$session_id DEBUG: Target is client address with processing function within a plugin -> process here", 7); + } + } + } + # If header has a 'job_' prefix, do always process message locally # which means put it into job queue if ((not $done) && ($header =~ /job_/)) @@ -1242,9 +1264,10 @@ sub msg_to_decrypt { if (not $done) { $sql = "SELECT * FROM $known_clients_tn WHERE (hostname='$target' OR macaddress LIKE '$target')"; $res = $known_clients_db->select_dbentry($sql); - if (keys(%$res) > 0) { - &daemon_log("$session_id DEBUG: target is a client address in known_clients -> forward to client", 7); + if (keys(%$res) > 0) + { $done = 1; + &daemon_log("$session_id DEBUG: target is a client address in known_clients -> forward to client", 7); my $hostkey = $res->{1}->{'hostkey'}; my $hostname = $res->{1}->{'hostname'}; $msg =~ s/\S*<\/target>/$hostname<\/target>/; @@ -1253,7 +1276,9 @@ sub msg_to_decrypt { if ($error) { &daemon_log("$session_id ERROR: Some problems occurred while trying to send msg to client '$hostkey': $msg", 1); } - } else { + } + else + { $not_found_in_known_clients_db = 1; } } @@ -3523,6 +3548,21 @@ foreach my $foreign_server (@foreign_server_list) { # Check wether all modules are gosa-si valid passwd check &password_check; +# Create functions hash +#print STDERR Dumper $known_modules; +while (my ($module, @mod_info) = each %$known_modules) +{ +#print STDERR Dumper $module; + while (my ($plugin, $functions) = each %{$mod_info[0][2]}) + { +#print STDERR Dumper $functions; + while (my ($function, $nothing) = each %$functions ) + { + $known_functions->{$function} = $nothing; + } + } +} + # Prepare for using Opsi if ($opsi_enabled eq "true") { use JSON::RPC::Client; diff --git a/gosa-si/server/events/gosaTriggered.pm b/gosa-si/server/events/gosaTriggered.pm index 237776221..5b645e859 100644 --- a/gosa-si/server/events/gosaTriggered.pm +++ b/gosa-si/server/events/gosaTriggered.pm @@ -17,8 +17,6 @@ my @events = ( "set_activated_for_installation", "new_key_for_client", "detect_hardware", - "get_login_usr", - "get_login_client", "trigger_action_localboot", "trigger_action_faireboot", "trigger_action_reboot", @@ -213,12 +211,12 @@ sub get_login_usr_for_client { 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); + &main::daemon_log("$session_id DEBUG: $sql_statement", 7); my $res = $main::job_db->exec_statement($sql_statement); } - # If $client is a mac address - if ($client =~ /^\w\w:\w\w:\w\w:\w\w:\w\w:\w\w$/i) + # If $client is a mac address + if ($client =~ /^\w\w:\w\w:\w\w:\w\w:\w\w:\w\w$/i) { # Search for hostname of $client within known_clients_db my $sql = "SELECT * FROM $main::known_clients_tn WHERE macaddress LIKE '$client'"; @@ -276,7 +274,7 @@ sub get_client_for_login_usr { 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); + &main::daemon_log("$session_id DEBUG: $sql_statement", 7); my $res = $main::job_db->exec_statement($sql_statement); } @@ -290,7 +288,6 @@ sub get_client_for_login_usr { $out_msg .= ""; return ( $out_msg ); - } -- 2.30.2