diff --git a/gosa-si/gosa-si-server b/gosa-si/gosa-si-server
index 018d67f4f61c61c45f6244680b1c66e58176cfbf..cb243deff3879981da39f477314cdf26463fae52 100755 (executable)
--- a/gosa-si/gosa-si-server
+++ b/gosa-si/gosa-si-server
# REVISION: ---
#===============================================================================
+
use strict;
use warnings;
use Getopt::Long;
my $modules_path = "/usr/lib/gosa-si/modules";
use lib "/usr/lib/gosa-si/modules";
+# TODO es gibt eine globale funktion get_ldap_handle
+# - ist in einer session dieses ldap handle schon vorhanden, wird es zurückgegeben
+# - ist es nicht vorhanden, wird es erzeugt, im heap für spätere ldap anfragen gespeichert und zurückgegeben
+# - sessions die kein ldap handle brauchen, sollen auch keins haben
+# - wird eine session geschlossen, muss das ldap verbindung vorher beendet werden
+our $global_kernel;
+
my (%cfg_defaults, $foreground, $verbose, $ping_timeout);
my ($bus_activ, $bus, $msg_to_bus, $bus_cipher);
my ($server);
my ($gosa_server, $job_queue_timeout, $job_queue_loop_delay);
+my ($messaging_db_loop_delay);
my ($known_modules);
my ($pid_file, $procid, $pid, $log_file);
my ($arp_activ, $arp_fifo);
our $verbose;
our $forground;
our $cfg_file;
-our ($ldap_handle, $ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $ldap_server_dn);
+#our ($ldap_handle, $ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $ldap_server_dn);
+our ($ldap_uri, $ldap_base, $ldap_admin_dn, $ldap_admin_password, $ldap_server_dn);
# specifies the verbosity of the daemon_log
"targettag DEFAULT 'none'",
"xmlmessage DEFAULT 'none'",
"macaddress DEFAULT 'none'",
+ "plainname DEFAULT 'none'",
);
# holds all other gosa-sd as well as the gosa-sd-bus
# holds all messages which should be delivered to a user
our $messaging_db;
our $messaging_tn = "messaging";
-our @messaging_col_names = ('subject', 'from', 'to', 'flag', 'direction', 'delivery_time', 'message', 'timestamp', 'id INTEGER', );
+our @messaging_col_names = ('subject', 'message_from', 'message_to', 'flag', 'direction', 'delivery_time', 'message', 'timestamp', 'id INTEGER' );
my $messaging_file_name;
# path to directory to store client install log files
"port" => [\$gosa_port, "20082"],
"job-queue" => [\$job_queue_file_name, '/var/lib/gosa-si/jobs.db'],
"job-queue-loop-delay" => [\$job_queue_loop_delay, 3],
+ "messaging-db-loop-delay" => [\$messaging_db_loop_delay, 3],
"key" => [\$GosaPackages_key, "none"],
},
"SIPackages" => {
#===============================================================================
sub read_configfile {
my $cfg;
- if( defined( $cfg_file) && ( length($cfg_file) > 0 )) {
+ if( defined( $cfg_file) && ( (-s $cfg_file) > 0 )) {
if( -r $cfg_file ) {
$cfg = Config::IniFiles->new( -file => $cfg_file );
} else {
sub sig_int_handler {
my ($signal) = @_;
- if(defined($ldap_handle)) {
- $ldap_handle->disconnect;
- }
+# if (defined($ldap_handle)) {
+# $ldap_handle->disconnect;
+# }
+ # TODO alle verbliebenden ldap verbindungen aus allen heaps beenden
+
daemon_log("shutting down gosa-si-server", 1);
- system("killall gosa-si-server");
+ system("kill `ps -C gosa-si-server -o pid=`");
}
$SIG{INT} = \&sig_int_handler;
sub _start {
my ($kernel) = $_[KERNEL];
&trigger_db_loop($kernel);
+ $global_kernel = $kernel;
$kernel->yield('create_fai_server_db', $fai_server_tn );
$kernel->yield('create_fai_release_db', $fai_release_tn );
$kernel->sig(USR1 => "sig_handler");
+ $kernel->sig(USR2 => "create_packages_list_db");
}
sub sig_handler {
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 INFO 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", 5);
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 } ) {
######################
# process incoming msg
if( $error == 0) {
- daemon_log("$session_id INFO: Incoming msg with header '".@{$msg_hash->{'header'}}[0]."'", 5);
+ daemon_log("$session_id INFO: Incoming msg 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);
sub trigger_db_loop {
my ($kernel) = @_ ;
$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_done_jobs', $job_queue_loop_delay);
+ $kernel->delay_set('watch_for_new_messages', $messaging_db_loop_delay);
+ $kernel->delay_set('watch_for_done_messages', $messaging_db_loop_delay);
}
sub watch_for_done_jobs {
my ($kernel,$heap) = @_[KERNEL, HEAP];
# check gosa job queue for jobs with executable timestamp
- my $timestamp = &get_time();
- my $sql_statement = "SELECT * FROM ".$job_queue_tn.
- " WHERE status='waiting' AND timestamp<'$timestamp'";
- my $res = $job_db->select_dbentry( $sql_statement );
+ my $timestamp = &get_time();
+ my $sql_statement = "SELECT * FROM $job_queue_tn WHERE status='waiting' AND (CAST (timestamp AS INTEGER) + 120) < $timestamp ORDER BY timestamp";
+ my $res = $job_db->exec_statement( $sql_statement );
+
+ # Merge all new jobs that would do the same actions
+ my @drops;
+ my $hits;
+ foreach my $hit (reverse @{$res} ) {
+ my $macaddress= lc @{$hit}[8];
+ my $headertag= @{$hit}[5];
+ if(defined($hits->{$macaddress}->{$headertag})) {
+ push @drops, "DELETE FROM $job_queue_tn WHERE id = '$hits->{$macaddress}->{$headertag}[0]'";
+ }
+ $hits->{$macaddress}->{$headertag}= $hit;
+ }
- while( my ($id, $hit) = each %{$res} ) {
- my $jobdb_id = $hit->{id};
- my $macaddress = $hit->{'macaddress'};
- my $job_msg = $hit->{'xmlmessage'};
- daemon_log("J DEBUG: its time to execute $job_msg", 7);
- my $sql_statement = "SELECT * FROM known_clients WHERE macaddress LIKE '$macaddress'";
- my $res_hash = $known_clients_db->select_dbentry( $sql_statement );
- # expect macaddress is unique!!!!!!
- my $target = $res_hash->{1}->{hostname};
-
-# if (not defined $target) {
-# &daemon_log("ERROR: no host found for mac address: $macaddress", 1);
-# &daemon_log("$hit->{xmlmessage}", 8);
-# my $sql_statement = "UPDATE $job_queue_tn ".
-# "SET status='error', result='no host found for mac address' ".
-# "WHERE id='$jobdb_id'";
-# my $res = $job_db->update_dbentry($sql_statement);
-# next;
-# }
-#
- # change header
- $job_msg =~ s/<header>job_/<header>gosa_/;
+ # Delete new jobs with a matching job in state 'processing'
+ foreach my $macaddress (keys %{$hits}) {
+ foreach my $jobdb_headertag (keys %{$hits->{$macaddress}}) {
+ my $jobdb_id = @{$hits->{$macaddress}->{$jobdb_headertag}}[0];
+ my $sql_statement = "SELECT * FROM $job_queue_tn WHERE macaddress LIKE '$macaddress' AND headertag='$jobdb_headertag' AND status='processing'";
+ my $res = $job_db->exec_statement( $sql_statement );
+ foreach my $hit (@{$res}) {
+ push @drops, "DELETE FROM $job_queue_tn WHERE id = '$jobdb_id'";
+ }
+ }
+ }
- # add sqlite_id
- $job_msg =~ s/<\/xml>$/<jobdb_id>$jobdb_id<\/jobdb_id><\/xml>/;
+ # Commit deletion
+ $job_db->exec_statementlist(\@drops);
- $job_msg =~ /<header>(\S+)<\/header>/;
- my $header = $1 ;
- my $func_error = &send_msg_to_target($job_msg, $server_address, $GosaPackages_key, $header, "J");
+ # Look for new jobs that could be executed
+ foreach my $macaddress (keys %{$hits}) {
- # update status in job queue to 'processing'
- $sql_statement = "UPDATE $job_queue_tn SET status='processing' WHERE id='$jobdb_id'";
- my $res = $job_db->update_dbentry($sql_statement);
- }
+ # Look if there is an executing job
+ my $sql_statement = "SELECT * FROM $job_queue_tn WHERE macaddress LIKE '$macaddress' AND status='processing'";
+ my $res = $job_db->exec_statement( $sql_statement );
+
+ # Skip new jobs for host if there is a processing job
+ if(defined($res) and defined @{$res}[0]) {
+ next;
+ }
+
+ foreach my $jobdb_headertag (keys %{$hits->{$macaddress}}) {
+ my $jobdb_id = @{$hits->{$macaddress}->{$jobdb_headertag}}[0];
+ my $job_msg = @{$hits->{$macaddress}->{$jobdb_headertag}}[7];
+
+ daemon_log("J DEBUG: its time to execute $job_msg", 7);
+ my $sql_statement = "SELECT * FROM known_clients WHERE macaddress LIKE '$macaddress'";
+ my $res_hash = $known_clients_db->select_dbentry( $sql_statement );
+
+ # expect macaddress is unique!!!!!!
+ my $target = $res_hash->{1}->{hostname};
+
+ # change header
+ $job_msg =~ s/<header>job_/<header>gosa_/;
+
+ # add sqlite_id
+ $job_msg =~ s/<\/xml>$/<jobdb_id>$jobdb_id<\/jobdb_id><\/xml>/;
+
+ $job_msg =~ /<header>(\S+)<\/header>/;
+ my $header = $1 ;
+ my $func_error = &send_msg_to_target($job_msg, $server_address, $GosaPackages_key, $header, "J");
+
+ # update status in job queue to 'processing'
+ $sql_statement = "UPDATE $job_queue_tn SET status='processing' WHERE id='$jobdb_id'";
+ my $res = $job_db->update_dbentry($sql_statement);
+
+ # We don't want parallel processing
+ last;
+ }
+ }
$kernel->delay_set('watch_for_new_jobs', $job_queue_loop_delay);
}
-sub refresh_ldap_handle {
- my $mesg;
+sub watch_for_new_messages {
+ my ($kernel,$heap) = @_[KERNEL, HEAP];
+ my @coll_user_msg; # collection list of outgoing messages
+
+ # check messaging_db for new incoming messages with executable timestamp
+ my $timestamp = &get_time();
+ #my $sql_statement = "SELECT * FROM $messaging_tn WHERE (CAST (delivery_time AS INTEGER) + 120) < $timestamp";
+ my $sql_statement = "SELECT * FROM $messaging_tn WHERE ( (CAST(timestamp AS INTEGER))<$timestamp AND flag='n' AND direction='in' )";
+ my $res = $messaging_db->exec_statement( $sql_statement );
+
+ foreach my $hit (@{$res}) {
+
+ # create outgoing messages
+ my $message_to = @{$hit}[2];
+
+ # translate message_to to plain login name
+ my @reciever_l = ($message_to);
+ my $message_id = @{$hit}[8];
+
+ #add each outgoing msg to messaging_db
+ my $reciever;
+ foreach $reciever (@reciever_l) {
+ my $sql_statement = "INSERT INTO $messaging_tn (subject, message_from, message_to, flag, direction, delivery_time, message, timestamp, id) ".
+ "VALUES ('".
+ @{$hit}[0]."', '". # subject
+ @{$hit}[1]."', '". # message_from
+ $reciever."', '". # message_to
+ "none"."', '". # flag
+ "out"."', '". # direction
+ @{$hit}[5]."', '". # delivery_time
+ @{$hit}[6]."', '". # message
+ $timestamp."', '". # timestamp
+ @{$hit}[8]. # id
+ "')";
+ &daemon_log("M DEBUG: $sql_statement", 1);
+ my $res = $messaging_db->exec_statement($sql_statement);
+ &daemon_log("M INFO: message '".@{$hit}[8]."' is prepared for delivery to reciever '$reciever'", 5);
+ }
- daemon_log("DEBUG: Trying to create a connection to URI $ldap_uri", 5);
- # Get an ldap handle, if we don't have one
- if( ! defined $ldap_handle ){
- $ldap_handle = Net::LDAP->new( $ldap_uri );
- }
- # Still not defined?
- if( ! defined $ldap_handle ) {
- daemon_log( "ch $$: Net::LDAP constructor failed: $!\n" );
- return 0;
- }
+ # send outgoing messages
+ my $sql_statement = "SELECT * FROM $messaging_tn WHERE ( flag='p' AND direction='out' )";
+ my $res = $messaging_db->exec_statement( $sql_statement );
+ foreach my $hit (@{$res}) {
+ # add subject, from, to and message to list coll_user_msg
+ my @user_msg = [@{$hit}[0], @{$hit}[1], $reciever, @{$hit}[6]];
+ push( @coll_user_msg, \@user_msg);
+ }
+
+ # send outgoing list to myself (gosa-si-server) to deliver each message to user
+ # reason for this workaround: if to much messages have to be delivered, it can come to
+ # denial of service problems of the server. so, the incoming message list can be processed
+ # by a forked child and gosa-si-server is always ready to work.
+ my $collection_out_msg = &create_xml_hash("collection_user_messages", $server_address, $server_address);
+ # add to hash 'msg1' => [subject, from, to, message]
+ # hash to string
+ # send msg to myself
+# TODO
+
+ # set incoming message to flag d=deliverd
+ $sql_statement = "UPDATE $messaging_tn SET flag='p' WHERE id='$message_id'";
+ &daemon_log("M DEBUG: $sql_statement", 7);
+ $res = $messaging_db->update_dbentry($sql_statement);
+ &daemon_log("M INFO: message '".@{$hit}[8]."' is set to flag 'p' (processed)", 5);
- # Bind to ldap server - eventually authenticate
- if( defined $ldap_admin_dn ) {
- if( defined $ldap_admin_password ) {
- $mesg = $ldap_handle->bind( $ldap_admin_dn, password => $ldap_admin_password );
- } else {
- $mesg = $ldap_handle->bind( $ldap_admin_dn );
}
- } else {
- $mesg = $ldap_handle->bind();
- }
+
+ $kernel->delay_set('watch_for_new_messages', $messaging_db_loop_delay);
- if( 0 != $mesg->code ) {
- undef( $ldap_handle ) if( 81 == $mesg->code );
- daemon_log( "ch $$: LDAP bind: error (". $mesg->code . ') - ' . $mesg->error . "\n", 1);
- return 0;
- }
- return 1;
+ return;
+}
+
+
+sub watch_for_done_messages {
+ my ($kernel,$heap) = @_[KERNEL, HEAP];
+
+ $kernel->delay_set('watch_for_done_messages', $messaging_db_loop_delay);
+ return;
+}
+
+
+sub get_ldap_handle {
+ my ($session_id) = @_;
+ my $heap;
+ my $ldap_handle;
+
+ if (not defined $session_id ) { $session_id = 0 };
+
+ 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);
+
+ } else {
+ my $session_reference = $global_kernel->ID_id_to_session($session_id);
+ if( defined $session_reference ) {
+ $heap = $session_reference->get_heap();
+ }
+
+ if (not defined $heap) {
+ daemon_log("$session_id DEBUG: cannot get heap for session_id '$session_id'", 7);
+ return;
+ }
+
+ # TODO: This "if" is nonsense, because it doesn't prove that the
+ # 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);
+ $heap->{ldap_handle} = $ldap_handle;
+ #}
+ }
+ return $ldap_handle;
}
wake => '',
memcheck => 'memcheck',
sysinfo => 'sysinfo',
+ install => 'install',
);
# Return if this is unknown
my $state= $mapActions{ $st };
- &refresh_ldap_handle();
+ my $ldap_handle = &get_ldap_handle($session_id);
if( defined($ldap_handle) ) {
# Build search filter for hosts
filter => "$search"
);
- if ($mesg->count) {
- my @entries = $mesg->entries;
- foreach my $entry (@entries) {
- # Only modify entry if it is not set to '$state'
- if ($entry->get_value("FAIstate") ne "$state"){
- daemon_log("$session_id INFO: Setting FAIstate to '$state' for ".$entry->dn, 5);
- my $result;
- my %tmp = map { $_ => 1 } $entry->get_value("objectClass");
- if (exists $tmp{'FAIobject'}){
- if ($state eq ''){
- $result= $ldap_handle->modify($entry->dn, changes => [
- delete => [ FAIstate => [] ] ]);
- } else {
- $result= $ldap_handle->modify($entry->dn, changes => [
- replace => [ FAIstate => $state ] ]);
- }
- } elsif ($state ne ''){
- $result= $ldap_handle->modify($entry->dn, changes => [
- add => [ objectClass => 'FAIobject' ],
- add => [ FAIstate => $state ] ]);
- }
-
- # Errors?
- if ($result->code){
- daemon_log("$session_id Error: Setting FAIstate to '$state' for ".$entry->dn. "failed: ".$result->error, 1);
- }
-
- } else {
- daemon_log("$session_id DEBUG FAIstate at host found with filter statement '$search' already at state '$st'", 7);
- }
- }
- }
+ if ($mesg->count) {
+ my @entries = $mesg->entries;
+ foreach my $entry (@entries) {
+ # Only modify entry if it is not set to '$state'
+ if ($entry->get_value("FAIstate") ne "$state"){
+ daemon_log("$session_id INFO: Setting FAIstate to '$state' for ".$entry->dn, 5);
+ my $result;
+ my %tmp = map { $_ => 1 } $entry->get_value("objectClass");
+ if (exists $tmp{'FAIobject'}){
+ if ($state eq ''){
+ $result= $ldap_handle->modify($entry->dn, changes => [
+ delete => [ FAIstate => [] ] ]);
+ } else {
+ $result= $ldap_handle->modify($entry->dn, changes => [
+ replace => [ FAIstate => $state ] ]);
+ }
+ } elsif ($state ne ''){
+ $result= $ldap_handle->modify($entry->dn, changes => [
+ add => [ objectClass => 'FAIobject' ],
+ add => [ FAIstate => $state ] ]);
+ }
+
+ # Errors?
+ if ($result->code){
+ daemon_log("$session_id Error: Setting FAIstate to '$state' for ".$entry->dn. "failed: ".$result->error, 1);
+ }
+ } else {
+ daemon_log("$session_id DEBUG FAIstate at host '".$entry->dn."' already at state '$st'", 7);
+ }
+ }
+ }
# if no ldap handle defined
} else {
daemon_log("$session_id ERROR: no LDAP handle defined for update FAIstate", 1);
}
+
}
# Switch on or off?
my $state= $st eq 'active' ? 'active': 'locked';
- &refresh_ldap_handle();
+ my $ldap_handle = &get_ldap_handle($session_id);
if( defined($ldap_handle) ) {
# Build search filter for hosts
sub create_fai_server_db {
my ($table_name, $kernel) = @_;
my $result;
-
+ my $ldap_handle = &get_ldap_handle();
if(defined($ldap_handle)) {
daemon_log("INFO: create_fai_server_db: start", 5);
my $mesg= $ldap_handle->search(
daemon_log("INFO: create_fai_server_db: finished", 5);
# TODO: Find a way to post the 'create_packages_list_db' event
- &create_packages_list_db();
+ &create_packages_list_db($ldap_handle);
}
-
+
+ $ldap_handle->disconnect;
return $result;
}
my ($table_name) = @_;
my $result;
+ my $ldap_handle = &get_ldap_handle();
if(defined($ldap_handle)) {
daemon_log("INFO: create_fai_release_db: start",5);
my $mesg= $ldap_handle->search(
my @sql_list;
my $timestamp= &get_time();
foreach my $ou (@{$mesg->{entries}}) {
- my $tmp_classes= resolve_fai_classes($ou->dn);
+ my $tmp_classes= resolve_fai_classes($ou->dn, $ldap_handle);
if(defined($tmp_classes) && ref($tmp_classes) eq 'HASH') {
my @tmp_array=get_fai_release_entries($tmp_classes);
if(@tmp_array) {
}
daemon_log("INFO: create_fai_release_db: finished",5);
}
-
+ $ldap_handle->disconnect;
return $result;
}
sub run_create_fai_release_db {
}
sub resolve_fai_classes {
+ my ($fai_base, $ldap_handle) = @_;
my $result;
- my $fai_base= shift;
my @possible_fai_classes= ("FAIscript", "FAIhook", "FAIpartitionTable", "FAItemplate", "FAIvariable", "FAIprofile", "FAIpackageList");
my $fai_filter= "(|(&(objectClass=FAIclass)(|(objectClass=".join(")(objectClass=", @possible_fai_classes).")))(objectClass=FAIbranch))";
my $fai_classes;
}
sub create_sources_list {
+ my ($ldap_handle) = @_;
my $result="/tmp/gosa_si_tmp_sources_list";
# Remove old file
);
if($mesg->count) {
foreach my $entry(@{$mesg->{'entries'}}) {
- my ($server, $tag, $release, $sections)= split /\|/, $entry->get_value('FAIrepository');
- my $line = "deb $server $release";
- $sections =~ s/,/ /g;
- $line.= " $sections";
- print $fh $line."\n";
+ foreach my $value(@{$entry->get_value('FAIrepository', asref => 1)}) {
+ my ($server, $tag, $release, $sections)= split /\|/, $value;
+ my $line = "deb $server $release";
+ $sections =~ s/,/ /g;
+ $line.= " $sections";
+ print $fh $line."\n";
+ }
}
}
}
}
sub create_packages_list_db {
- my ($sources_file) = @_ || &create_sources_list;
+ my ($ldap_handle, $sources_file) = @_ ;
+
+ if (not defined $ldap_handle) {
+ $ldap_handle= &get_ldap_handle();
+
+ if (not defined $ldap_handle) {
+ daemon_log("0 ERROR: no ldap_handle available to create_packages_list_db", 1);
+ return;
+ }
+ }
+
+ if (not defined $sources_file) {
+ $sources_file = &create_sources_list($ldap_handle);
+ }
+
my $line;
daemon_log("INFO: create_packages_list_db: start", 5);
# This is ugly, but I've no time to take a look at "how it works in perl"
if(0 == system("wget '$url' -O '$dest' 2>/dev/null") ) {
system("gunzip -cd '$dest' > '$dest.in'");
- system("rm -f '$dest'");
+ unlink($dest);
} else {
daemon_log("ERROR: create_packages_list_db: get_packages: fetching '$url' failed!", 1);
}
}
sub cleanup_and_extract {
-
- my %templates = ();
my $fileinfo = $repo_files{ $File::Find::name };
if( defined $fileinfo ) {
- print STDERR "============> $File::Find::name\n";
my $dir = "$outdir/$fileinfo->{ 'dist' }/debconf.d";
- system( "mkdir -p '$dir'" );
+ my $sql;
+ my $package = $fileinfo->{ 'package' };
+ my $newver = $fileinfo->{ 'version' };
+ mkpath($dir);
system( "dpkg -e '$File::Find::name' '$dir/DEBIAN'" );
+
if( -f "$dir/DEBIAN/templates" ) {
- my $package = $fileinfo->{ 'package' };
- my $newver = $fileinfo->{ 'version' };
daemon_log("DEBUG: Found debconf templates in '$package' - $newver", 5);
- if( exists $templates{ "$fileinfo->{ 'dist' }/$package" } ) {
- my $oldver = $templates{ "$fileinfo->{ 'dist' }/$package" };
- my $ret = system( "dpkg --compare-versions '$oldver' gt '$newver'" );
- if( ! $ret ) {
- daemon_log("DEBUG: duplicated '$package' ($newver) in $fileinfo->{ 'dist' } - keeping tmpl v'$oldver'", 5);
- return;
- }
- else {
- daemon_log("DEBUG: duplicated '$package' ($newver) in $fileinfo->{ 'dist' } - overwriting tmpl v'$oldver'", 5);
- }
+
+ my $tmpl= "";
+ {
+ local $/=undef;
+ open FILE, "$dir/DEBIAN/templates";
+ $tmpl = &encode_base64(<FILE>);
+ close FILE;
}
- $templates{ "$fileinfo->{ 'dist' }/$package" } = $newver;
- move( "$dir/DEBIAN/templates", "$dir/$package.templates" );
+ rmtree("$dir/DEBIAN/templates");
+
+ $sql= "update $main::packages_list_tn set template = '$tmpl' where package = '$package' and version = '$newver';";
+
+ } else {
+ $sql= "update $main::packages_list_tn set template = '' where package = '$package' and version = '$newver';";
}
+
+ my $res= $main::packages_list_db->update_dbentry($sql);
}
}
$bus_activ = "false"
}
-
-
-# delete old DBsqlite lock files
-#unlink('/tmp/gosa_si_lock*');
-
# connect to gosa-si job queue
$job_db = GOSA::DBsqlite->new($job_queue_file_name);
$job_db->create_table($job_queue_tn, \@job_queue_col_names);
$login_users_db->create_table($login_users_tn, \@login_users_col_names);
# connect to fai_server_db and fai_release_db
+unlink($fai_server_file_name);
$fai_server_db = GOSA::DBsqlite->new($fai_server_file_name);
$fai_server_db->create_table($fai_server_tn, \@fai_server_col_names);
$fai_server_db->create_table($fai_release_tn, \@fai_release_col_names);
inline_states => {
_start => \&_start,
sig_handler => \&sig_handler,
+ watch_for_new_messages => \&watch_for_new_messages,
+ watch_for_done_messages => \&watch_for_done_messages,
watch_for_new_jobs => \&watch_for_new_jobs,
watch_for_done_jobs => \&watch_for_done_jobs,
create_packages_list_db => \&run_create_packages_list_db,