I am working on a Cocoa application (Objective-C) where it needs to determine if the FileVault
is turned on. I tried searching the .plist
for FileVault
but no success.
Any help would be appreciated,
Thanks in advance :) cheers
I am working on a Cocoa application (Objective-C) where it needs to determine if the FileVault
is turned on. I tried searching the .plist
for FileVault
but no success.
Any help would be appreciated,
Thanks in advance :) cheers
It's fairly simple via NSTask
:
@autoreleasepool {
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/bin/fdesetup"];
[task setArguments:[NSArray arrayWithObjects:@"status", nil]];
NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput: pipe];
NSFileHandle *file = [pipe fileHandleForReading];
[task launch];
NSData *data = [file readDataToEndOfFile];
NSString *string = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
NSLog (@"%@", string); // FileVault is Off/On.
}
There's likely a way to check via SecKeychain
, although for a quick check that might be overkill.