Code

Added some ssh works. Not working in the moment.
[gosa.git] / gosa-si / modules / GosaSupportDaemon.pm
index d6aafa43f1f3a821bc7cde046a4ffb957a37159a..b3a43167718f6a03a631abf084648b2af918c64e 100644 (file)
@@ -524,11 +524,11 @@ sub import_events {
 
     if ($error == 0) {
         while (defined (my $event = readdir ($DIR))) {
-            if( $event eq "." || $event eq ".." ) { next; }  
+            if( $event eq "." || $event eq ".." || ($event =~ /^\.pm$/)) { next; }  
 
                        # Check config file to exclude disabled event plugins (i.e. Opsi)
                        if ($event eq "opsi_com.pm" &&  $main::opsi_enabled ne "true")  { 
-                               &main::daemon_log("WARNING: opsi-module is installed but not enabled in config file, please set under section '[OPSI]': 'enabled=true'", 3);    
+                               &main::daemon_log("0 WARNING: opsi-module is installed but not enabled in config file, please set under section '[OPSI]': 'enabled=true'", 3);  
                                next; 
                        }
 
@@ -758,9 +758,11 @@ sub run_as {
        }
        my $cmd_line= "$sudo_cmd su - $uid -c '$command'";
        open(PIPE, "$cmd_line |");
-       my $result = {'resultCode' => $?};
-       $result->{'command'} = $cmd_line;
+       my $result = {'command' => $cmd_line};
        push @{$result->{'output'}}, <PIPE>;
+       close(PIPE);
+       my $exit_value = $? >> 8;
+       $result->{'resultCode'} = $exit_value;
        return $result;
 }
 
@@ -840,7 +842,8 @@ sub check_opsi_res {
 }
 
 sub calc_timestamp {
-    my ($timestamp, $operation, $value) = @_ ;
+    my ($timestamp, $operation, $value, $entity) = @_ ;
+       $entity = defined $entity ? $entity : "seconds";
     my $res_timestamp = 0;
     
     $value = int($value);
@@ -855,12 +858,12 @@ sub calc_timestamp {
             );
 
     if ($operation eq "plus" || $operation eq "+") {
-        $dt->add( seconds => $value);
+        $dt->add($entity => $value);
         $res_timestamp = $dt->ymd('').$dt->hms('');
     }
 
     if ($operation eq "minus" || $operation eq "-") {
-        $dt->subtract(seconds => $value);
+        $dt->subtract($entity => $value);
         $res_timestamp = $dt->ymd('').$dt->hms('');
     }