X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-si%2Fgosa-si-server;h=e8abf699299c94ff63895383fd1b8d98302903c0;hb=446b8856cd871ce456b737b7cc7b32407125d97d;hp=aa8590f954ff932dd183b1bb0c6bb90aae0616e2;hpb=d9062c4b34dc5a7bb1258bba8404dd7f7fac976d;p=gosa.git
diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index aa8590f95..e8abf6992 100755
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
@@ -48,7 +48,7 @@ use File::Basename;
use File::Find;
use File::Copy;
use File::Path;
-use GOSA::DBsqlite;
+use GOSA::DBmysql;
use GOSA::GosaSupportDaemon;
use POE qw(Component::Server::TCP Wheel::Run Filter::Reference);
use Net::LDAP;
@@ -78,9 +78,10 @@ my $max_clients;
my %repo_files=();
my $repo_path;
my %repo_dirs=();
-# variables declared in config file are always set to 'our'
+
+# Variables declared in config file are always set to 'our'
our (%cfg_defaults, $log_file, $pid_file,
- $server_ip, $server_port, $ClientPackages_key,
+ $server_ip, $server_port, $ClientPackages_key, $dns_lookup,
$arp_activ, $gosa_unit_tag,
$GosaPackages_key, $gosa_timeout,
$foreign_server_string, $server_domain, $ServerPackages_key, $foreign_servers_register_delay,
@@ -99,7 +100,11 @@ our $verbose;
our $forground;
our $cfg_file;
our ($ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $ldap_server_dn);
+our ($mysql_username, $mysql_password, $mysql_database, $mysql_host);
our $known_modules;
+our $root_uid;
+our $adm_gid;
+
# specifies the verbosity of the daemon_log
$verbose = 0 ;
@@ -119,81 +124,81 @@ my $watch_for_new_jobs_in_progress = 0;
our $incoming_db;
our $incoming_tn = 'incoming';
my $incoming_file_name;
-my @incoming_col_names = ("id INTEGER PRIMARY KEY",
- "timestamp DEFAULT 'none'",
- "headertag DEFAULT 'none'",
- "targettag DEFAULT 'none'",
- "xmlmessage DEFAULT 'none'",
- "module DEFAULT 'none'",
- "sessionid DEFAULT '0'",
- );
+my @incoming_col_names = ("id INTEGER PRIMARY KEY auto_increment",
+ "timestamp VARCHAR(14) DEFAULT 'none'",
+ "headertag VARCHAR(255) DEFAULT 'none'",
+ "targettag VARCHAR(255) DEFAULT 'none'",
+ "xmlmessage TEXT",
+ "module VARCHAR(255) DEFAULT 'none'",
+ "sessionid VARCHAR(255) DEFAULT '0'",
+);
# holds all gosa jobs
our $job_db;
our $job_queue_tn = 'jobs';
my $job_queue_file_name;
-my @job_queue_col_names = ("id INTEGER PRIMARY KEY",
- "timestamp DEFAULT 'none'",
- "status DEFAULT 'none'",
- "result DEFAULT 'none'",
- "progress DEFAULT 'none'",
- "headertag DEFAULT 'none'",
- "targettag DEFAULT 'none'",
- "xmlmessage DEFAULT 'none'",
- "macaddress DEFAULT 'none'",
- "plainname DEFAULT 'none'",
- "siserver DEFAULT 'none'",
- "modified DEFAULT '0'",
- );
+my @job_queue_col_names = ("id INTEGER PRIMARY KEY auto_increment",
+ "timestamp VARCHAR(14) DEFAULT 'none'",
+ "status VARCHAR(255) DEFAULT 'none'",
+ "result TEXT",
+ "progress VARCHAR(255) DEFAULT 'none'",
+ "headertag VARCHAR(255) DEFAULT 'none'",
+ "targettag VARCHAR(255) DEFAULT 'none'",
+ "xmlmessage TEXT",
+ "macaddress VARCHAR(17) DEFAULT 'none'",
+ "plainname VARCHAR(255) DEFAULT 'none'",
+ "siserver VARCHAR(255) DEFAULT 'none'",
+ "modified INTEGER DEFAULT '0'",
+);
# holds all other gosa-si-server
our $known_server_db;
our $known_server_tn = "known_server";
my $known_server_file_name;
-my @known_server_col_names = ("hostname", "macaddress", "status", "hostkey", "loaded_modules", "timestamp");
+my @known_server_col_names = ("hostname VARCHAR(255)", "macaddress VARCHAR(17)", "status VARCHAR(255)", "hostkey VARCHAR(255)", "loaded_modules TEXT", "timestamp VARCHAR(14)");
# holds all registrated clients
our $known_clients_db;
our $known_clients_tn = "known_clients";
my $known_clients_file_name;
-my @known_clients_col_names = ("hostname", "status", "hostkey", "timestamp", "macaddress", "events", "keylifetime");
+my @known_clients_col_names = ("hostname VARCHAR(255)", "status VARCHAR(255)", "hostkey VARCHAR(255)", "timestamp VARCHAR(14)", "macaddress VARCHAR(17)", "events TEXT", "keylifetime VARCHAR(255)");
# holds all registered clients at a foreign server
our $foreign_clients_db;
our $foreign_clients_tn = "foreign_clients";
my $foreign_clients_file_name;
-my @foreign_clients_col_names = ("hostname", "macaddress", "regserver", "timestamp");
+my @foreign_clients_col_names = ("hostname VARCHAR(255)", "macaddress VARCHAR(17)", "regserver VARCHAR(255)", "timestamp VARCHAR(14)");
# holds all logged in user at each client
our $login_users_db;
our $login_users_tn = "login_users";
my $login_users_file_name;
-my @login_users_col_names = ("client", "user", "timestamp");
+my @login_users_col_names = ("client VARCHAR(255)", "user VARCHAR(255)", "timestamp VARCHAR(14)");
# holds all fai server, the debian release and tag
our $fai_server_db;
our $fai_server_tn = "fai_server";
my $fai_server_file_name;
-our @fai_server_col_names = ("timestamp", "server", "release", "sections", "tag");
+our @fai_server_col_names = ("timestamp VARCHAR(14)", "server VARCHAR(255)", "fai_release VARCHAR(255)", "sections VARCHAR(255)", "tag VARCHAR(255)");
our $fai_release_db;
our $fai_release_tn = "fai_release";
my $fai_release_file_name;
-our @fai_release_col_names = ("timestamp", "release", "class", "type", "state");
+our @fai_release_col_names = ("timestamp VARCHAR(14)", "fai_release VARCHAR(255)", "class VARCHAR(255)", "type VARCHAR(255)", "state VARCHAR(255)");
# holds all packages available from different repositories
our $packages_list_db;
our $packages_list_tn = "packages_list";
my $packages_list_file_name;
-our @packages_list_col_names = ("distribution", "package", "version", "section", "description", "template", "timestamp");
+our @packages_list_col_names = ("distribution VARCHAR(255)", "package VARCHAR(255)", "version VARCHAR(255)", "section VARCHAR(255)", "description TEXT", "template LONGBLOB", "timestamp VARCHAR(14)");
my $outdir = "/tmp/packages_list_db";
my $arch = "i386";
# holds all messages which should be delivered to a user
our $messaging_db;
our $messaging_tn = "messaging";
-our @messaging_col_names = ("id INTEGER", "subject", "message_from", "message_to",
- "flag", "direction", "delivery_time", "message", "timestamp" );
+our @messaging_col_names = ("id INTEGER", "subject TEXT", "message_from VARCHAR(255)", "message_to VARCHAR(255)",
+ "flag VARCHAR(255)", "direction VARCHAR(255)", "delivery_time VARCHAR(255)", "message TEXT", "timestamp VARCHAR(14)" );
my $messaging_file_name;
# path to directory to store client install log files
@@ -222,26 +227,30 @@ our $logged_in_user_date_of_expiry = 600;
"pid-file" => [\$pid_file, "/var/run/".$prg.".pid"],
},
"server" => {
- "ip" => [\$server_ip, "0.0.0.0"],
- "port" => [\$server_port, "20081"],
- "known-clients" => [\$known_clients_file_name, '/var/lib/gosa-si/clients.db' ],
- "known-servers" => [\$known_server_file_name, '/var/lib/gosa-si/servers.db'],
- "incoming" => [\$incoming_file_name, '/var/lib/gosa-si/incoming.db'],
- "login-users" => [\$login_users_file_name, '/var/lib/gosa-si/users.db'],
- "fai-server" => [\$fai_server_file_name, '/var/lib/gosa-si/fai_server.db'],
- "fai-release" => [\$fai_release_file_name, '/var/lib/gosa-si/fai_release.db'],
- "packages-list" => [\$packages_list_file_name, '/var/lib/gosa-si/packages.db'],
- "messaging" => [\$messaging_file_name, '/var/lib/gosa-si/messaging.db'],
- "foreign-clients" => [\$foreign_clients_file_name, '/var/lib/gosa-si/foreign_clients.db'],
- "source-list" => [\$sources_list, '/etc/apt/sources.list'],
- "repo-path" => [\$repo_path, '/srv/www/repository'],
- "ldap-uri" => [\$ldap_uri, ""],
- "ldap-base" => [\$ldap_base, ""],
- "ldap-admin-dn" => [\$ldap_admin_dn, ""],
- "ldap-admin-password" => [\$ldap_admin_password, ""],
- "gosa-unit-tag" => [\$gosa_unit_tag, ""],
- "max-clients" => [\$max_clients, 10],
- "wol-password" => [\$wake_on_lan_passwd, ""],
+ "ip" => [\$server_ip, "0.0.0.0"],
+ "port" => [\$server_port, "20081"],
+ "known-clients" => [\$known_clients_file_name, '/var/lib/gosa-si/clients.db' ],
+ "known-servers" => [\$known_server_file_name, '/var/lib/gosa-si/servers.db'],
+ "incoming" => [\$incoming_file_name, '/var/lib/gosa-si/incoming.db'],
+ "login-users" => [\$login_users_file_name, '/var/lib/gosa-si/users.db'],
+ "fai-server" => [\$fai_server_file_name, '/var/lib/gosa-si/fai_server.db'],
+ "fai-release" => [\$fai_release_file_name, '/var/lib/gosa-si/fai_release.db'],
+ "packages-list" => [\$packages_list_file_name, '/var/lib/gosa-si/packages.db'],
+ "messaging" => [\$messaging_file_name, '/var/lib/gosa-si/messaging.db'],
+ "foreign-clients" => [\$foreign_clients_file_name, '/var/lib/gosa-si/foreign_clients.db'],
+ "source-list" => [\$sources_list, '/etc/apt/sources.list'],
+ "repo-path" => [\$repo_path, '/srv/www/repository'],
+ "ldap-uri" => [\$ldap_uri, ""],
+ "ldap-base" => [\$ldap_base, ""],
+ "ldap-admin-dn" => [\$ldap_admin_dn, ""],
+ "ldap-admin-password" => [\$ldap_admin_password, ""],
+ "gosa-unit-tag" => [\$gosa_unit_tag, ""],
+ "max-clients" => [\$max_clients, 10],
+ "wol-password" => [\$wake_on_lan_passwd, ""],
+ "mysql-username" => [\$mysql_username, "gosa_si"],
+ "mysql-password" => [\$mysql_password, ""],
+ "mysql-database" => [\$mysql_database, "gosa_si"],
+ "mysql-host" => [\$mysql_host, "127.0.0.1"],
},
"GOsaPackages" => {
"job-queue" => [\$job_queue_file_name, '/var/lib/gosa-si/jobs.db'],
@@ -256,6 +265,7 @@ our $logged_in_user_date_of_expiry = 600;
},
"ServerPackages"=> {
"address" => [\$foreign_server_string, ""],
+ "dns-lookup" => [\$dns_lookup, "true"],
"domain" => [\$server_domain, ""],
"key" => [\$ServerPackages_key, "none"],
"key-lifetime" => [\$foreign_servers_register_delay, 120],
@@ -312,7 +322,6 @@ sub daemon_log {
if(not defined $level) { $level = 1 }
if(defined $log_file){
open(LOG_HANDLE, ">>$log_file");
- chmod 0600, $log_file;
if(not defined open( LOG_HANDLE, ">>$log_file" )) {
print STDERR "cannot open $log_file: $!";
return
@@ -446,7 +455,7 @@ sub import_modules {
eval { require $file; };
if ($@) {
daemon_log("0 ERROR: gosa-si-server could not load module $file", 1);
- daemon_log("$@", 5);
+ daemon_log("$@", 1);
} else {
my $info = eval($mod_name.'::get_module_info()');
# Only load module if get_module_info() returns a non-null object
@@ -696,42 +705,41 @@ sub input_from_known_client {
sub input_from_unknown_host {
- no strict "refs";
- my ($input, $session_id) = @_ ;
- my ($msg, $msg_hash, $module);
- my $error_string;
-
+ no strict "refs";
+ my ($input, $session_id) = @_ ;
+ my ($msg, $msg_hash, $module);
+ my $error_string;
+
my %act_modules = %$known_modules;
-
- while( my ($mod, $info) = each(%act_modules)) {
- # check a key exists for this module
- my $module_key = ${$mod."_key"};
- if( not defined $module_key ) {
- if( $mod eq 'ArpHandler' ) {
- next;
- }
- daemon_log("$session_id ERROR: no key specified in config file for $mod", 1);
- next;
- }
- daemon_log("$session_id DEBUG: $mod: $module_key", 7);
+ while( my ($mod, $info) = each(%act_modules)) {
- # check if module can open msg envelope with module key
- ($msg, $msg_hash) = &check_key_and_xml_validity($input, $module_key, $session_id);
- if( (not defined $msg) || (not defined $msg_hash) ) {
- next;
- }
- else {
- $module = $mod;
- last;
- }
- }
+ # check a key exists for this module
+ my $module_key = ${$mod."_key"};
+ if( not defined $module_key ) {
+ if( $mod eq 'ArpHandler' ) {
+ next;
+ }
+ daemon_log("$session_id ERROR: no key specified in config file for $mod", 1);
+ next;
+ }
+ daemon_log("$session_id DEBUG: $mod: $module_key", 7);
- if( (!$msg) || (!$msg_hash) || (!$module)) {
- daemon_log("$session_id DEBUG: Incoming message is not from an unknown host", 7);
- }
+ # check if module can open msg envelope with module key
+ ($msg, $msg_hash) = &check_key_and_xml_validity($input, $module_key, $session_id);
+ if( (not defined $msg) || (not defined $msg_hash) ) {
+ next;
+ } else {
+ $module = $mod;
+ last;
+ }
+ }
- return ($msg, $msg_hash, $module);
+ if( (!$msg) || (!$msg_hash) || (!$module)) {
+ daemon_log("$session_id DEBUG: Incoming message is not from an unknown host", 7);
+ }
+
+ return ($msg, $msg_hash, $module);
}
@@ -1008,260 +1016,264 @@ sub sig_handler {
sub msg_to_decrypt {
- my ($kernel, $session, $heap) = @_[KERNEL, SESSION, HEAP];
- my $session_id = $session->ID;
- my ($msg, $msg_hash, $module);
- my $error = 0;
+ my ($kernel, $session, $heap) = @_[KERNEL, SESSION, HEAP];
+ my $session_id = $session->ID;
+ my ($msg, $msg_hash, $module);
+ my $error = 0;
- # hole neue msg aus @msgs_to_decrypt
- my $next_msg = shift @msgs_to_decrypt;
-
- # entschlüssle sie
+ # hole neue msg aus @msgs_to_decrypt
+ my $next_msg = shift @msgs_to_decrypt;
- # msg is from a new client or gosa
- ($msg, $msg_hash, $module) = &input_from_unknown_host($next_msg, $session_id);
- # msg is from a gosa-si-server
- if(( !$msg ) || ( !$msg_hash ) || ( !$module )){
- ($msg, $msg_hash, $module) = &input_from_known_server($next_msg, $heap->{'remote_ip'}, $session_id);
- }
- # msg is from a gosa-si-client
- if(( !$msg ) || ( !$msg_hash ) || ( !$module )){
- ($msg, $msg_hash, $module) = &input_from_known_client($next_msg, $heap->{'remote_ip'}, $session_id);
- }
- # an error occurred
- if(( !$msg ) || ( !$msg_hash ) || ( !$module )){
- # if an incoming msg could not be decrypted (maybe a wrong key), send client a ping. If the client
- # could not understand a msg from its server the client cause a re-registering process
- daemon_log("$session_id WARNING cannot understand incoming msg, send 'ping'-msg to all host with ip '".$heap->{remote_ip}.
- "' to cause a re-registering of the client if necessary", 3);
- my $sql_statement = "SELECT * FROM $main::known_clients_tn WHERE (hostname LIKE '".$heap->{'remote_ip'}."%')";
- my $query_res = $known_clients_db->select_dbentry( $sql_statement );
- while( my ($hit_num, $hit) = each %{ $query_res } ) {
- my $host_name = $hit->{'hostname'};
- my $host_key = $hit->{'hostkey'};
- my $ping_msg = " $host_name";
- my $error = &send_msg_to_target($ping_msg, $host_name, $host_key, "gosa_ping", $session_id);
- &update_jobdb_status_for_send_msgs($ping_msg, $error);
- }
- $error++;
- }
+ # entschlüssle sie
+ # msg is from a new client or gosa
+ ($msg, $msg_hash, $module) = &input_from_unknown_host($next_msg, $session_id);
+ # msg is from a gosa-si-server
+ if(( !$msg ) || ( !$msg_hash ) || ( !$module )){
+ ($msg, $msg_hash, $module) = &input_from_known_server($next_msg, $heap->{'remote_ip'}, $session_id);
+ }
+ # msg is from a gosa-si-client
+ if(( !$msg ) || ( !$msg_hash ) || ( !$module )){
+ ($msg, $msg_hash, $module) = &input_from_known_client($next_msg, $heap->{'remote_ip'}, $session_id);
+ }
+ # an error occurred
+ if(( !$msg ) || ( !$msg_hash ) || ( !$module )){
+ # if an incoming msg could not be decrypted (maybe a wrong key), send client a ping. If the client
+ # could not understand a msg from its server the client cause a re-registering process
+ daemon_log("$session_id WARNING cannot understand incoming msg, send 'ping'-msg to all host with ip '".$heap->{remote_ip}.
+ "' to cause a re-registering of the client if necessary", 3);
+ my $sql_statement = "SELECT * FROM $main::known_clients_tn WHERE (hostname LIKE '".$heap->{'remote_ip'}."%')";
+ my $query_res = $known_clients_db->select_dbentry( $sql_statement );
+ while( my ($hit_num, $hit) = each %{ $query_res } ) {
+ my $host_name = $hit->{'hostname'};
+ my $host_key = $hit->{'hostkey'};
+ my $ping_msg = " $host_name";
+ my $error = &send_msg_to_target($ping_msg, $host_name, $host_key, "gosa_ping", $session_id);
+ &update_jobdb_status_for_send_msgs($ping_msg, $error);
+ }
+ $error++;
+ }
- my $header;
- my $target;
- my $source;
- my $done = 0;
- my $sql;
- my $res;
-
- # check whether this message should be processed here
- if ($error == 0) {
- $header = @{$msg_hash->{'header'}}[0];
- $target = @{$msg_hash->{'target'}}[0];
- $source = @{$msg_hash->{'source'}}[0];
+
+ my $header;
+ my $target;
+ my $source;
+ my $done = 0;
+ my $sql;
+ my $res;
+
+ # check whether this message should be processed here
+ if ($error == 0) {
+ $header = @{$msg_hash->{'header'}}[0];
+ $target = @{$msg_hash->{'target'}}[0];
+ $source = @{$msg_hash->{'source'}}[0];
my $not_found_in_known_clients_db = 0;
my $not_found_in_known_server_db = 0;
my $not_found_in_foreign_clients_db = 0;
- my $local_address;
- my $local_mac;
- my ($target_ip, $target_port) = split(':', $target);
-
- # Determine the local ip address if target is an ip address
+ my $local_address;
+ my $local_mac;
+ my ($target_ip, $target_port) = split(':', $target);
+
+ # Determine the local ip address if target is an ip address
if ($target =~ /^\d+\.\d+\.\d+\.\d+:\d+$/) {
$local_address = &get_local_ip_for_remote_ip($target_ip).":$server_port";
} else {
- $local_address = $server_address;
- }
+ $local_address = $server_address;
+ }
- # Determine the local mac address if target is a mac address
- if ($target =~ /^([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})$/i) {
- my $loc_ip = &get_local_ip_for_remote_ip($heap->{'remote_ip'});
- my $network_interface= &get_interface_for_ip($loc_ip);
- $local_mac = &get_mac_for_interface($network_interface);
- } else {
- $local_mac = $server_mac_address;
- }
+ # Determine the local mac address if target is a mac address
+ if ($target =~ /^([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2})$/i) {
+ my $loc_ip = &get_local_ip_for_remote_ip($heap->{'remote_ip'});
+ my $network_interface= &get_interface_for_ip($loc_ip);
+ $local_mac = &get_mac_for_interface($network_interface);
+ } else {
+ $local_mac = $server_mac_address;
+ }
- # target and source is equal to GOSA -> process here
- if (not $done) {
- if ($target eq "GOSA" && $source eq "GOSA") {
- $done = 1;
- }
- }
+ # target and source is equal to GOSA -> process here
+ if (not $done) {
+ if ($target eq "GOSA" && $source eq "GOSA") {
+ $done = 1;
+ &daemon_log("$session_id DEBUG: target and source is 'GOSA' -> process here", 7);
+ }
+ }
- # target is own address without forward_to_gosa-tag -> process here
- if (not $done) {
- #if ((($target eq $local_address) || ($target eq $local_mac) ) && (not exists $msg_hash->{'forward_to_gosa'})) {
- if (($target eq $local_address) && (not exists $msg_hash->{'forward_to_gosa'})) {
- $done = 1;
- if ($source eq "GOSA") {
- $msg =~ s/<\/xml>/$local_address,$session_id<\/forward_to_gosa><\/xml>/;
- }
- #print STDERR "target is own address without forward_to_gosa-tag -> process here\n";
- }
- }
+ # target is own address without forward_to_gosa-tag -> process here
+ if (not $done) {
+ #if ((($target eq $local_address) || ($target eq $local_mac) ) && (not exists $msg_hash->{'forward_to_gosa'})) {
+ if (($target eq $local_address) && (not exists $msg_hash->{'forward_to_gosa'})) {
+ $done = 1;
+ if ($source eq "GOSA") {
+ $msg =~ s/<\/xml>/$local_address,$session_id<\/forward_to_gosa><\/xml>/;
+ }
+ &daemon_log("$session_id DEBUG: target is own address without forward_to_gosa-tag -> process here", 7);
+ }
+ }
- # target is a client address in known_clients -> process here
+ # target is a client address in known_clients -> process here
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) {
- $done = 1;
- my $hostname = $res->{1}->{'hostname'};
- $msg =~ s/$target<\/target>/$hostname<\/target>/;
- #print STDERR "target is a client address in known_clients -> process here\n";
- my $local_address = &get_local_ip_for_remote_ip($target_ip).":$server_port";
- if ($source eq "GOSA") {
- $msg =~ s/<\/xml>/$local_address,$session_id<\/forward_to_gosa><\/xml>/;
- }
+ $sql = "SELECT * FROM $known_clients_tn WHERE (hostname='$target' OR macaddress LIKE '$target')";
+ $res = $known_clients_db->select_dbentry($sql);
+ if (keys(%$res) > 0) {
+ $done = 1;
+ my $hostname = $res->{1}->{'hostname'};
+ $msg =~ s/$target<\/target>/$hostname<\/target>/;
+ my $local_address = &get_local_ip_for_remote_ip($target_ip).":$server_port";
+ if ($source eq "GOSA") {
+ $msg =~ s/<\/xml>/$local_address,$session_id<\/forward_to_gosa><\/xml>/;
+ }
+ &daemon_log("$session_id DEBUG: target is a client address in known_clients -> process here", 7);
- } else {
- $not_found_in_known_clients_db = 1;
+ } else {
+ $not_found_in_known_clients_db = 1;
+ }
+ }
+
+ # target ist 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;
+ my $gosa_session_id;
+ if (($target eq $local_address) && (defined $forward_to_gosa)){
+ my ($gosa_at, $gosa_session_id) = split(/,/, $forward_to_gosa);
+ if ($gosa_at ne $local_address) {
+ $done = 1;
+ &daemon_log("$session_id DEBUG: target is own address with forward_to_gosa-tag not pointing to myself -> process here", 7);
}
+ }
}
-
- # target ist 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;
- my $gosa_session_id;
- if (($target eq $local_address) && (defined $forward_to_gosa)){
- my ($gosa_at, $gosa_session_id) = split(/,/, $forward_to_gosa);
- if ($gosa_at ne $local_address) {
- $done = 1;
- #print STDERR "target is own address with forward_to_gosa-tag not pointing to myself -> process here\n";
- }
- }
- }
- # if message should be processed here -> add message to incoming_db
+ # if message should be processed here -> add message to incoming_db
if ($done) {
- # if a job or a gosa message comes from a foreign server, fake module to GosaPackages
- # so gosa-si-server knows how to process this kind of messages
- if ($header =~ /^gosa_/ || $header =~ /^job_/) {
- $module = "GosaPackages";
- }
+ # if a job or a gosa message comes from a foreign server, fake module to GosaPackages
+ # so gosa-si-server knows how to process this kind of messages
+ if ($header =~ /^gosa_/ || $header =~ /^job_/) {
+ $module = "GosaPackages";
+ }
+
+ my $res = $incoming_db->add_dbentry( {table=>$incoming_tn,
+ primkey=>[],
+ headertag=>$header,
+ targettag=>$target,
+ xmlmessage=>&encode_base64($msg),
+ timestamp=>&get_time,
+ module=>$module,
+ sessionid=>$session_id,
+ } );
- my $res = $incoming_db->add_dbentry( {table=>$incoming_tn,
- primkey=>[],
- headertag=>$header,
- targettag=>$target,
- xmlmessage=>&encode_base64($msg),
- timestamp=>&get_time,
- module=>$module,
- sessionid=>$session_id,
- } );
}
- # target is own address with forward_to_gosa-tag pointing at myself -> forward to gosa
- if (not $done) {
- my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
- my $gosa_at;
- my $gosa_session_id;
- if (($target eq $local_address) && (defined $forward_to_gosa)){
- my ($gosa_at, $gosa_session_id) = split(/,/, $forward_to_gosa);
- if ($gosa_at eq $local_address) {
- my $session_reference = $kernel->ID_id_to_session($gosa_session_id);
- if( defined $session_reference ) {
- $heap = $session_reference->get_heap();
- }
- if(exists $heap->{'client'}) {
- $msg = &encrypt_msg($msg, $GosaPackages_key);
- $heap->{'client'}->put($msg);
- &daemon_log("$session_id INFO: incoming '$header' message forwarded to GOsa", 5);
- }
- $done = 1;
- #print STDERR "target is own address with forward_to_gosa-tag pointing at myself -> forward to gosa\n";
- }
- }
+ # target is own address with forward_to_gosa-tag pointing at myself -> forward to gosa
+ if (not $done) {
+ my $forward_to_gosa = @{$msg_hash->{'forward_to_gosa'}}[0];
+ my $gosa_at;
+ my $gosa_session_id;
+ if (($target eq $local_address) && (defined $forward_to_gosa)){
+ my ($gosa_at, $gosa_session_id) = split(/,/, $forward_to_gosa);
+ if ($gosa_at eq $local_address) {
+ my $session_reference = $kernel->ID_id_to_session($gosa_session_id);
+ if( defined $session_reference ) {
+ $heap = $session_reference->get_heap();
+ }
+ if(exists $heap->{'client'}) {
+ $msg = &encrypt_msg($msg, $GosaPackages_key);
+ $heap->{'client'}->put($msg);
+ &daemon_log("$session_id INFO: incoming '$header' message forwarded to GOsa", 5);
+ }
+ $done = 1;
+ &daemon_log("$session_id DEBUG: target is own address with forward_to_gosa-tag pointing at myself -> forward to gosa", 7);
+ }
+ }
- }
+ }
- # target is a client address in foreign_clients -> forward to registration server
- if (not $done) {
- $sql = "SELECT * FROM $foreign_clients_tn WHERE (hostname='$target' OR macaddress LIKE '$target')";
- $res = $foreign_clients_db->select_dbentry($sql);
- if (keys(%$res) > 0) {
- my $hostname = $res->{1}->{'hostname'};
- my ($host_ip, $host_port) = split(/:/, $hostname);
- my $local_address = &get_local_ip_for_remote_ip($host_ip).":$server_port";
- my $regserver = $res->{1}->{'regserver'};
- my $sql = "SELECT * FROM $known_server_tn WHERE hostname='$regserver'";
- my $res = $known_server_db->select_dbentry($sql);
- if (keys(%$res) > 0) {
- my $regserver_key = $res->{1}->{'hostkey'};
- $msg =~ s/