Code

Add next to the right scope.
[gosa.git] / gosa-si / gosa-si-server
index 8bc1100fd8952f69ad42795e76a594fea4ae8587..99e02fdb491627812c2f21e8471a5d669134226b 100755 (executable)
@@ -87,6 +87,7 @@ our (%cfg_defaults, $log_file, $pid_file,
     $wake_on_lan_passwd, $job_synchronization, $modified_jobs_loop_delay,
     $arp_enabled, $arp_interface,
     $opsi_enabled, $opsi_server, $opsi_admin, $opsi_password,
+               $new_systems_ou,
 );
 
 # additional variable which should be globaly accessable
@@ -247,6 +248,7 @@ our $logged_in_user_date_of_expiry = 600;
     "job-queue-loop-delay" => [\$job_queue_loop_delay, 3],
     "messaging-db-loop-delay" => [\$messaging_db_loop_delay, 3],
     "key" => [\$GosaPackages_key, "none"],
+               "new-systems-ou" => [\$new_systems_ou, 'ou=workstations,ou=systems'],
     },
 "ClientPackages" => {
     "key" => [\$ClientPackages_key, "none"],
@@ -1715,6 +1717,16 @@ sub watch_for_new_jobs {
 
                        # Skip new jobs for host if there is a processing job
                        if(defined($res) and defined @{$res}[0]) {
+                               # Prevent race condition if there is a trigger_activate job waiting and a goto-activation job processing
+                               if(@{$res}[5] eq 'trigger_action_reinstall') {
+                                       my $sql_statement_2 =  "SELECT * FROM $job_queue_tn WHERE macaddress LIKE '$macaddress' AND status='waiting' AND headertag = 'trigger_activate_new'"; 
+                                       my $res_2 = $job_db->exec_statement( $sql_statement_2 );
+                                       if(defined($res_2) and defined @{$res}[0]) {
+                                               # Set status from goto-activation to 'waiting' and update timestamp
+                                               $job_db->exec_statement = "UPDATE $job_queue_tn SET status='waiting' WHERE macaddress LIKE '$macaddress' AND headertag = 'trigger_action_reinstall'";
+                                               $job_db->exec_statement = "UPDATE $job_queue_tn SET timestamp='".&get_time(30)."' WHERE macaddress LIKE '$macaddress' AND headertag = 'trigger_action_reinstall'";
+                                       }
+                               }
                                next;
                        }
 
@@ -3037,10 +3049,12 @@ sub register_at_foreign_servers {
         # add locally loaded gosa-si modules to registration message
         my $loaded_modules = {};
         while (my ($package, $pck_info) = each %$known_modules) {
-            foreach my $act_module (keys(%{@$pck_info[2]})) {
-                $loaded_modules->{$act_module} = ""; 
-            }
+                                               next if ((!defined(@$pck_info[2])) || (!(ref (@$pck_info[2]) eq 'HASH')));
+                                               foreach my $act_module (keys(%{@$pck_info[2]})) {
+                                                       $loaded_modules->{$act_module} = ""; 
+                                               }
         }
+
         map(&add_content2xml_hash($myhash, "loaded_modules", $_), keys(%$loaded_modules));
 
         # add macaddress to registration message