| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "AuthorizedInstall.h" | 5 #import "AuthorizedInstall.h" |
| 6 | 6 |
| 7 @interface AuthorizedInstall () { | 7 @interface AuthorizedInstall () { |
| 8 NSFileHandle* communicationFile_; | 8 NSFileHandle* communicationFile_; |
| 9 NSString* destinationAppBundlePath_; | 9 NSString* destinationAppBundlePath_; |
| 10 } | 10 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 // Starts up the proccess with privileged permissions. | 29 // Starts up the proccess with privileged permissions. |
| 30 - (void)startPrivilegedTool:(const char*)toolPath | 30 - (void)startPrivilegedTool:(const char*)toolPath |
| 31 withArguments:(const char**)args | 31 withArguments:(const char**)args |
| 32 authorization:(AuthorizationRef)authRef | 32 authorization:(AuthorizationRef)authRef |
| 33 status:(OSStatus)status { | 33 status:(OSStatus)status { |
| 34 if (status != errAuthorizationSuccess) | 34 if (status != errAuthorizationSuccess) |
| 35 return; | 35 return; |
| 36 | 36 |
| 37 FILE* file; | 37 FILE* file; |
| 38 // AuthorizationExecuteWithPrivileges is deprecated in macOS 10.7, but no good |
| 39 // replacement exists. https://crbug.com/593133. |
| 38 #pragma clang diagnostic push | 40 #pragma clang diagnostic push |
| 39 #pragma clang diagnostic ignored "-Wdeprecated-declarations" | 41 #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
| 40 status = AuthorizationExecuteWithPrivileges( | 42 status = AuthorizationExecuteWithPrivileges( |
| 41 authRef, toolPath, kAuthorizationFlagDefaults, (char* const*)args, &file); | 43 authRef, toolPath, kAuthorizationFlagDefaults, (char* const*)args, &file); |
| 42 #pragma clang diagnostic pop | 44 #pragma clang diagnostic pop |
| 43 communicationFile_ = [[NSFileHandle alloc] initWithFileDescriptor:fileno(file) | 45 communicationFile_ = [[NSFileHandle alloc] initWithFileDescriptor:fileno(file) |
| 44 closeOnDealloc:YES]; | 46 closeOnDealloc:YES]; |
| 45 } | 47 } |
| 46 | 48 |
| 47 // Starts up same proccess as above without privileged permissions. | 49 // Starts up same proccess as above without privileged permissions. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 [communicationFile_ writeData:[[message stringByAppendingString:@"\n"] | 122 [communicationFile_ writeData:[[message stringByAppendingString:@"\n"] |
| 121 dataUsingEncoding:NSUTF8StringEncoding]]; | 123 dataUsingEncoding:NSUTF8StringEncoding]]; |
| 122 } | 124 } |
| 123 | 125 |
| 124 - (NSString*)startInstall:(NSString*)appBundlePath { | 126 - (NSString*)startInstall:(NSString*)appBundlePath { |
| 125 [self sendMessageToTool:appBundlePath]; | 127 [self sendMessageToTool:appBundlePath]; |
| 126 return destinationAppBundlePath_; | 128 return destinationAppBundlePath_; |
| 127 } | 129 } |
| 128 | 130 |
| 129 @end | 131 @end |
| OLD | NEW |