diff --git a/gosa-si/server/events/server_server_com.pm b/gosa-si/server/events/server_server_com.pm
index bc1027c8bbd340f96a2e9e33e090bde1db763fd0..68aa78702ed2efa57a751c38b65874034b0ace14 100644 (file)
my @events = (
'new_server',
'confirm_new_server',
my @events = (
'new_server',
'confirm_new_server',
+ 'new_foreign_client',
);
@EXPORT = @events;
);
@EXPORT = @events;
my $source = @{$msg_hash->{'source'}}[0];
my $target = @{$msg_hash->{'target'}}[0];
my $key = @{$msg_hash->{'key'}}[0];
my $source = @{$msg_hash->{'source'}}[0];
my $target = @{$msg_hash->{'target'}}[0];
my $key = @{$msg_hash->{'key'}}[0];
- my @clients = @{$msg_hash->{'client'}};
+ my @clients = exists $msg_hash->{'client'} ? @{$msg_hash->{'client'}} : qw();
# sanity check
if (ref $key eq 'HASH') {
# sanity check
if (ref $key eq 'HASH') {
my $func_dic = {table=>$main::known_server_tn,
primkey=>['hostname'],
hostname => $source,
my $func_dic = {table=>$main::known_server_tn,
primkey=>['hostname'],
hostname => $source,
+ status => "new_server",
hostkey => $key,
timestamp=>&get_time(),
};
hostkey => $key,
timestamp=>&get_time(),
};
&main::daemon_log("$session_id INFO: server_server_com.pm: server '$source' successfully added to known_server_db", 5);
}
&main::daemon_log("$session_id INFO: server_server_com.pm: server '$source' successfully added to known_server_db", 5);
}
+ # delete all entries at foreign_clients_db coresponding to this server
+ my $del_sql = "DELETE FROM $main::foreign_clients_tn WHERE regserver='$source' ";
+ my $del_res = $main::foreign_clients_db->exec_statement($del_sql);
+
# add clients of foreign server to known_foreign_clients_db
my @sql_list;
foreach my $client (@clients) {
my @client_details = split(/,/, $client);
# workaround to avoid double entries in foreign_clients_db
# add clients of foreign server to known_foreign_clients_db
my @sql_list;
foreach my $client (@clients) {
my @client_details = split(/,/, $client);
# workaround to avoid double entries in foreign_clients_db
- my $del_sql = "DELTE FROM $main::foreign_clients_tn WHERE hostname='".$client_details[0]."'";
+ my $del_sql = "DELETE FROM $main::foreign_clients_tn WHERE hostname='".$client_details[0]."'";
push(@sql_list, $del_sql);
my $sql = "INSERT INTO $main::foreign_clients_tn VALUES ("
push(@sql_list, $del_sql);
my $sql = "INSERT INTO $main::foreign_clients_tn VALUES ("
push(@sql_list, $sql);
}
if (@sql_list) {
push(@sql_list, $sql);
}
if (@sql_list) {
- &main::daemon_log("$session_id DEBUG: Inserting ".scalar @sql_list." entries to foreign_clients_db", 8);
+ my $len = @sql_list;
+ $len /= 2;
+ &main::daemon_log("$session_id DEBUG: Inserting ".$len." entries to foreign_clients_db", 8);
my $res = $main::foreign_clients_db->exec_statementlist(\@sql_list);
}
my $res = $main::foreign_clients_db->exec_statementlist(\@sql_list);
}
my $out_msg = &build_msg('confirm_new_server', $main::server_address, $source, \%data);
my $error = &main::send_msg_to_target($out_msg, $source, $main::ServerPackages_key, 'confirm_new_server', $session_id);
my $out_msg = &build_msg('confirm_new_server', $main::server_address, $source, \%data);
my $error = &main::send_msg_to_target($out_msg, $source, $main::ServerPackages_key, 'confirm_new_server', $session_id);
-
+ return;
}
}
my $sql = "UPDATE $main::known_server_tn SET status='$header', hostkey='$key' WHERE hostname='$source'";
my $res = $main::known_server_db->update_dbentry($sql);
my $sql = "UPDATE $main::known_server_tn SET status='$header', hostkey='$key' WHERE hostname='$source'";
my $res = $main::known_server_db->update_dbentry($sql);
+ return;
+}
+
+sub new_foreign_client {
+ my ($msg, $msg_hash, $session_id) = @_ ;
+ my $header = @{$msg_hash->{'header'}}[0];
+ my $source = @{$msg_hash->{'source'}}[0];
+ my $hostname = @{$msg_hash->{'client'}}[0];
+ my $macaddress = @{$msg_hash->{'macaddress'}}[0];
+
+ my $func_dic = { table => $main::foreign_clients_tn,
+ primkey => ['hostname'],
+ hostname => $hostname,
+ macaddress => $macaddress,
+ regserver => $source,
+ timestamp => &get_time(),
+ };
+ my $res = $main::foreign_clients_db->add_dbentry($func_dic);
+ if (not $res == 0) {
+ &main::daemon_log("$session_id ERROR: server_server_com.pm: cannot add server to foreign_clients_db: $res", 1);
+ } else {
+ &main::daemon_log("$session_id INFO: server_server_com.pm: client '$hostname' successfully added to foreign_clients_db", 5);
+ }
+
+ return;
}
}
+
1;
1;