Code

Merged changeset:13419 from gosa-lhm.
authorjanw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 20 Feb 2009 15:50:17 +0000 (15:50 +0000)
committerjanw <janw@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 20 Feb 2009 15:50:17 +0000 (15:50 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13435 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/gosa-si-server
gosa-si/modules/ClientPackages.pm

index 29542324b1d5628adf6d59b2808c51224e534ca5..514e8b1bde1f54442d4e053c6c7d3d9025959613 100755 (executable)
@@ -1573,19 +1573,19 @@ sub session_start {
 
 
 sub watch_for_done_jobs {
-    #CHECK: $heap for what?
-    my ($kernel,$heap) = @_[KERNEL, HEAP];
+       #CHECK: $heap for what?
+       my ($kernel,$heap) = @_[KERNEL, HEAP];
 
-    my $sql_statement = "SELECT * FROM ".$job_queue_tn." WHERE ((status='done') AND (modified='0'))";
+       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} ) {
-        my $jobdb_id = $hit->{id};
-        my $sql_statement = "DELETE FROM $job_queue_tn WHERE id=$jobdb_id"; 
-        my $res = $job_db->del_dbentry($sql_statement);        
-    }
+       while( my ($id, $hit) = each %{$res} ) {
+               my $jobdb_id = $hit->{id};
+               my $sql_statement = "DELETE FROM $job_queue_tn WHERE id=$jobdb_id"; 
+               my $res = $job_db->del_dbentry($sql_statement); 
+       }
 
-    $kernel->delay_set('watch_for_done_jobs',$job_queue_loop_delay);
+       $kernel->delay_set('watch_for_done_jobs',$job_queue_loop_delay);
 }
 
 
@@ -2405,8 +2405,10 @@ sub create_fai_release_db {
                        attrs  => [],
                        filter => "(&(objectClass=organizationalUnit)(ou=fai))",
                );
-               if($mesg->{'resultCode'} == 0 &&
-                       $mesg->count != 0) {
+               if(($mesg->code == 0) && ($mesg->count != 0))
+               {
+                       daemon_log("$session_id DEBUG: create_fai_release_db: count " . $mesg->count,8);
+
                        # Walk through all possible FAI container ou's
                        my @sql_list;
                        my $timestamp= &get_time();
@@ -2432,12 +2434,15 @@ sub create_fai_release_db {
                                }
                        }
 
-                       daemon_log("$session_id DEBUG: Inserting ".scalar @sql_list." entries to DB",8);
+                       daemon_log("$session_id DEBUG: create_fai_release_db: Inserting ".scalar @sql_list." entries to DB",8);
                        if(@sql_list) {
+                               unshift @sql_list, "VACUUM";
                                unshift @sql_list, "DELETE FROM $table_name";
                                $fai_release_db->exec_statementlist(\@sql_list);
                        }
-                       daemon_log("$session_id DEBUG: Done with inserting",7);
+                       daemon_log("$session_id DEBUG: create_fai_release_db: Done with inserting",7);
+               } else {
+                       daemon_log("$session_id INFO: create_fai_release_db: error: " . $mesg->code, 5);
                }
                daemon_log("$session_id INFO: create_fai_release_db: finished",5);
        }
@@ -2500,9 +2505,11 @@ sub resolve_fai_classes {
                foreach my $entry (@{$mesg->{entries}}) {
                        if($entry->exists('cn')) {
                                my $tmp_dn= $entry->dn();
+                               $tmp_dn= substr( $tmp_dn, 0, length($tmp_dn)
+                                       - length($fai_base) - 1 );
 
                                # Skip classname and ou dn parts for class
-                               my $tmp_release = ($1) if $tmp_dn =~ /^[^,]+,[^,]+,(.*?),$fai_base$/;
+                               my $tmp_release = ($1) if $tmp_dn =~ /^[^,]+,[^,]+,(.*?)$/;
 
                                # Skip classes without releases
                                if((!defined($tmp_release)) || length($tmp_release)==0) {
@@ -2537,7 +2544,9 @@ sub resolve_fai_classes {
                                }
                        } elsif (!$entry->exists('cn')) {
                                my $tmp_dn= $entry->dn();
-                               my $tmp_release = ($1) if $tmp_dn =~ /^(.*?),$fai_base$/;
+                               $tmp_dn= substr( $tmp_dn, 0, length($tmp_dn)
+                                       - length($fai_base) - 1 );
+                               my $tmp_release = ($1) if $tmp_dn =~ /^(.*?)$/;
 
                                # Skip classes without releases
                                if((!defined($tmp_release)) || length($tmp_release)==0) {
@@ -2960,6 +2969,8 @@ sub strip_packages_list_statements {
                }
        }
 
+       unshift(@new_statement_list, "VACUUM");
+
        @packages_list_statements = @new_statement_list;
 }
 
@@ -2994,7 +3005,7 @@ sub get_package {
         unlink($dest);
         daemon_log("$session_id DEBUG: delete file '$dest'", 5); 
     } else {
-        daemon_log("$session_id ERROR: create_packages_list_db: get_packages: fetching '$url' failed!", 1);
+        daemon_log("$session_id ERROR: create_packages_list_db: get_packages: fetching '$url' into '$dest' failed!", 1);
     }
     return 0;
 }
index b21fb33032e32616c13cdb62aed9c4726032ca73..99bb3506909d66fbcae153ea52daeb6efc0b0bce 100644 (file)
@@ -628,7 +628,7 @@ sub new_syslog_config {
        }
 
        my $entry= $ldap_res->entry(0);
-    my $dn = &Net::LDAP::Util::escape_dn_value($entry->dn);
+    my $filter_dn = &Net::LDAP::Util::escape_filter_value($entry->dn);
        my $syslog_server = $entry->get_value("gotoSyslogServer");
 
     # If no syslog server is specified at host, just have a look at the object group of the host
@@ -637,7 +637,7 @@ sub new_syslog_config {
         my $ldap_res = $ldap_handle->search( base   => $ldap_base,
                 scope  => 'sub',
                 attrs => ['gotoSyslogServer'],
-                filter => "(&(objectClass=gosaGroupOfNames)(member=$dn))");
+                filter => "(&(objectClass=gosaGroupOfNames)(member=$filter_dn))");
         if($ldap_res->code) {
             &main::daemon_log("$session_id ".$ldap_res->error, 1);
             return;
@@ -649,7 +649,7 @@ sub new_syslog_config {
                     "\n\tbase: $ldap_base".
                     "\n\tscope: sub".
                     "\n\tattrs: gotoSyslogServer".
-                    "\n\tfilter: (&(objectClass=gosaGroupOfNames)(member=$dn))", 1);
+                    "\n\tfilter: (&(objectClass=gosaGroupOfNames)(member=$filter_dn))", 1);
             return;
         }
 
@@ -662,6 +662,7 @@ sub new_syslog_config {
         &main::daemon_log("$session_id WARNING: no syslog server specified for this host '$mac_address'", 3);
         return;
     }
+
  
     # Add syslog server to 'syslog_config' message
     my $syslog_msg_hash = &create_xml_hash("new_syslog_config", $server_address, $mac_address);
@@ -703,7 +704,7 @@ sub new_ntp_config {
        }
 
        my $entry= $ldap_res->entry(0);
-    my $dn = &Net::LDAP::Util::escape_dn_value($entry->dn);
+    my $filter_dn = &Net::LDAP::Util::escape_filter_value($entry->dn);
        my @ntp_servers= $entry->get_value("gotoNtpServer");
 
     # If no ntp server is specified at host, just have a look at the object group of the host
@@ -712,7 +713,7 @@ sub new_ntp_config {
         my $ldap_res = $ldap_handle->search( base   => $ldap_base,
                 scope  => 'sub',
                 attrs => ['gotoNtpServer'],
-                filter => "(&(objectClass=gosaGroupOfNames)(member=$dn))");
+                filter => "(&(objectClass=gosaGroupOfNames)(member=$filter_dn))");
         if($ldap_res->code) {
             &main::daemon_log("$session_id ".$ldap_res->error, 1);
             return;
@@ -724,7 +725,7 @@ sub new_ntp_config {
                     "\n\tbase: $ldap_base".
                     "\n\tscope: sub".
                     "\n\tattrs: gotoNtpServer".
-                    "\n\tfilter: (&(objectClass=gosaGroupOfNames)(member=$dn))", 1);
+                    "\n\tfilter: (&(objectClass=gosaGroupOfNames)(member=$filter_dn))", 1);
             return;
         }
 
@@ -803,13 +804,14 @@ sub new_ldap_config {
        }
 
        my $entry= $mesg->entry(0);
-       my $dn= $entry->dn;
+       my $filter_dn= &Net::LDAP::Util::escape_filter_value($entry->dn);
        my @servers= $entry->get_value("gotoLdapServer");
        my $unit_tag= $entry->get_value("gosaUnitTag");
        my @ldap_uris;
        my $server;
        my $base;
        my $release;
+    my $dn= $entry->dn;
 
        # Fill release if available
        my $FAIclass= $entry->get_value("FAIclass");
@@ -819,13 +821,12 @@ sub new_ldap_config {
 
        # Do we need to look at an object class?
        if (not @servers){
-          my $escaped_dn = &Net::LDAP::Util::escape_dn_value($dn);
                $mesg = $ldap_handle->search( base   => $ldap_base,
                        scope  => 'sub',
                        attrs => ['dn', 'gotoLdapServer', 'FAIclass'],
-                       filter => "(&(objectClass=gosaGroupOfNames)(member=$escaped_dn))");
+                       filter => "(&(objectClass=gosaGroupOfNames)(member=$filter_dn))");
                if($mesg->code) {
-                       &main::daemon_log("$session_id ERROR: unable to search for '(&(objectClass=gosaGroupOfNames)(member=$dn))': ".$mesg->error, 1);
+                       &main::daemon_log("$session_id ERROR: unable to search for '(&(objectClass=gosaGroupOfNames)(member=$filter_dn))': ".$mesg->error, 1);
                        return;
                }
 
@@ -835,7 +836,7 @@ sub new_ldap_config {
                     "\n\tbase: $ldap_base".
                     "\n\tscope: sub".
                     "\n\tattrs: dn, gotoLdapServer, FAIclass".
-                    "\n\tfilter: (&(objectClass=gosaGroupOfNames)(member=$escaped_dn))", 1);
+                    "\n\tfilter: (&(objectClass=gosaGroupOfNames)(member=$filter_dn))", 1);
             return;
         }
 
@@ -987,7 +988,6 @@ sub hardware_config {
        
        } else {
                my $entry= $mesg->entry(0);
-               my $dn= $entry->dn;
                if (defined($entry->get_value("gotoHardwareChecksum"))) {
                        if (! $entry->get_value("gotoHardwareChecksum") eq $gotoHardwareChecksum) {
                                $entry->replace(gotoHardwareChecksum => $gotoHardwareChecksum);