diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 2aa5404fbde4d0e12dad02f6fedff655ca172a42..d73b3c7630b1b65a00ccb0a060de25ce07bba640 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
$arp_activ, $gosa_unit_tag,
$GosaPackages_key, $gosa_ip, $gosa_port, $gosa_timeout,
$foreign_server_string, $server_domain, $ServerPackages_key, $foreign_servers_register_delay,
+ $wake_on_lan_passwd, $job_synchronization, $modified_jobs_loop_delay,
);
# additional variable which should be globaly accessable
our $cfg_file;
our ($ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $ldap_server_dn);
+# dak variables
+our $dak_base_directory;
+our $dak_signing_keys_directory;
+our $dak_queue_directory;
+our $dak_user;
# specifies the verbosity of the daemon_log
$verbose = 0 ;
"xmlmessage DEFAULT 'none'",
"macaddress DEFAULT 'none'",
"plainname DEFAULT 'none'",
+ "siserver DEFAULT 'none'",
+ "modified DEFAULT '0'",
);
# holds all other gosa-si-server
"ldap-admin-password" => [\$ldap_admin_password, ""],
"gosa-unit-tag" => [\$gosa_unit_tag, ""],
"max-clients" => [\$max_clients, 10],
+ "wol-password" => [\$wake_on_lan_passwd, ""],
},
"GOsaPackages" => {
"ip" => [\$gosa_ip, "0.0.0.0"],
"job-queue-loop-delay" => [\$job_queue_loop_delay, 3],
"messaging-db-loop-delay" => [\$messaging_db_loop_delay, 3],
"key" => [\$GosaPackages_key, "none"],
+ "dak-base" => [\$dak_base_directory, "/srv/archive"],
+ "dak-keyring" => [\$dak_signing_keys_directory, "/srv/archive/keyrings"],
+ "dak-queue" => [\$dak_queue_directory, "/srv/archive/queue"],
+ "dak-user" => [\$dak_user, "deb-dak"],
},
"ClientPackages" => {
"key" => [\$ClientPackages_key, "none"],
"domain" => [\$server_domain, ""],
"key" => [\$ServerPackages_key, "none"],
"key-lifetime" => [\$foreign_servers_register_delay, 120],
+ "job-synchronization-enabled" => [\$job_synchronization, "true"],
+ "synchronization-loop" => [\$modified_jobs_loop_delay, 5],
}
);
sub check_outgoing_xml_validity {
- my ($msg) = @_;
+ my ($msg, $session_id) = @_;
my $msg_hash;
eval{
}
};
if($@) {
- daemon_log("WARNING: outgoing msg is not gosa-si envelope conform", 5);
- daemon_log("$@ ".(defined($msg) && length($msg)>0)?$msg:"Empty Message", 8);
+ daemon_log("$session_id WARNING: outgoing msg is not gosa-si envelope conform: ", 5);
+ daemon_log("$@ ".(defined($msg) && length($msg)>0)?$msg:"Empty Message", 5);
$msg_hash = undef;
}
if ($source eq "GOSA") {
$msg =~ s/<\/xml>/<forward_to_gosa>$local_address,$session_id<\/forward_to_gosa><\/xml>/;
}
- print STDERR "target is own address without forward_to_gosa-tag -> process here\n";
+ #print STDERR "target is own address without forward_to_gosa-tag -> process here\n";
}
}
$done = 1;
my $hostname = $res->{1}->{'hostname'};
$msg =~ s/<target>$target<\/target>/<target>$hostname<\/target>/;
- print STDERR "target is a client address in known_clients -> process here\n";
+ #print STDERR "target is a client address in known_clients -> process here\n";
} else {
$not_found_in_known_clients_db = 1;
}
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";
+ #print STDERR "target is own address with forward_to_gosa-tag not pointing to myself -> process here\n";
}
}
}
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_/) {
+ if ($header =~ /^gosa_/ || $header =~ /^job_/) {
$module = "GosaPackages";
}
$heap->{'client'}->put($msg);
}
$done = 1;
- print STDERR "target is own address with forward_to_gosa-tag pointing at myself -> forward to gosa\n";
+ #print STDERR "target is own address with forward_to_gosa-tag pointing at myself -> forward to gosa\n";
}
}
$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 $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);
&send_msg_to_target($msg, $regserver, $regserver_key, $header, $session_id);
}
$done = 1;
- print STDERR "target is a client address in foreign_clients -> forward to registration server\n";
+ #print STDERR "target is a client address in foreign_clients -> forward to registration server\n";
} else {
$not_found_in_foreign_clients_db = 1;
}
&send_msg_to_target($msg, $target, $hostkey, $header, $session_id);
$done = 1;
- print STDERR "target is a server address -> forward to server\n";
+ #print STDERR "target is a server address -> forward to server\n";
} else {
$not_found_in_known_server_db = 1;
}
foreach my $answer ( @{$answer_l} ) {
# check outgoing msg to xml validity
- my $answer_hash = &check_outgoing_xml_validity($answer);
+ my $answer_hash = &check_outgoing_xml_validity($answer, $session_id);
if( not defined $answer_hash ) { next; }
$answer_header = @{$answer_hash->{'header'}}[0];
$kernel->yield('create_fai_release_db', $fai_release_tn );
$kernel->yield('watch_for_next_tasks');
$kernel->sig(USR1 => "sig_handler");
- $kernel->sig(USR2 => "create_packages_list_db");
+ $kernel->sig(USR2 => "recreate_packages_db");
$kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay);
$kernel->delay_set('watch_for_done_jobs', $job_queue_loop_delay);
+ $kernel->delay_set('watch_for_modified_jobs', $modified_jobs_loop_delay);
$kernel->delay_set('watch_for_new_messages', $messaging_db_loop_delay);
$kernel->delay_set('watch_for_delivery_messages', $messaging_db_loop_delay);
$kernel->delay_set('watch_for_done_messages', $messaging_db_loop_delay);
$kernel->delay_set('watch_for_old_known_clients', $job_queue_loop_delay);
+
}
sub watch_for_done_jobs {
my ($kernel,$heap) = @_[KERNEL, HEAP];
- my $sql_statement = "SELECT * FROM ".$job_queue_tn." WHERE status='done'";
+ my $sql_statement = "SELECT * FROM ".$job_queue_tn." WHERE ((status='done') AND (modified='0'))";
my $res = $job_db->select_dbentry( $sql_statement );
while( my ($id, $hit) = each %{$res} ) {
}
+# if a job got an update or was modified anyway, send to all other si-server an update message
+# of this jobs
+sub watch_for_modified_jobs {
+ my ($kernel,$heap) = @_[KERNEL, HEAP];
+
+ my $sql_statement = "SELECT * FROM $job_queue_tn WHERE ((siserver='localhost') AND (modified='1'))";
+ my $res = $job_db->select_dbentry( $sql_statement );
+
+ # if db contains no jobs which should be update, do nothing
+ if (keys %$res != 0) {
+
+ if ($job_synchronization eq "true") {
+ # make out of the db result a gosa-si message
+ my $update_msg = &db_res2si_msg ($res, "foreign_job_updates", "KNOWN_SERVER", "MY_LOCAL_ADDRESS");
+
+ # update all other SI-server
+ &inform_all_other_si_server($update_msg);
+ }
+
+ # set jobs all jobs to modified = 0, wait until the next modification for updates of other si-server
+ $sql_statement = "UPDATE $job_queue_tn SET modified='0' ";
+ $res = $job_db->update_dbentry($sql_statement);
+ }
+
+ $kernel->delay_set('watch_for_modified_jobs', $modified_jobs_loop_delay);
+}
+
+
sub watch_for_new_jobs {
if($watch_for_new_jobs_in_progress == 0) {
$watch_for_new_jobs_in_progress = 1;
my ($kernel,$heap) = @_[KERNEL, HEAP];
- # check gosa job queue for jobs with executable timestamp
+ # check gosa job quaeue for jobs with executable timestamp
my $timestamp = &get_time();
my $sql_statement = "SELECT * FROM $job_queue_tn WHERE status='waiting' AND (CAST (timestamp AS INTEGER)) < $timestamp ORDER BY timestamp";
my $res = $job_db->exec_statement( $sql_statement );
}
+
sub watch_for_new_messages {
my ($kernel,$heap) = @_[KERNEL, HEAP];
my @coll_user_msg; # collection list of outgoing messages
my $res = $incoming_db->exec_statement($sql);
}
- $kernel->delay_set('watch_for_next_tasks', 1);
+ $kernel->delay_set('watch_for_next_tasks', 0.1);
}
if ($session_id == 0) {
daemon_log("$session_id DEBUG: get_ldap_handle invoked without a session_id, create a new ldap_handle", 7);
$ldap_handle = Net::LDAP->new( $ldap_uri );
- $ldap_handle->bind($ldap_admin_dn, password => $ldap_admin_password);
+ $ldap_handle->bind($ldap_admin_dn, password => $ldap_admin_password) or daemon_log("$session_id ERROR: Bind to LDAP $ldap_uri as $ldap_admin_dn failed!");
} else {
my $session_reference = $global_kernel->ID_id_to_session($session_id);
# used handle is still valid - or if we've to reconnect...
#if (not exists $heap->{ldap_handle}) {
$ldap_handle = Net::LDAP->new( $ldap_uri );
- $ldap_handle->bind($ldap_admin_dn, password => $ldap_admin_password);
+ $ldap_handle->bind($ldap_admin_dn, password => $ldap_admin_password) or daemon_log("$session_id ERROR: Bind to LDAP $ldap_uri as $ldap_admin_dn failed!");
$heap->{ldap_handle} = $ldap_handle;
#}
}
}
}
} else {
- daemon_log("$session_id ERROR: LDAP search failed: ldap_base=$ldap_base, filter=$search", 1);
+ daemon_log("$session_id ERROR: LDAP search failed in function change_goto_state: ldap_base=$ldap_base, filter=$search", 1);
}
}
}
+sub run_recreate_packages_db {
+ my ($kernel, $session, $heap) = @_[KERNEL, SESSION, HEAP];
+ my $session_id = $session->ID;
+ &main::daemon_log("$session_id INFO: Recreating FAI Packages DB ('$fai_release_tn', '$fai_server_tn', '$packages_list_tn')", 4);
+ $kernel->yield('create_fai_release_db');
+ $kernel->yield('create_fai_server_db');
+ return;
+}
+
+
sub run_create_fai_server_db {
my ($kernel, $session, $heap, $table_name) = @_[KERNEL, SESSION, HEAP, ARG0];
my $session_id = $session->ID;
close( $PACKAGES );
unlink( "$path.in" );
- &main::daemon_log("$session_id DEBUG: unlink '$path.in'", 1);
}
@@ -2963,6 +3020,11 @@ daemon_log("0 INFO: found foreign server in config file and DNS: $all_foreign_se
# add all found foreign servers to known_server
my $act_timestamp = &get_time();
foreach my $foreign_server (@foreign_server_list) {
+
+ # do not add myself to known_server_db
+ if (&is_local($foreign_server)) { next; }
+ ######################################
+
my $res = $known_server_db->add_dbentry( {table=>$known_server_tn,
primkey=>['hostname'],
hostname=>$foreign_server,
watch_for_delivery_messages => \&watch_for_delivery_messages,
watch_for_done_messages => \&watch_for_done_messages,
watch_for_new_jobs => \&watch_for_new_jobs,
+ watch_for_modified_jobs => \&watch_for_modified_jobs,
watch_for_done_jobs => \&watch_for_done_jobs,
watch_for_old_known_clients => \&watch_for_old_known_clients,
create_packages_list_db => \&run_create_packages_list_db,
create_fai_server_db => \&run_create_fai_server_db,
create_fai_release_db => \&run_create_fai_release_db,
+ recreate_packages_db => \&run_recreate_packages_db,
session_run_result => \&session_run_result,
session_run_debug => \&session_run_debug,
session_run_done => \&session_run_done,