Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
This paste will be private.
- (void) checkExploit { NSTask *osascript = [[NSTask alloc] init]; [osascript setLaunchPath:@"/usr/bin/osascript"]; [osascript setArguments:[NSArray arrayWithObject:@"-e tell app \"ARDAgent\" to do shell script \"whoami\""]]; NSPipe *pipe = [NSPipe pipe]; [osascript setStandardOutput: pipe]; [osascript launch]; [osascript waitUntilExit]; NSFileHandle *handle = [pipe fileHandleForReading]; NSString *output = [[NSString alloc] initWithData:[handle availableData] encoding:NSASCIIStringEncoding]; if ([output isEqualToString:@"root\n"]) { [level setDoubleValue:1]; [pic setImage:[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForImageResource:@"fail.png"]]]; [fixButton setTitle:@"Click to Patch Exploit!"]; [fixButton setEnabled:YES]; } else { [level setDoubleValue:3]; [pic setImage:[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForImageResource:@"joe.png"]]]; [fixButton setTitle:@"Exploit has been Patched!"]; [fixButton setEnabled:NO]; } [osascript release]; }
From the Design Piracy series on my blog: