From ba80944c6b05a357b5684972bac5a054e29434fb Mon Sep 17 00:00:00 2001 From: michael starke Date: Fri, 11 Nov 2016 19:35:19 +0100 Subject: [PATCH] re-enabled srm for system that still support it --- MacPass/MPTemporaryFileStorage.m | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/MacPass/MPTemporaryFileStorage.m b/MacPass/MPTemporaryFileStorage.m index ae00f539..eb6eb6d6 100644 --- a/MacPass/MPTemporaryFileStorage.m +++ b/MacPass/MPTemporaryFileStorage.m @@ -118,8 +118,22 @@ + (void)_runCleanupForPath:(NSString *)path { NSTask *task = [[NSTask alloc] init]; - [task setLaunchPath:@"/bin/rm"]; - [task setArguments:@[@"-P", path]]; + + NSURL *srmURL = [NSURL fileURLWithPath:@"/usr/bin/srm"]; + NSURL *rmURL = [NSURL fileURLWithPath:@"/bin/rm"]; + + if([srmURL checkResourceIsReachableAndReturnError:nil]) { + task.launchPath = srmURL.path; + task.arguments = @[@"-m", path]; + } + else if([rmURL checkResourceIsReachableAndReturnError:nil]) { + task.launchPath = rmURL.path; + task.arguments= @[@"-P", path]; + } + else { + NSLog(@"Unable to retrieve remove command to whipe temporary file storage!"); + return; + } [task launch]; [task waitUntilExit]; }