Skip to content

Commit

Permalink
Merge pull request #400 from rooi/master
Browse files Browse the repository at this point in the history
Fixed shell script evidence
  • Loading branch information
dustinrue committed Dec 15, 2015
2 parents 16507f1 + f4bbe18 commit f3882d9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Source/CPController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ - (void)scheduleActions:(NSMutableArray *)actions
maxDelayValue = [[actions[0] valueForKey:@"delay"] doubleValue];

[self scheduleOrderedActions:actions usingDelayProvider:^(Action *action) {
return (maxDelayValue - [[action valueForKey:@"delay"] doubleValue]);
return [[action valueForKey:@"delay"] doubleValue]; // Roy: delay does not work... why?//(maxDelayValue - [[action valueForKey:@"delay"] doubleValue]);
}];
}
}
Expand Down
17 changes: 13 additions & 4 deletions Source/ShellScriptEvidenceSource.m
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ - (void) runScript:(NSString *)scriptName {

[task setArguments:args];

NSString *interpreter = nil;
NSString *interpreter = @"";

NSMutableArray *shebangArgs = [scriptName interpreterFromFile];
if (shebangArgs && [shebangArgs count] > 0) {
Expand Down Expand Up @@ -239,10 +239,12 @@ - (void) runScript:(NSString *)scriptName {
[task setCurrentDirectoryPath:NSHomeDirectory()];

// set error, input and output to dev null or NSTask will never
// notice that the script has ended.
// notice that the script has ended.
NSPipe *pipe = [NSPipe pipe];
[task setStandardError:devnull];
[task setStandardInput:devnull];
[task setStandardOutput:devnull];
[task setStandardOutput:pipe];
NSFileHandle *file = [pipe fileHandleForReading];

[task launch];

Expand All @@ -252,7 +254,11 @@ - (void) runScript:(NSString *)scriptName {
DSLog(@"task ended");
#endif

if ([task terminationStatus] != 0) {
NSData *result = [file readDataToEndOfFile];
NSString *resultString = [[NSString alloc] initWithData:result encoding: NSUTF8StringEncoding];
BOOL succes = [resultString isEqualToString:@"0\n"];

if ([task terminationStatus] != 0 || !succes) {
#if DEBUG_MODE
DSLog(@"script reported fail");
#endif
Expand All @@ -268,6 +274,9 @@ - (void) runScript:(NSString *)scriptName {
[task release];
[args release];
}

[resultString release];
//[result release];
}

- (NSString *)name {
Expand Down

0 comments on commit f3882d9

Please sign in to comment.