mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
Initial work on removing AuthorizationExecuteWithPrivileges
I need to at least look at: * Automatic downloaded / silent updates * Running updates as root user from beginning * Status info query service * Add guided flag in the appcast
This commit is contained in:
1 parent
6b5f014946
commit
66e3083e0c
51 files changed
+1192
-1177
No files matched your search
@@ -3,7 +3,6 @@
|
||||
SPARKLE_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle
|
||||
SPARKLE_RELAUNCH_TOOL_NAME = Autoupdate
|
||||
SPARKLE_INSTALLER_PROGRESS_TOOL_NAME = Updater
|
||||
SPARKLE_FILEOP_TOOL_NAME = fileop
|
||||
|
||||
SPARKLE_APPEND_VERSION_NUMBER = 1
|
||||
|
||||
@@ -46,7 +45,7 @@ INSTALLER_LAUNCHER_BUNDLE_ID = org.sparkle-project.${INSTALLER_LAUNCHER_PRODUCT_
|
||||
TEMPORARY_DOWNLOADER_BUNDLE_ID = org.sparkle-project.${TEMPORARY_DOWNLOADER_PRODUCT_NAME}
|
||||
PERSISTENT_DOWNLOADER_BUNDLE_ID = org.sparkle-project.${PERSISTENT_DOWNLOADER_PRODUCT_NAME}
|
||||
|
||||
GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_AUTOMATED_DOWNGRADES=$(SPARKLE_AUTOMATED_DOWNGRADES) SPARKLE_APPEND_VERSION_NUMBER=$(SPARKLE_APPEND_VERSION_NUMBER) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" CURRENT_PROJECT_VERSION=\"$(CURRENT_PROJECT_VERSION)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_INSTALLER_PROGRESS_TOOL_NAME=\"$(SPARKLE_INSTALLER_PROGRESS_TOOL_NAME)\" SPARKLE_ICON_NAME=\"$(SPARKLE_ICON_NAME)\" INSTALLER_LAUNCHER_BUNDLE_ID=\"${INSTALLER_LAUNCHER_BUNDLE_ID}\" INSTALLER_CONNECTION_BUNDLE_ID=\"${INSTALLER_CONNECTION_BUNDLE_ID}\" INSTALLER_STATUS_BUNDLE_ID=\"${INSTALLER_STATUS_BUNDLE_ID}\" TEMPORARY_DOWNLOADER_BUNDLE_ID=\"${TEMPORARY_DOWNLOADER_BUNDLE_ID}\" PERSISTENT_DOWNLOADER_BUNDLE_ID=\"${PERSISTENT_DOWNLOADER_BUNDLE_ID}\" INSTALLER_LAUNCHER_PRODUCT_NAME=\"${INSTALLER_LAUNCHER_PRODUCT_NAME}\" INSTALLER_CONNECTION_PRODUCT_NAME=\"${INSTALLER_CONNECTION_PRODUCT_NAME}\" INSTALLER_STATUS_PRODUCT_NAME=\"${INSTALLER_STATUS_PRODUCT_NAME}\" TEMPORARY_DOWNLOADER_PRODUCT_NAME=\"${TEMPORARY_DOWNLOADER_PRODUCT_NAME}\" PERSISTENT_DOWNLOADER_PRODUCT_NAME=\"${PERSISTENT_DOWNLOADER_PRODUCT_NAME}\" SPARKLE_FILEOP_TOOL_NAME=\"$(SPARKLE_FILEOP_TOOL_NAME)\"
|
||||
GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_AUTOMATED_DOWNGRADES=$(SPARKLE_AUTOMATED_DOWNGRADES) SPARKLE_APPEND_VERSION_NUMBER=$(SPARKLE_APPEND_VERSION_NUMBER) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" CURRENT_PROJECT_VERSION=\"$(CURRENT_PROJECT_VERSION)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_INSTALLER_PROGRESS_TOOL_NAME=\"$(SPARKLE_INSTALLER_PROGRESS_TOOL_NAME)\" SPARKLE_ICON_NAME=\"$(SPARKLE_ICON_NAME)\" INSTALLER_LAUNCHER_BUNDLE_ID=\"${INSTALLER_LAUNCHER_BUNDLE_ID}\" INSTALLER_CONNECTION_BUNDLE_ID=\"${INSTALLER_CONNECTION_BUNDLE_ID}\" INSTALLER_STATUS_BUNDLE_ID=\"${INSTALLER_STATUS_BUNDLE_ID}\" TEMPORARY_DOWNLOADER_BUNDLE_ID=\"${TEMPORARY_DOWNLOADER_BUNDLE_ID}\" PERSISTENT_DOWNLOADER_BUNDLE_ID=\"${PERSISTENT_DOWNLOADER_BUNDLE_ID}\" INSTALLER_LAUNCHER_PRODUCT_NAME=\"${INSTALLER_LAUNCHER_PRODUCT_NAME}\" INSTALLER_CONNECTION_PRODUCT_NAME=\"${INSTALLER_CONNECTION_PRODUCT_NAME}\" INSTALLER_STATUS_PRODUCT_NAME=\"${INSTALLER_STATUS_PRODUCT_NAME}\" TEMPORARY_DOWNLOADER_PRODUCT_NAME=\"${TEMPORARY_DOWNLOADER_PRODUCT_NAME}\" PERSISTENT_DOWNLOADER_PRODUCT_NAME=\"${PERSISTENT_DOWNLOADER_PRODUCT_NAME}\"
|
||||
|
||||
CLANG_ENABLE_OBJC_ARC = YES
|
||||
GCC_ENABLE_PASCAL_STRINGS = NO
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
// Fileop tool only
|
||||
|
||||
PRODUCT_NAME = $(SPARKLE_FILEOP_TOOL_NAME)
|
||||
SKIP_INSTALL = YES
|
||||
CLANG_ENABLE_MODULES = NO
|
||||
@@ -58,9 +58,9 @@ static NSString *SUInstallerConnectionKeepAliveReason = @"Installer Connection K
|
||||
[self enableAutomaticTermination];
|
||||
}
|
||||
|
||||
- (void)setServiceName:(NSString *)serviceName
|
||||
- (void)setServiceName:(NSString *)serviceName hostPath:(NSString *)hostPath guided:(BOOL)guided
|
||||
{
|
||||
NSXPCConnectionOptions options = SUGrantsSystemAuthorizationAccess() ? NSXPCConnectionPrivileged : 0;
|
||||
NSXPCConnectionOptions options = SUNeedsSystemAuthorizationAccess(hostPath, guided, NULL) ? NSXPCConnectionPrivileged : 0;
|
||||
NSXPCConnection *connection = [[NSXPCConnection alloc] initWithMachServiceName:serviceName options:options];
|
||||
|
||||
connection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerCommunicationProtocol)];
|
||||
@@ -72,7 +72,7 @@ static NSString *SUInstallerConnectionKeepAliveReason = @"Installer Connection K
|
||||
|
||||
__weak SUInstallerConnection *weakSelf = self;
|
||||
self.connection.interruptionHandler = ^{
|
||||
[weakSelf invalidate];
|
||||
[weakSelf.connection invalidate];
|
||||
};
|
||||
|
||||
self.connection.invalidationHandler = ^{
|
||||
|
||||
@@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)setInvalidationHandler:(void (^)(void))invalidationHandler;
|
||||
|
||||
- (void)setServiceName:(NSString *)serviceName;
|
||||
- (void)setServiceName:(NSString *)serviceName hostPath:(NSString *)hostPath guided:(BOOL)guided;
|
||||
|
||||
- (void)invalidate;
|
||||
|
||||
|
||||
@@ -59,9 +59,9 @@
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setServiceName:(NSString *)serviceName
|
||||
- (void)setServiceName:(NSString *)serviceName hostPath:(NSString *)hostPath guided:(BOOL)guided
|
||||
{
|
||||
[self.connection.remoteObjectProxy setServiceName:serviceName];
|
||||
[self.connection.remoteObjectProxy setServiceName:serviceName hostPath:hostPath guided:guided];
|
||||
}
|
||||
|
||||
- (void)handleMessageWithIdentifier:(int32_t)identifier data:(NSData *)data
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// InstallerProgressLauncher.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 7/17/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol InstallerProgressLauncherDelegate <NSObject>
|
||||
|
||||
- (void)installerProgressLauncherDidInvalidate;
|
||||
- (void)installerProgressLauncherDidSubmitJob;
|
||||
|
||||
@end
|
||||
|
||||
@interface InstallerProgressLauncher : NSObject
|
||||
|
||||
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle installerPath:(NSString *)installerPath allowingInteraction:(BOOL)allowingInteraction delegate:(id<InstallerProgressLauncherDelegate>)delegate;
|
||||
|
||||
- (void)startListener;
|
||||
|
||||
- (void)invalidate;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,140 @@
|
||||
//
|
||||
// InstallerProgressLauncher.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 7/17/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "InstallerProgressLauncher.h"
|
||||
#import "SUMessageTypes.h"
|
||||
#import "SUInstallerProgressLauncherProtocol.h"
|
||||
#import "SUSubmitInstaller.h"
|
||||
#import "SULog.h"
|
||||
|
||||
#define REQUEST_AUTHORIZATION_TIMEOUT 7ull
|
||||
|
||||
@interface InstallerProgressLauncher () <NSXPCListenerDelegate>
|
||||
|
||||
@property (nonatomic) NSXPCListener *xpcListener;
|
||||
@property (nonatomic) NSXPCConnection *activeConnection;
|
||||
@property (nonatomic, readonly) NSBundle *hostBundle;
|
||||
@property (nonatomic, copy, readonly) NSString *installerPath;
|
||||
@property (nonatomic, readonly) BOOL allowsInteraction;
|
||||
@property (nonatomic, weak) id<InstallerProgressLauncherDelegate> delegate;
|
||||
@property (nonatomic) BOOL connected;
|
||||
|
||||
@end
|
||||
|
||||
@implementation InstallerProgressLauncher
|
||||
|
||||
@synthesize xpcListener = _xpcListener;
|
||||
@synthesize activeConnection = _activeConnection;
|
||||
@synthesize hostBundle = _hostBundle;
|
||||
@synthesize installerPath = _installerPath;
|
||||
@synthesize allowsInteraction = _allowsInteraction;
|
||||
@synthesize delegate = _delegate;
|
||||
@synthesize connected = _connected;
|
||||
|
||||
- (instancetype)initWithHostBundle:(NSBundle *)hostBundle installerPath:(NSString *)installerPath allowingInteraction:(BOOL)allowingInteraction delegate:(id<InstallerProgressLauncherDelegate>)delegate
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
NSString *bundleIdentifier = hostBundle.bundleIdentifier;
|
||||
assert(bundleIdentifier != nil);
|
||||
|
||||
_hostBundle = hostBundle;
|
||||
_installerPath = [installerPath copy];
|
||||
_allowsInteraction = allowingInteraction;
|
||||
_delegate = delegate;
|
||||
|
||||
_xpcListener = [[NSXPCListener alloc] initWithMachServiceName:SUProgressAgentLauncherServiceNameForBundleIdentifier(bundleIdentifier)];
|
||||
_xpcListener.delegate = self;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)startListener
|
||||
{
|
||||
[self.xpcListener resume];
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
// Declare local variable for the delegate, so that if the delegate invokes -invalidate, we won't be in an infinite recursion
|
||||
id<InstallerProgressLauncherDelegate> delegate = self.delegate;
|
||||
self.delegate = nil;
|
||||
[delegate installerProgressLauncherDidInvalidate];
|
||||
|
||||
[self.activeConnection invalidate];
|
||||
[self.xpcListener invalidate];
|
||||
|
||||
self.activeConnection = nil;
|
||||
self.xpcListener = nil;
|
||||
}
|
||||
|
||||
- (BOOL)listener:(NSXPCListener *)__unused listener shouldAcceptNewConnection:(NSXPCConnection *)connection
|
||||
{
|
||||
if (self.activeConnection != nil) {
|
||||
SULog(@"Error: active connection for progress launcher already exists");
|
||||
[connection invalidate];
|
||||
return NO;
|
||||
}
|
||||
|
||||
connection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerProgressLauncherProtocol)];
|
||||
connection.exportedObject = self;
|
||||
|
||||
self.activeConnection = connection;
|
||||
|
||||
__weak InstallerProgressLauncher *weakSelf = self;
|
||||
connection.interruptionHandler = ^{
|
||||
[weakSelf.activeConnection invalidate];
|
||||
};
|
||||
|
||||
connection.invalidationHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
InstallerProgressLauncher *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
strongSelf.activeConnection = nil;
|
||||
[strongSelf invalidate];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(REQUEST_AUTHORIZATION_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
SULog(@"Dispatch timeout invoked");
|
||||
if (!self.connected) {
|
||||
[self invalidate];
|
||||
}
|
||||
});
|
||||
|
||||
[connection resume];
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)requestUserAuthorizationWithReply:(void (^)(SUAuthorizationReply))reply
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.connected = YES;
|
||||
|
||||
SUAuthorizationReply submissionReply = [SUSubmitInstaller submitInstallerAtPath:self.installerPath withHostBundle:self.hostBundle allowingInteraction:self.allowsInteraction inSystemDomain:YES];
|
||||
|
||||
if (submissionReply == SUAuthorizationReplyFailure) {
|
||||
SULog(@"Error: failed to submit installer in system domain");
|
||||
}
|
||||
|
||||
reply(submissionReply);
|
||||
|
||||
if (submissionReply == SUAuthorizationReplySuccess) {
|
||||
[self.delegate installerProgressLauncherDidSubmitJob];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)connectionDidInitiateWithReply:(void (^)(void))acknowledgement
|
||||
{
|
||||
acknowledgement();
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// SUAuthorizationReply.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 7/18/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
typedef NS_ENUM(NSUInteger, SUAuthorizationReply)
|
||||
{
|
||||
SUAuthorizationReplySuccess = 0,
|
||||
SUAuthorizationReplyCancelled = 1,
|
||||
SUAuthorizationReplyFailure = 2
|
||||
};
|
||||
@@ -10,76 +10,176 @@
|
||||
#import "SUFileManager.h"
|
||||
#import "SULog.h"
|
||||
#import "SUMessageTypes.h"
|
||||
#import <ServiceManagement/SMLoginItem.h>
|
||||
#import "SUSystemAuthorization.h"
|
||||
#import "SUSubmitInstaller.h"
|
||||
#import "SUInstallerProgressLauncherProtocol.h"
|
||||
|
||||
#define AUTHORIZATION_REPLY_TIMEOUT 7ull
|
||||
|
||||
@interface SUInstallerLauncher ()
|
||||
|
||||
@property (nonatomic, nullable) NSXPCConnection *activeConnection;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUInstallerLauncher
|
||||
|
||||
- (void)launchInstallerAtPath:(NSString *)installerPath withHostBundleIdentifier:(NSString *)hostBundleIdentifier allowingInteraction:(BOOL)allowingInteraction completion:(void (^)(BOOL success))completionHandler
|
||||
@synthesize activeConnection = _activeConnection;
|
||||
|
||||
- (BOOL)submitProgressToolAtPath:(NSString *)progressToolPath withHostBundle:(NSBundle *)hostBundle allowingInteraction:(BOOL)allowingInteraction installerPath:(NSString *)installerPath shouldSubmitInstaller:(BOOL)shouldSubmitInstaller
|
||||
{
|
||||
SUFileManager *fileManager = [SUFileManager defaultManager];
|
||||
|
||||
NSURL *progressToolURL = [NSURL fileURLWithPath:progressToolPath];
|
||||
|
||||
NSError *quarantineError = nil;
|
||||
if (![fileManager releaseItemFromQuarantineAtRootURL:progressToolURL error:&quarantineError]) {
|
||||
// This may or may not be a fatal error depending on if the process is sandboxed or not
|
||||
SULog(@"Failed to release quarantine on installer at %@ with error %@", progressToolPath, quarantineError);
|
||||
}
|
||||
|
||||
NSString *executablePath = [[NSBundle bundleWithURL:progressToolURL] executablePath];
|
||||
assert(executablePath != nil);
|
||||
|
||||
NSString *hostBundlePath = hostBundle.bundlePath;
|
||||
assert(hostBundlePath != nil);
|
||||
|
||||
NSString *hostBundleIdentifier = hostBundle.bundleIdentifier;
|
||||
assert(hostBundleIdentifier != nil);
|
||||
|
||||
NSArray<NSString *> *arguments = @[executablePath, hostBundlePath, @(allowingInteraction).stringValue, installerPath, @(shouldSubmitInstaller).stringValue];
|
||||
|
||||
#warning support running under system domain if updater is running as root - this means we would have to try running job under a different user
|
||||
CFStringRef domain = kSMDomainUserLaunchd;
|
||||
NSString *label = [NSString stringWithFormat:@"%@-sparkle-progress", hostBundleIdentifier];
|
||||
|
||||
AuthorizationRef auth = NULL;
|
||||
Boolean submittedJob = false;
|
||||
OSStatus createStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &auth);
|
||||
if (createStatus == errAuthorizationSuccess) {
|
||||
// Try to remove the job from launchd if it is already running
|
||||
// We could invoke SMJobCopyDictionary() first to see if the job exists, but I'd rather avoid
|
||||
// using it because the headers indicate it may be removed one day without any replacement
|
||||
CFErrorRef removeError = NULL;
|
||||
if (!SMJobRemove(domain, (__bridge CFStringRef)(label), auth, true, &removeError)) {
|
||||
if (removeError != NULL) {
|
||||
// It's normal for a job to not be found, so this is not an interesting error
|
||||
if (CFErrorGetCode(removeError) != kSMErrorJobNotFound) {
|
||||
SULog(@"Remove error: %@", removeError);
|
||||
}
|
||||
CFRelease(removeError);
|
||||
}
|
||||
}
|
||||
|
||||
NSMutableDictionary *jobDictionary = [[NSMutableDictionary alloc] init];
|
||||
jobDictionary[@"Label"] = label;
|
||||
jobDictionary[@"ProgramArguments"] = arguments;
|
||||
jobDictionary[@"EnableTransactions"] = @NO;
|
||||
jobDictionary[@"KeepAlive"] = @{@"SuccessfulExit" : @NO};
|
||||
jobDictionary[@"RunAtLoad"] = @NO;
|
||||
jobDictionary[@"NICE"] = @0;
|
||||
jobDictionary[@"LaunchOnlyOnce"] = @YES;
|
||||
|
||||
if (shouldSubmitInstaller) {
|
||||
jobDictionary[@"MachServices"] = @{SUProgressAgentLauncherServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES};
|
||||
}
|
||||
|
||||
CFErrorRef submitError = NULL;
|
||||
submittedJob = SMJobSubmit(domain, (__bridge CFDictionaryRef)(jobDictionary), auth, &submitError);
|
||||
if (!submittedJob) {
|
||||
if (submitError != NULL) {
|
||||
SULog(@"Submit progress error: %@", submitError);
|
||||
CFRelease(submitError);
|
||||
}
|
||||
}
|
||||
|
||||
AuthorizationFree(auth, kAuthorizationFlagDefaults);
|
||||
}
|
||||
|
||||
return (submittedJob == true);
|
||||
}
|
||||
|
||||
- (void)waitForProgressAgentWithHostBundle:(NSBundle *)hostBundle completion:(void (^)(SUAuthorizationReply))completionHandler
|
||||
{
|
||||
NSString *hostBundleIdentifier = hostBundle.bundleIdentifier;
|
||||
assert(hostBundleIdentifier != nil);
|
||||
|
||||
NSXPCConnection *connection = [[NSXPCConnection alloc] initWithMachServiceName:SUProgressAgentLauncherServiceNameForBundleIdentifier(hostBundleIdentifier) options:(NSXPCConnectionOptions)0];
|
||||
|
||||
connection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerProgressLauncherProtocol)];
|
||||
|
||||
self.activeConnection = connection;
|
||||
|
||||
__weak SUInstallerLauncher *weakSelf = self;
|
||||
connection.interruptionHandler = ^{
|
||||
[weakSelf.activeConnection invalidate];
|
||||
};
|
||||
|
||||
__block BOOL invokedCompletion = NO;
|
||||
|
||||
connection.invalidationHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (!invokedCompletion) {
|
||||
invokedCompletion = YES;
|
||||
completionHandler(SUAuthorizationReplyFailure);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
[connection resume];
|
||||
|
||||
id<SUInstallerProgressLauncherProtocol> launcher = connection.remoteObjectProxy;
|
||||
|
||||
__block BOOL intiatedConnection = NO;
|
||||
[launcher connectionDidInitiateWithReply:^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
intiatedConnection = YES;
|
||||
|
||||
[launcher requestUserAuthorizationWithReply:^(SUAuthorizationReply reply) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (!invokedCompletion) {
|
||||
invokedCompletion = YES;
|
||||
[weakSelf.activeConnection invalidate];
|
||||
completionHandler(reply);
|
||||
}
|
||||
});
|
||||
}];
|
||||
});
|
||||
}];
|
||||
|
||||
// If we initiated a connection, we can't time out because the user could just be taking a really long time to reply
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(AUTHORIZATION_REPLY_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (!intiatedConnection && !invokedCompletion) {
|
||||
[weakSelf.activeConnection invalidate];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)launchInstallerAtPath:(NSString *)installerPath progressToolPath:(NSString *)progressToolPath withHostBundlePath:(NSString *)hostBundlePath guidedInstallation:(BOOL)guidedInstallation allowingInteraction:(BOOL)allowingInteraction completion:(void (^)(SUAuthorizationReply))completionHandler
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
SUFileManager *fileManager = [SUFileManager defaultManager];
|
||||
NSBundle *hostBundle = [NSBundle bundleWithPath:hostBundlePath];
|
||||
|
||||
NSURL *installerURL = [NSURL fileURLWithPath:installerPath];
|
||||
BOOL submittedInstaller = NO;
|
||||
BOOL preflighted = NO;
|
||||
|
||||
NSError *quarantineError = nil;
|
||||
if (![fileManager releaseItemFromQuarantineAtRootURL:installerURL error:&quarantineError]) {
|
||||
// This may or may not be a fatal error depending on if the process is sandboxed or not
|
||||
SULog(@"Failed to release quarantine on installer at %@ with error %@", installerPath, quarantineError);
|
||||
// Only submit a job here if we are preflighted (already running root in which case we use system domain),
|
||||
// or if we do not have to ask the user for authorization
|
||||
BOOL needsSystemAuthorization = SUNeedsSystemAuthorizationAccess(hostBundlePath, guidedInstallation, &preflighted);
|
||||
BOOL shouldSubmitInstallerImmediately = (!needsSystemAuthorization || preflighted);
|
||||
if (shouldSubmitInstallerImmediately) {
|
||||
submittedInstaller = ([SUSubmitInstaller submitInstallerAtPath:installerPath withHostBundle:hostBundle allowingInteraction:allowingInteraction inSystemDomain:needsSystemAuthorization] == SUAuthorizationReplySuccess);
|
||||
}
|
||||
|
||||
NSString *executablePath = [[[installerPath stringByAppendingPathComponent:@"Contents"] stringByAppendingPathComponent:@"MacOS"] stringByAppendingPathComponent:@SPARKLE_RELAUNCH_TOOL_NAME];
|
||||
BOOL submittedProgressTool = [self submitProgressToolAtPath:progressToolPath withHostBundle:hostBundle allowingInteraction:allowingInteraction installerPath:installerPath shouldSubmitInstaller:!shouldSubmitInstallerImmediately];
|
||||
|
||||
NSError *ownershipError = nil;
|
||||
if (![fileManager changeOwnerAndGroupOfItemAtRootURL:[NSURL fileURLWithPath:executablePath] toMatchURL:installerURL error:&ownershipError]) {
|
||||
// This may or may not be a fatal error
|
||||
SULog(@"Failed to change ownership on installer executable at %@ with error %@", executablePath, ownershipError);
|
||||
if (!submittedProgressTool) {
|
||||
completionHandler(SUAuthorizationReplyFailure);
|
||||
} else if (shouldSubmitInstallerImmediately) {
|
||||
completionHandler(submittedInstaller ? SUAuthorizationReplySuccess : SUAuthorizationReplyFailure);
|
||||
} else {
|
||||
[self waitForProgressAgentWithHostBundle:hostBundle completion:completionHandler];
|
||||
}
|
||||
|
||||
NSArray *arguments = @[executablePath, hostBundleIdentifier, @(allowingInteraction).stringValue];
|
||||
|
||||
// If the updater is running as the logged in user, we submit a job under the user domain
|
||||
// However if the updater is running as root (which is experimental), we submit the job under the system domain
|
||||
// We don't yet handle the updater running as the logged in user, and submitting a job under the system domain, which
|
||||
// would remove the need for using AuthorizationExecuteWithPrivileges() in the installer. That would require knowing before hand
|
||||
// if we will need to request authorization privileges, and that would prevent this code from being invoked silently/automatically.
|
||||
// Additionally, we would want to remove AppKit references in the installer
|
||||
BOOL grantsSystemPrivilege = NO;
|
||||
AuthorizationRef auth = SUCreateAuthorization(&grantsSystemPrivilege);
|
||||
Boolean submittedJob = false;
|
||||
if (auth != NULL) {
|
||||
CFStringRef domain = (grantsSystemPrivilege ? kSMDomainSystemLaunchd : kSMDomainUserLaunchd);
|
||||
NSString *label = [NSString stringWithFormat:@"%@-sparkle-updater", hostBundleIdentifier];
|
||||
|
||||
// Try to remove the job from launchd if it is already running
|
||||
// We could invoke SMJobCopyDictionary() first to see if the job exists, but I'd rather avoid
|
||||
// using it because the headers indicate it may be removed one day without any replacement
|
||||
CFErrorRef removeError = NULL;
|
||||
if (!SMJobRemove(domain, (__bridge CFStringRef)(label), auth, true, &removeError)) {
|
||||
if (removeError != NULL) {
|
||||
// It's normal for a job to not be found, so this is not an interesting error
|
||||
if (CFErrorGetCode(removeError) != kSMErrorJobNotFound) {
|
||||
SULog(@"Remove error: %@", removeError);
|
||||
}
|
||||
CFRelease(removeError);
|
||||
}
|
||||
}
|
||||
|
||||
NSDictionary *jobDictionary = @{@"Label" : label, @"ProgramArguments" : arguments, @"EnableTransactions" : @NO, @"KeepAlive" : @{@"SuccessfulExit" : @NO}, @"RunAtLoad" : @NO, @"NICE" : @0, @"LaunchOnlyOnce": @YES, @"MachServices" : @{SUInstallerServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES, SUStatusInfoServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES}};
|
||||
|
||||
CFErrorRef submitError = NULL;
|
||||
submittedJob = SMJobSubmit(domain, (__bridge CFDictionaryRef)(jobDictionary), auth, &submitError);
|
||||
if (!submittedJob) {
|
||||
if (submitError != NULL) {
|
||||
SULog(@"Submit error: %@", submitError);
|
||||
CFRelease(submitError);
|
||||
}
|
||||
}
|
||||
|
||||
AuthorizationFree(auth, kAuthorizationFlagDefaults);
|
||||
}
|
||||
|
||||
completionHandler(submittedJob == true);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -7,9 +7,10 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUAuthorizationReply.h"
|
||||
|
||||
@protocol SUInstallerLauncherProtocol
|
||||
|
||||
- (void)launchInstallerAtPath:(NSString *)installerPath withHostBundleIdentifier:(NSString *)hostBundleIdentifier allowingInteraction:(BOOL)allowingInteraction completion:(void (^)(BOOL success))completionHandler;
|
||||
- (void)launchInstallerAtPath:(NSString *)installerPath progressToolPath:(NSString *)progressToolPath withHostBundlePath:(NSString *)hostBundlePath guidedInstallation:(BOOL)guidedInstallation allowingInteraction:(BOOL)allowingInteraction completion:(void (^)(SUAuthorizationReply))completionHandler;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// SUInstallerProgressLauncherProtocol.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 7/17/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUInstallerAgentInitiationProtocol.h"
|
||||
#import "SUAuthorizationReply.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SUInstallerProgressLauncherProtocol <SUInstallerAgentInitiationProtocol>
|
||||
|
||||
- (void)requestUserAuthorizationWithReply:(void (^)(SUAuthorizationReply))reply;
|
||||
|
||||
// Redeclare this method from SUInstallerAgentInitiationProtocol because XPC decoders on older OS systems (eg: 10.8) do not traverse parent protocols
|
||||
- (void)connectionDidInitiateWithReply:(void (^)(void))acknowledgement;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// SUSubmitInstaller.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 7/17/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUAuthorizationReply.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUSubmitInstaller : NSObject
|
||||
|
||||
+ (SUAuthorizationReply)submitInstallerAtPath:(NSString *)installerPath withHostBundle:(NSBundle *)hostBundle allowingInteraction:(BOOL)allowingInteraction inSystemDomain:(BOOL)systemDomain;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,120 @@
|
||||
//
|
||||
// SUSubmitInstaller.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 7/17/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUSubmitInstaller.h"
|
||||
#import "SUFileManager.h"
|
||||
#import "SULog.h"
|
||||
#import "SUMessageTypes.h"
|
||||
#import <ServiceManagement/ServiceManagement.h>
|
||||
|
||||
@implementation SUSubmitInstaller
|
||||
|
||||
+ (SUAuthorizationReply)submitInstallerAtPath:(NSString *)installerPath withHostBundle:(NSBundle *)hostBundle allowingInteraction:(BOOL)allowingInteraction inSystemDomain:(BOOL)systemDomain
|
||||
{
|
||||
SUFileManager *fileManager = [SUFileManager defaultManager];
|
||||
|
||||
NSURL *installerURL = [NSURL fileURLWithPath:installerPath];
|
||||
|
||||
NSError *quarantineError = nil;
|
||||
if (![fileManager releaseItemFromQuarantineAtRootURL:installerURL error:&quarantineError]) {
|
||||
// This may or may not be a fatal error depending on if the process is sandboxed or not
|
||||
SULog(@"Failed to release quarantine on installer at %@ with error %@", installerPath, quarantineError);
|
||||
}
|
||||
|
||||
NSString *executablePath = [[NSBundle bundleWithURL:installerURL] executablePath];
|
||||
assert(executablePath != nil);
|
||||
|
||||
NSError *ownershipError = nil;
|
||||
if (![fileManager changeOwnerAndGroupOfItemAtRootURL:[NSURL fileURLWithPath:executablePath] toMatchURL:installerURL error:&ownershipError]) {
|
||||
// This may or may not be a fatal error
|
||||
SULog(@"Failed to change ownership on installer executable at %@ with error %@", executablePath, ownershipError);
|
||||
}
|
||||
|
||||
NSString *hostBundleIdentifier = hostBundle.bundleIdentifier;
|
||||
assert(hostBundleIdentifier != nil);
|
||||
|
||||
NSArray<NSString *> *arguments = @[executablePath, hostBundleIdentifier, @(allowingInteraction).stringValue];
|
||||
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus createStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &auth);
|
||||
if (createStatus != errAuthorizationSuccess) {
|
||||
auth = NULL;
|
||||
SULog(@"Failed to create authorization reference");
|
||||
}
|
||||
|
||||
BOOL canceledAuthorization = NO;
|
||||
BOOL failedToUseSystemDomain = NO;
|
||||
if (auth != NULL && systemDomain) {
|
||||
AuthorizationItem rightItems[] = {
|
||||
{ .name = kSMRightModifySystemDaemons, .valueLength = 0, .value = NULL, .flags = 0}
|
||||
};
|
||||
|
||||
AuthorizationRights rights = {
|
||||
.count = sizeof(rightItems) / sizeof(*rightItems),
|
||||
.items = rightItems,
|
||||
};
|
||||
|
||||
AuthorizationFlags flags =
|
||||
(AuthorizationFlags)(kAuthorizationFlagDefaults | kAuthorizationFlagExtendRights | kAuthorizationFlagPreAuthorize | kAuthorizationFlagInteractionAllowed);
|
||||
|
||||
OSStatus copyStatus = AuthorizationCopyRights(auth, &rights, kAuthorizationEmptyEnvironment, flags, NULL);
|
||||
if (copyStatus != errAuthorizationSuccess) {
|
||||
SULog(@"Failed copying system domain rights with kSMRightModifySystemDaemons");
|
||||
failedToUseSystemDomain = YES;
|
||||
|
||||
if (copyStatus == errAuthorizationCanceled) {
|
||||
canceledAuthorization = YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Boolean submittedJob = false;
|
||||
if (!failedToUseSystemDomain && auth != NULL) {
|
||||
CFStringRef domain = (systemDomain ? kSMDomainSystemLaunchd : kSMDomainUserLaunchd);
|
||||
NSString *label = [NSString stringWithFormat:@"%@-sparkle-updater", hostBundleIdentifier];
|
||||
|
||||
// Try to remove the job from launchd if it is already running
|
||||
// We could invoke SMJobCopyDictionary() first to see if the job exists, but I'd rather avoid
|
||||
// using it because the headers indicate it may be removed one day without any replacement
|
||||
CFErrorRef removeError = NULL;
|
||||
if (!SMJobRemove(domain, (__bridge CFStringRef)(label), auth, true, &removeError)) {
|
||||
if (removeError != NULL) {
|
||||
// It's normal for a job to not be found, so this is not an interesting error
|
||||
if (CFErrorGetCode(removeError) != kSMErrorJobNotFound) {
|
||||
SULog(@"Remove error: %@", removeError);
|
||||
}
|
||||
CFRelease(removeError);
|
||||
}
|
||||
}
|
||||
|
||||
NSDictionary *jobDictionary = @{@"Label" : label, @"ProgramArguments" : arguments, @"EnableTransactions" : @NO, @"KeepAlive" : @{@"SuccessfulExit" : @NO}, @"RunAtLoad" : @NO, @"NICE" : @0, @"LaunchOnlyOnce": @YES, @"MachServices" : @{SUInstallerServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES, SUStatusInfoServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES, SUProgressAgentServiceNameForBundleIdentifier(hostBundleIdentifier) : @YES}};
|
||||
|
||||
CFErrorRef submitError = NULL;
|
||||
submittedJob = SMJobSubmit(domain, (__bridge CFDictionaryRef)(jobDictionary), auth, &submitError);
|
||||
if (!submittedJob) {
|
||||
if (submitError != NULL) {
|
||||
SULog(@"Submit error: %@", submitError);
|
||||
CFRelease(submitError);
|
||||
}
|
||||
}
|
||||
|
||||
AuthorizationFree(auth, kAuthorizationFlagDefaults);
|
||||
}
|
||||
|
||||
SUAuthorizationReply reply;
|
||||
if (submittedJob == true) {
|
||||
reply = SUAuthorizationReplySuccess;
|
||||
} else if (canceledAuthorization) {
|
||||
reply = SUAuthorizationReplyCancelled;
|
||||
} else {
|
||||
reply = SUAuthorizationReplyFailure;
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -28,8 +28,7 @@
|
||||
|
||||
- (void)setServiceName:(NSString *)serviceName
|
||||
{
|
||||
NSXPCConnectionOptions options = SUGrantsSystemAuthorizationAccess() ? NSXPCConnectionPrivileged : 0;
|
||||
NSXPCConnection *connection = [[NSXPCConnection alloc] initWithMachServiceName:serviceName options:options];
|
||||
NSXPCConnection *connection = [[NSXPCConnection alloc] initWithMachServiceName:serviceName options:(NSXPCConnectionOptions)0];
|
||||
|
||||
connection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUStatusInfoProtocol)];
|
||||
|
||||
@@ -37,7 +36,7 @@
|
||||
|
||||
__weak SUInstallerStatus *weakSelf = self;
|
||||
self.connection.interruptionHandler = ^{
|
||||
[weakSelf invalidate];
|
||||
[weakSelf.connection invalidate];
|
||||
};
|
||||
|
||||
self.connection.invalidationHandler = ^{
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
1420DF50196247F900203BB0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1420DF4F196247F900203BB0 /* Images.xcassets */; };
|
||||
1420DF51196247F900203BB0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1420DF4F196247F900203BB0 /* Images.xcassets */; };
|
||||
142E0E0019A6954400E4312B /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
142E0E0219A6A14700E4312B /* Sparkle.framework in Copy Files */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
142E0E0419A6A26F00E4312B /* Autoupdate.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 55C14BB7136EEF1500649790 /* Autoupdate.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
@@ -44,7 +43,6 @@
|
||||
1495006E195FCE1100BC5B5B /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
|
||||
1495006F195FCE1800BC5B5B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
|
||||
14950070195FCE3A00BC5B5B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
|
||||
14950071195FCE3D00BC5B5B /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
|
||||
14950072195FCE4B00BC5B5B /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
|
||||
14950073195FCE4E00BC5B5B /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
|
||||
14958C6E19AEBC950061B14F /* signed-test-file.txt in Resources */ = {isa = PBXBuildFile; fileRef = 14958C6B19AEBC530061B14F /* signed-test-file.txt */; };
|
||||
@@ -120,15 +118,14 @@
|
||||
61EF67590E25C5B400F754E0 /* SUHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 61EF67580E25C5B400F754E0 /* SUHost.h */; };
|
||||
61FA52880E2D9EA400EF58AD /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (Required, ); }; };
|
||||
720B16451C66433D006985FB /* SUTestApplicationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 720B16431C66433D006985FB /* SUTestApplicationTest.swift */; };
|
||||
720E21781D0CED2B003A311C /* SUFileOperationConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 72E641A61D090F51000404CA /* SUFileOperationConstants.m */; };
|
||||
720E217B1D0D00BF003A311C /* SUUpdaterCycle.h in Headers */ = {isa = PBXBuildFile; fileRef = 720E21791D0D00BF003A311C /* SUUpdaterCycle.h */; };
|
||||
720E217C1D0D00BF003A311C /* SUUpdaterCycle.m in Sources */ = {isa = PBXBuildFile; fileRef = 720E217A1D0D00BF003A311C /* SUUpdaterCycle.m */; };
|
||||
7210C7681B9A9A1500EB90AC /* SUUnarchiverTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */; };
|
||||
72162B061C82C8B30013C1C5 /* SUParameterAssert.h in Headers */ = {isa = PBXBuildFile; fileRef = 72162B051C82C8B30013C1C5 /* SUParameterAssert.h */; };
|
||||
72162B081C82C9600013C1C5 /* SULocalizations.h in Headers */ = {isa = PBXBuildFile; fileRef = 72162B071C82C9600013C1C5 /* SULocalizations.h */; };
|
||||
721BC2031D17A4FC002BC71E /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B5F8F609C4CEB300B25A18 /* Security.framework */; };
|
||||
721BC2041D17A51B002BC71E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
|
||||
721BC20B1D17A5AD002BC71E /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 721BC20A1D17A5AD002BC71E /* CoreServices.framework */; };
|
||||
721652611D3C437E00FD13D8 /* SUSubmitInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 722194771D3C4251004C34FF /* SUSubmitInstaller.m */; };
|
||||
721652621D3C44A100FD13D8 /* SUSystemAuthorization.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3AC1D347EDE005D534A /* SUSystemAuthorization.m */; };
|
||||
721652651D3C744700FD13D8 /* InstallerProgressLauncher.m in Sources */ = {isa = PBXBuildFile; fileRef = 721652641D3C744700FD13D8 /* InstallerProgressLauncher.m */; };
|
||||
721BC20E1D1CDE55002BC71E /* SULocalCacheDirectory.h in Headers */ = {isa = PBXBuildFile; fileRef = 721BC20C1D1CDE55002BC71E /* SULocalCacheDirectory.h */; };
|
||||
721BC20F1D1CDE55002BC71E /* SULocalCacheDirectory.m in Sources */ = {isa = PBXBuildFile; fileRef = 721BC20D1D1CDE55002BC71E /* SULocalCacheDirectory.m */; };
|
||||
721BC2101D1CDE55002BC71E /* SULocalCacheDirectory.m in Sources */ = {isa = PBXBuildFile; fileRef = 721BC20D1D1CDE55002BC71E /* SULocalCacheDirectory.m */; };
|
||||
@@ -144,6 +141,11 @@
|
||||
721CF1A91AD7644C00D9AC09 /* sais.c in Sources */ = {isa = PBXBuildFile; fileRef = 7223E7611AD1AEFF008E3161 /* sais.c */; settings = {COMPILER_FLAGS = "-w"; }; };
|
||||
721CF1AA1AD7647000D9AC09 /* libxar.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5890FD7678C0065DB48 /* libxar.1.dylib */; };
|
||||
721CF1AB1AD764EB00D9AC09 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D06E8FB0FD68D61005AE3F6 /* libbz2.dylib */; };
|
||||
722194551D3C0135004C34FF /* AgentConnection.m in Sources */ = {isa = PBXBuildFile; fileRef = 722194541D3C0135004C34FF /* AgentConnection.m */; };
|
||||
722194791D3C4251004C34FF /* SUSubmitInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 722194771D3C4251004C34FF /* SUSubmitInstaller.m */; };
|
||||
7221947A1D3C42EA004C34FF /* ServiceManagement.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 724BB3B51D35AAC3005D534A /* ServiceManagement.framework */; };
|
||||
7221947B1D3C42F7004C34FF /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; };
|
||||
7221947D1D3C433C004C34FF /* SUSubmitInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 722194771D3C4251004C34FF /* SUSubmitInstaller.m */; };
|
||||
7223E7631AD1AEFF008E3161 /* sais.c in Sources */ = {isa = PBXBuildFile; fileRef = 7223E7611AD1AEFF008E3161 /* sais.c */; };
|
||||
7229E1B61C97C91100CB50D0 /* SUUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 7229E1B51C97C91100CB50D0 /* SUUpdateDriver.h */; };
|
||||
7229E1B91C97CC4D00CB50D0 /* SUScheduledUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 7229E1B71C97CC4D00CB50D0 /* SUScheduledUpdateDriver.h */; };
|
||||
@@ -177,8 +179,6 @@
|
||||
724BB3B01D3482BA005D534A /* SUSystemAuthorization.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3AC1D347EDE005D534A /* SUSystemAuthorization.m */; };
|
||||
724BB3B11D3484B2005D534A /* SUSystemAuthorization.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3AC1D347EDE005D534A /* SUSystemAuthorization.m */; };
|
||||
724BB3B21D34862A005D534A /* SUSystemAuthorization.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3AC1D347EDE005D534A /* SUSystemAuthorization.m */; };
|
||||
724BB3B31D35A6E6005D534A /* SUInstallerStatus.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3971D333832005D534A /* SUInstallerStatus.m */; };
|
||||
724BB3B41D35AA44005D534A /* SUSystemAuthorization.m in Sources */ = {isa = PBXBuildFile; fileRef = 724BB3AC1D347EDE005D534A /* SUSystemAuthorization.m */; };
|
||||
724BB3B71D35ABA8005D534A /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B5F8F609C4CEB300B25A18 /* Security.framework */; };
|
||||
725602D51C83551C00DAA70E /* SUApplicationInfo.h in Headers */ = {isa = PBXBuildFile; fileRef = 725602D31C83551C00DAA70E /* SUApplicationInfo.h */; };
|
||||
725602D61C83551C00DAA70E /* SUApplicationInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 725602D41C83551C00DAA70E /* SUApplicationInfo.m */; };
|
||||
@@ -279,7 +279,7 @@
|
||||
72B144501CF8826900B971EE /* SUAuthorizationEnvironment.h in Headers */ = {isa = PBXBuildFile; fileRef = 72B1444E1CF8826900B971EE /* SUAuthorizationEnvironment.h */; };
|
||||
72B144511CF8826900B971EE /* SUAuthorizationEnvironment.m in Sources */ = {isa = PBXBuildFile; fileRef = 72B1444F1CF8826900B971EE /* SUAuthorizationEnvironment.m */; };
|
||||
72B144521CF8826900B971EE /* SUAuthorizationEnvironment.m in Sources */ = {isa = PBXBuildFile; fileRef = 72B1444F1CF8826900B971EE /* SUAuthorizationEnvironment.m */; };
|
||||
72B144531CF8992200B971EE /* SUApplicationInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 725602D41C83551C00DAA70E /* SUApplicationInfo.m */; };
|
||||
72B52A1E1D3CA4560085AC99 /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 721BC20A1D17A5AD002BC71E /* CoreServices.framework */; };
|
||||
72B767CA1C9B707000A07552 /* SUAppcastDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 72B767C81C9B707000A07552 /* SUAppcastDriver.h */; };
|
||||
72B767CB1C9B707000A07552 /* SUAppcastDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 72B767C91C9B707000A07552 /* SUAppcastDriver.m */; };
|
||||
72B767CE1C9B924900A07552 /* SUInstallerDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 72B767CC1C9B924900A07552 /* SUInstallerDriver.h */; };
|
||||
@@ -315,15 +315,6 @@
|
||||
72E45CFC1B641961005C701A /* sparkletestcast.xml in Resources */ = {isa = PBXBuildFile; fileRef = 72E45CFB1B641961005C701A /* sparkletestcast.xml */; };
|
||||
72E45CFE1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem in Resources */ = {isa = PBXBuildFile; fileRef = 72E45CFD1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem */; };
|
||||
72E45DDD1B65C3BD005C701A /* sign_update in Resources */ = {isa = PBXBuildFile; fileRef = 72E45DDC1B65C3BD005C701A /* sign_update */; };
|
||||
72E641A71D090F51000404CA /* fileop.m in Sources */ = {isa = PBXBuildFile; fileRef = 72E641A41D090F51000404CA /* fileop.m */; };
|
||||
72E641A81D090F51000404CA /* SUFileOperationConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 72E641A61D090F51000404CA /* SUFileOperationConstants.m */; };
|
||||
72E641AB1D090F6E000404CA /* SUFileOperationConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 72E641A61D090F51000404CA /* SUFileOperationConstants.m */; };
|
||||
72E641AC1D090F7F000404CA /* SUFileOperationConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 72E641A61D090F51000404CA /* SUFileOperationConstants.m */; };
|
||||
72E641AF1D090F9E000404CA /* fileop in Resources */ = {isa = PBXBuildFile; fileRef = 72E6419B1D090F1C000404CA /* fileop */; };
|
||||
72E641B11D091781000404CA /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; };
|
||||
72E641B21D091789000404CA /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; };
|
||||
72E641B31D0918E4000404CA /* SUFileOperationConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 72E641A61D090F51000404CA /* SUFileOperationConstants.m */; };
|
||||
72E641B51D091A15000404CA /* fileop in Copy Executables */ = {isa = PBXBuildFile; fileRef = 72E6419B1D090F1C000404CA /* fileop */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
|
||||
72EB87EA1CB8798800C37F42 /* ShowInstallerProgress.m in Sources */ = {isa = PBXBuildFile; fileRef = 72EB87E91CB8798800C37F42 /* ShowInstallerProgress.m */; };
|
||||
72EB87EB1CB8859100C37F42 /* Updater.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 721C24451CB753E6005440CB /* Updater.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
|
||||
72EB87EC1CB8887E00C37F42 /* SUStatus.xib in Resources */ = {isa = PBXBuildFile; fileRef = 55C14BD8136EF00C00649790 /* SUStatus.xib */; };
|
||||
@@ -468,20 +459,6 @@
|
||||
remoteGlobalIDString = 721C24441CB753E6005440CB;
|
||||
remoteInfo = "Installer Progress";
|
||||
};
|
||||
72E641A91D090F63000404CA /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 72E6419A1D090F1C000404CA;
|
||||
remoteInfo = fileop;
|
||||
};
|
||||
72E641AD1D090F98000404CA /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 72E6419A1D090F1C000404CA;
|
||||
remoteInfo = fileop;
|
||||
};
|
||||
72F94F611CC48669002DEE68 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
|
||||
@@ -587,26 +564,6 @@
|
||||
name = "Copy Sparkle";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
72E641991D090F1C000404CA /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = /usr/share/man/man1/;
|
||||
dstSubfolderSpec = 0;
|
||||
files = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 1;
|
||||
};
|
||||
72E641B41D091A0A000404CA /* Copy Executables */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 6;
|
||||
files = (
|
||||
72E641B51D091A15000404CA /* fileop in Copy Executables */,
|
||||
);
|
||||
name = "Copy Executables";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -841,6 +798,10 @@
|
||||
7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUUnarchiverTest.swift; sourceTree = "<group>"; };
|
||||
72162B051C82C8B30013C1C5 /* SUParameterAssert.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUParameterAssert.h; sourceTree = "<group>"; };
|
||||
72162B071C82C9600013C1C5 /* SULocalizations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SULocalizations.h; sourceTree = "<group>"; };
|
||||
721652631D3C744700FD13D8 /* InstallerProgressLauncher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InstallerProgressLauncher.h; path = InstallerLauncher/InstallerProgressLauncher.h; sourceTree = SOURCE_ROOT; };
|
||||
721652641D3C744700FD13D8 /* InstallerProgressLauncher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = InstallerProgressLauncher.m; path = InstallerLauncher/InstallerProgressLauncher.m; sourceTree = SOURCE_ROOT; };
|
||||
721652661D3C76E500FD13D8 /* SUInstallerProgressLauncherProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SUInstallerProgressLauncherProtocol.h; path = InstallerLauncher/SUInstallerProgressLauncherProtocol.h; sourceTree = SOURCE_ROOT; };
|
||||
721652671D3C8FED00FD13D8 /* SUAuthorizationReply.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SUAuthorizationReply.h; path = InstallerLauncher/SUAuthorizationReply.h; sourceTree = SOURCE_ROOT; };
|
||||
721BC2061D17A532002BC71E /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
|
||||
721BC2081D17A553002BC71E /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
|
||||
721BC20A1D17A5AD002BC71E /* CoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreServices.framework; path = System/Library/Frameworks/CoreServices.framework; sourceTree = SDKROOT; };
|
||||
@@ -849,6 +810,12 @@
|
||||
721C24451CB753E6005440CB /* Updater.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Updater.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
721C24571CB754E8005440CB /* ConfigInstallerProgress.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigInstallerProgress.xcconfig; sourceTree = "<group>"; };
|
||||
721C24581CB7567D005440CB /* InstallerProgress-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "InstallerProgress-Info.plist"; path = "Sparkle/InstallerProgress/InstallerProgress-Info.plist"; sourceTree = SOURCE_ROOT; };
|
||||
722194511D3BF987004C34FF /* SUInstallerAgentProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SUInstallerAgentProtocol.h; path = Sparkle/InstallerProgress/SUInstallerAgentProtocol.h; sourceTree = SOURCE_ROOT; };
|
||||
722194521D3BFEB7004C34FF /* SUInstallerAgentInitiationProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SUInstallerAgentInitiationProtocol.h; path = Sparkle/InstallerProgress/SUInstallerAgentInitiationProtocol.h; sourceTree = SOURCE_ROOT; };
|
||||
722194531D3C0135004C34FF /* AgentConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AgentConnection.h; sourceTree = "<group>"; };
|
||||
722194541D3C0135004C34FF /* AgentConnection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AgentConnection.m; sourceTree = "<group>"; };
|
||||
722194761D3C4251004C34FF /* SUSubmitInstaller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUSubmitInstaller.h; sourceTree = "<group>"; };
|
||||
722194771D3C4251004C34FF /* SUSubmitInstaller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUSubmitInstaller.m; sourceTree = "<group>"; };
|
||||
7223E7611AD1AEFF008E3161 /* sais.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sais.c; sourceTree = "<group>"; };
|
||||
7223E7621AD1AEFF008E3161 /* sais.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sais.h; sourceTree = "<group>"; };
|
||||
7229E1B51C97C91100CB50D0 /* SUUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdateDriver.h; sourceTree = "<group>"; };
|
||||
@@ -1006,7 +973,7 @@
|
||||
72D954801CBACC35006F28BD /* InstallerProgressAppController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = InstallerProgressAppController.m; path = Sparkle/InstallerProgress/InstallerProgressAppController.m; sourceTree = SOURCE_ROOT; };
|
||||
72D954821CBAD34F006F28BD /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = Sparkle/InstallerProgress/main.m; sourceTree = SOURCE_ROOT; };
|
||||
72D954841CBAD418006F28BD /* ShowInstallerProgress.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ShowInstallerProgress.h; path = Sparkle/InstallerProgress/ShowInstallerProgress.h; sourceTree = SOURCE_ROOT; };
|
||||
72D954851CBAD4AE006F28BD /* InstallerProgressAppControllerDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InstallerProgressAppControllerDelegate.h; path = Sparkle/InstallerProgress/InstallerProgressAppControllerDelegate.h; sourceTree = SOURCE_ROOT; };
|
||||
72D954851CBAD4AE006F28BD /* InstallerProgressDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = InstallerProgressDelegate.h; path = Sparkle/InstallerProgress/InstallerProgressDelegate.h; sourceTree = SOURCE_ROOT; };
|
||||
72D9549E1CBB415B006F28BD /* sparkle.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = sparkle.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
72D954A01CBB415C006F28BD /* SUCommandLineDriver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SUCommandLineDriver.h; sourceTree = "<group>"; };
|
||||
72D954A11CBB415C006F28BD /* SUCommandLineDriver.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SUCommandLineDriver.m; sourceTree = "<group>"; };
|
||||
@@ -1023,11 +990,6 @@
|
||||
72E45CFB1B641961005C701A /* sparkletestcast.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = sparkletestcast.xml; sourceTree = "<group>"; };
|
||||
72E45CFD1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = test_app_only_dsa_priv_dont_ever_do_this_for_real.pem; sourceTree = "<group>"; };
|
||||
72E45DDC1B65C3BD005C701A /* sign_update */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = sign_update; path = bin/sign_update; sourceTree = SOURCE_ROOT; };
|
||||
72E6419B1D090F1C000404CA /* fileop */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = fileop; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
72E641A41D090F51000404CA /* fileop.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = fileop.m; sourceTree = "<group>"; };
|
||||
72E641A51D090F51000404CA /* SUFileOperationConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUFileOperationConstants.h; sourceTree = "<group>"; };
|
||||
72E641A61D090F51000404CA /* SUFileOperationConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUFileOperationConstants.m; sourceTree = "<group>"; };
|
||||
72E641B01D09119F000404CA /* ConfigFileop.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigFileop.xcconfig; sourceTree = "<group>"; };
|
||||
72EB87E91CB8798800C37F42 /* ShowInstallerProgress.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ShowInstallerProgress.m; path = Sparkle/InstallerProgress/ShowInstallerProgress.m; sourceTree = SOURCE_ROOT; };
|
||||
72F94EB01CC2A865002DEE68 /* ConfigCommonReleaseHTTP.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigCommonReleaseHTTP.xcconfig; sourceTree = "<group>"; };
|
||||
72F94ED31CC33F1E002DEE68 /* set-ats-exceptions.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "set-ats-exceptions.sh"; sourceTree = "<group>"; };
|
||||
@@ -1066,8 +1028,8 @@
|
||||
files = (
|
||||
726E076B1CA616B3001A286B /* libbz2.tbd in Frameworks */,
|
||||
726E07691CA616A4001A286B /* libxar.tbd in Frameworks */,
|
||||
14950071195FCE3D00BC5B5B /* AppKit.framework in Frameworks */,
|
||||
14950070195FCE3A00BC5B5B /* Foundation.framework in Frameworks */,
|
||||
72B52A1E1D3CA4560085AC99 /* CoreServices.framework in Frameworks */,
|
||||
55C14F9A136F045400649790 /* Security.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -1112,6 +1074,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7221947A1D3C42EA004C34FF /* ServiceManagement.framework in Frameworks */,
|
||||
724BB3B71D35ABA8005D534A /* Security.framework in Frameworks */,
|
||||
721C245A1CB75756005440CB /* Cocoa.framework in Frameworks */,
|
||||
);
|
||||
@@ -1175,16 +1138,6 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
72E641981D090F1C000404CA /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
721BC20B1D17A5AD002BC71E /* CoreServices.framework in Frameworks */,
|
||||
721BC2041D17A51B002BC71E /* Foundation.framework in Frameworks */,
|
||||
721BC2031D17A4FC002BC71E /* Security.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
8DC2EF560486A6940098B216 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -1215,7 +1168,6 @@
|
||||
728638F31CAF5A5F00783084 /* SparkleTemporaryDownloader.xpc */,
|
||||
721C24451CB753E6005440CB /* Updater.app */,
|
||||
72D9549E1CBB415B006F28BD /* sparkle.app */,
|
||||
72E6419B1D090F1C000404CA /* fileop */,
|
||||
724BB36C1D31D0B7005D534A /* SparkleInstallerConnection.xpc */,
|
||||
724BB3931D333832005D534A /* SparkleInstallerStatus.xpc */,
|
||||
);
|
||||
@@ -1373,7 +1325,6 @@
|
||||
55C14BD5136EEFD000649790 /* Autoupdate */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
72E6419C1D090F1C000404CA /* fileop */,
|
||||
61CFB2C10E384958007A1735 /* Verifiers */,
|
||||
6101354A0DD25B7F0049ACDF /* Unarchiving */,
|
||||
618FA6DB0DB485440026945C /* Installation */,
|
||||
@@ -1383,6 +1334,8 @@
|
||||
729746221C8E8F1100FC134E /* AppInstaller.m */,
|
||||
724BB38B1D33283C005D534A /* StatusInfo.h */,
|
||||
724BB38C1D33283C005D534A /* StatusInfo.m */,
|
||||
722194531D3C0135004C34FF /* AgentConnection.h */,
|
||||
722194541D3C0135004C34FF /* AgentConnection.m */,
|
||||
7297461E1C8E8D9A00FC134E /* TerminationListener.h */,
|
||||
7297461F1C8E8D9A00FC134E /* TerminationListener.m */,
|
||||
726E075E1CA4E9A5001A286B /* SUInstallationInputData.h */,
|
||||
@@ -1612,9 +1565,15 @@
|
||||
721C24461CB753E6005440CB /* Installer Progress */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
72D954851CBAD4AE006F28BD /* InstallerProgressAppControllerDelegate.h */,
|
||||
72D954851CBAD4AE006F28BD /* InstallerProgressDelegate.h */,
|
||||
722194511D3BF987004C34FF /* SUInstallerAgentProtocol.h */,
|
||||
722194521D3BFEB7004C34FF /* SUInstallerAgentInitiationProtocol.h */,
|
||||
72D9547F1CBACC35006F28BD /* InstallerProgressAppController.h */,
|
||||
72D954801CBACC35006F28BD /* InstallerProgressAppController.m */,
|
||||
721652671D3C8FED00FD13D8 /* SUAuthorizationReply.h */,
|
||||
721652661D3C76E500FD13D8 /* SUInstallerProgressLauncherProtocol.h */,
|
||||
721652631D3C744700FD13D8 /* InstallerProgressLauncher.h */,
|
||||
721652641D3C744700FD13D8 /* InstallerProgressLauncher.m */,
|
||||
72D954841CBAD418006F28BD /* ShowInstallerProgress.h */,
|
||||
72EB87E91CB8798800C37F42 /* ShowInstallerProgress.m */,
|
||||
72D954821CBAD34F006F28BD /* main.m */,
|
||||
@@ -1690,6 +1649,8 @@
|
||||
726E07AF1CAF08D6001A286B /* SUInstallerLauncherProtocol.h */,
|
||||
726E07B01CAF08D6001A286B /* SUInstallerLauncher.h */,
|
||||
726E07B11CAF08D6001A286B /* SUInstallerLauncher.m */,
|
||||
722194761D3C4251004C34FF /* SUSubmitInstaller.h */,
|
||||
722194771D3C4251004C34FF /* SUSubmitInstaller.m */,
|
||||
726E07B31CAF08D6001A286B /* main.m */,
|
||||
726E07B51CAF08D6001A286B /* Info.plist */,
|
||||
);
|
||||
@@ -1784,17 +1745,6 @@
|
||||
path = "sparkle-cli";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
72E6419C1D090F1C000404CA /* fileop */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
72E641A41D090F51000404CA /* fileop.m */,
|
||||
72E641A51D090F51000404CA /* SUFileOperationConstants.h */,
|
||||
72E641A61D090F51000404CA /* SUFileOperationConstants.m */,
|
||||
);
|
||||
name = fileop;
|
||||
path = ../../fileop;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
72F94F551CC43D99002DEE68 /* XPC Services */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -1822,7 +1772,6 @@
|
||||
FA1941D10D94A70100DD942E /* ConfigFramework.xcconfig */,
|
||||
FA1941CA0D94A70100DD942E /* ConfigFrameworkDebug.xcconfig */,
|
||||
FA1941CE0D94A70100DD942E /* ConfigRelaunch.xcconfig */,
|
||||
72E641B01D09119F000404CA /* ConfigFileop.xcconfig */,
|
||||
721C24571CB754E8005440CB /* ConfigInstallerProgress.xcconfig */,
|
||||
FA1941CD0D94A70100DD942E /* ConfigTestApp.xcconfig */,
|
||||
72F94EDA1CC36C37002DEE68 /* ConfigTestAppDebug.xcconfig */,
|
||||
@@ -1972,16 +1921,12 @@
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 55C14BBE136EEF1500649790 /* Build configuration list for PBXNativeTarget "Autoupdate" */;
|
||||
buildPhases = (
|
||||
55C14BB3136EEF1500649790 /* Resources */,
|
||||
55C14BB4136EEF1500649790 /* Sources */,
|
||||
55C14BB5136EEF1500649790 /* Frameworks */,
|
||||
14652F7B19A945D600959E44 /* Run Script: Set Git Version Info */,
|
||||
72E641B41D091A0A000404CA /* Copy Executables */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
72E641AA1D090F63000404CA /* PBXTargetDependency */,
|
||||
);
|
||||
name = Autoupdate;
|
||||
productName = Autoupdate;
|
||||
@@ -2016,7 +1961,6 @@
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
72E641AE1D090F98000404CA /* PBXTargetDependency */,
|
||||
61FA528D0E2D9EB200EF58AD /* PBXTargetDependency */,
|
||||
);
|
||||
name = "Sparkle Unit Tests";
|
||||
@@ -2208,23 +2152,6 @@
|
||||
productReference = 72D9549E1CBB415B006F28BD /* sparkle.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
72E6419A1D090F1C000404CA /* fileop */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 72E6419F1D090F1C000404CA /* Build configuration list for PBXNativeTarget "fileop" */;
|
||||
buildPhases = (
|
||||
72E641971D090F1C000404CA /* Sources */,
|
||||
72E641981D090F1C000404CA /* Frameworks */,
|
||||
72E641991D090F1C000404CA /* CopyFiles */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = fileop;
|
||||
productName = fileop;
|
||||
productReference = 72E6419B1D090F1C000404CA /* fileop */;
|
||||
productType = "com.apple.product-type.tool";
|
||||
};
|
||||
8DC2EF4F0486A6940098B216 /* Sparkle */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 1DEB91AD08733DA50010E9CD /* Build configuration list for PBXNativeTarget "Sparkle" */;
|
||||
@@ -2314,9 +2241,6 @@
|
||||
72D9549D1CBB415B006F28BD = {
|
||||
CreatedOnToolsVersion = 7.3;
|
||||
};
|
||||
72E6419A1D090F1C000404CA = {
|
||||
CreatedOnToolsVersion = 7.3.1;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "Sparkle" */;
|
||||
@@ -2394,7 +2318,6 @@
|
||||
1420DF491962329200203BB0 /* Documentation */,
|
||||
1495005F195FB89400BC5B5B /* All */,
|
||||
726B2B5C1C645FC900388755 /* UI Tests */,
|
||||
72E6419A1D090F1C000404CA /* fileop */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
@@ -2404,7 +2327,6 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
72E641AF1D090F9E000404CA /* fileop in Resources */,
|
||||
14958C6E19AEBC950061B14F /* signed-test-file.txt in Resources */,
|
||||
5F1510A21C96E591006E1629 /* testnamespaces.xml in Resources */,
|
||||
72AC6B2E1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg in Resources */,
|
||||
@@ -2420,14 +2342,6 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
55C14BB3136EEF1500649790 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
1420DF51196247F900203BB0 /* Images.xcassets in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
61B5F8FE09C4CEE200B25A18 /* Resources */ = {
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
@@ -2525,21 +2439,6 @@
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
14652F7B19A945D600959E44 /* Run Script: Set Git Version Info */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Run Script: Set Git Version Info";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"$SRCROOT/Configurations/set-git-version-info.sh\"";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
6131B1910DDCDE32005215F0 /* Run Script: Set Git Version Info */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 12;
|
||||
@@ -2622,8 +2521,7 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
72E641AB1D090F6E000404CA /* SUFileOperationConstants.m in Sources */,
|
||||
72B144531CF8992200B971EE /* SUApplicationInfo.m in Sources */,
|
||||
722194551D3C0135004C34FF /* AgentConnection.m in Sources */,
|
||||
72B09CEE1CEA21CD0052EF9E /* bscommon.c in Sources */,
|
||||
72D9547E1CBA221E006F28BD /* SUAppcastItem.m in Sources */,
|
||||
72B144521CF8826900B971EE /* SUAuthorizationEnvironment.m in Sources */,
|
||||
@@ -2672,7 +2570,6 @@
|
||||
726F2CE81BC9C48F001971A4 /* SUConstants.m in Sources */,
|
||||
726F2CDE1BC9BE5B001971A4 /* SUFileManager.m in Sources */,
|
||||
726F2CE91BC9C499001971A4 /* SUOperatingSystem.m in Sources */,
|
||||
720E21781D0CED2B003A311C /* SUFileOperationConstants.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -2729,14 +2626,16 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
724BB3B41D35AA44005D534A /* SUSystemAuthorization.m in Sources */,
|
||||
724BB3B31D35A6E6005D534A /* SUInstallerStatus.m in Sources */,
|
||||
721652621D3C44A100FD13D8 /* SUSystemAuthorization.m in Sources */,
|
||||
7221947B1D3C42F7004C34FF /* SUFileManager.m in Sources */,
|
||||
72D954831CBAD34F006F28BD /* main.m in Sources */,
|
||||
721C24621CB75C68005440CB /* SULog.m in Sources */,
|
||||
72D954811CBACC35006F28BD /* InstallerProgressAppController.m in Sources */,
|
||||
72EB87EA1CB8798800C37F42 /* ShowInstallerProgress.m in Sources */,
|
||||
721C24611CB75C5D005440CB /* SUHost.m in Sources */,
|
||||
721652651D3C744700FD13D8 /* InstallerProgressLauncher.m in Sources */,
|
||||
721C245F1CB75A6B005440CB /* SUMessageTypes.m in Sources */,
|
||||
722194791D3C4251004C34FF /* SUSubmitInstaller.m in Sources */,
|
||||
721C245E1CB757DE005440CB /* SUConstants.m in Sources */,
|
||||
721C245D1CB757C4005440CB /* SUApplicationInfo.m in Sources */,
|
||||
721C245C1CB7576E005440CB /* SUStatusController.m in Sources */,
|
||||
@@ -2775,9 +2674,9 @@
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
721652611D3C437E00FD13D8 /* SUSubmitInstaller.m in Sources */,
|
||||
724BB3AF1D34828A005D534A /* SUSystemAuthorization.m in Sources */,
|
||||
724BB3671D30B2C5005D534A /* SUMessageTypes.m in Sources */,
|
||||
72E641B31D0918E4000404CA /* SUFileOperationConstants.m in Sources */,
|
||||
726E07C01CAF15B7001A286B /* SULog.m in Sources */,
|
||||
726E07BF1CAF0C6C001A286B /* SUConstants.m in Sources */,
|
||||
726E07BE1CAF0C5C001A286B /* SUFileManager.m in Sources */,
|
||||
@@ -2828,25 +2727,14 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
72E641971D090F1C000404CA /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
72E641B21D091789000404CA /* SUConstants.m in Sources */,
|
||||
72E641B11D091781000404CA /* SUFileManager.m in Sources */,
|
||||
72E641A71D090F51000404CA /* fileop.m in Sources */,
|
||||
72E641A81D090F51000404CA /* SUFileOperationConstants.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
8DC2EF540486A6940098B216 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7221947D1D3C433C004C34FF /* SUSubmitInstaller.m in Sources */,
|
||||
724BB3B01D3482BA005D534A /* SUSystemAuthorization.m in Sources */,
|
||||
724BB3AA1D3347C2005D534A /* SUInstallerStatus.m in Sources */,
|
||||
724BB3891D32B915005D534A /* SUInstallerConnection.m in Sources */,
|
||||
72E641AC1D090F7F000404CA /* SUFileOperationConstants.m in Sources */,
|
||||
721BC20F1D1CDE55002BC71E /* SULocalCacheDirectory.m in Sources */,
|
||||
724A0A3E1CF7AF0E00D8C3D5 /* SUTemporaryDownloader.m in Sources */,
|
||||
723B5DAA1CF7AB6A00365F95 /* SUPersistentDownloader.m in Sources */,
|
||||
@@ -2989,16 +2877,6 @@
|
||||
target = 721C24441CB753E6005440CB /* Installer Progress */;
|
||||
targetProxy = 72D954B91CBB6E27006F28BD /* PBXContainerItemProxy */;
|
||||
};
|
||||
72E641AA1D090F63000404CA /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 72E6419A1D090F1C000404CA /* fileop */;
|
||||
targetProxy = 72E641A91D090F63000404CA /* PBXContainerItemProxy */;
|
||||
};
|
||||
72E641AE1D090F98000404CA /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 72E6419A1D090F1C000404CA /* fileop */;
|
||||
targetProxy = 72E641AD1D090F98000404CA /* PBXContainerItemProxy */;
|
||||
};
|
||||
72F94F621CC48669002DEE68 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
target = 726E07AC1CAF08D6001A286B /* SparkleInstallerLauncher */;
|
||||
@@ -3587,38 +3465,6 @@
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
72E641A01D090F1C000404CA /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 72E641B01D09119F000404CA /* ConfigFileop.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
72E641A11D090F1C000404CA /* Coverage */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 72E641B01D09119F000404CA /* ConfigFileop.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
};
|
||||
name = Coverage;
|
||||
};
|
||||
72E641A21D090F1C000404CA /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 72E641B01D09119F000404CA /* ConfigFileop.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
72E641A31D090F1C000404CA /* Release-HTTP */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 72E641B01D09119F000404CA /* ConfigFileop.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_NO_COMMON_BLOCKS = YES;
|
||||
};
|
||||
name = "Release-HTTP";
|
||||
};
|
||||
72F94E9F1CC2A23A002DEE68 /* Release-HTTP */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 72F94EB01CC2A865002DEE68 /* ConfigCommonReleaseHTTP.xcconfig */;
|
||||
@@ -3854,6 +3700,7 @@
|
||||
724BB37C1D31D0B7005D534A /* Release-HTTP */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
724BB39F1D333832005D534A /* Build configuration list for PBXNativeTarget "SparkleInstallerStatus" */ = {
|
||||
isa = XCConfigurationList;
|
||||
@@ -3864,6 +3711,7 @@
|
||||
724BB3A31D333832005D534A /* Release-HTTP */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
726B2B671C645FC900388755 /* Build configuration list for PBXNativeTarget "UI Tests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
@@ -3931,17 +3779,6 @@
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
72E6419F1D090F1C000404CA /* Build configuration list for PBXNativeTarget "fileop" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
72E641A01D090F1C000404CA /* Debug */,
|
||||
72E641A11D090F1C000404CA /* Coverage */,
|
||||
72E641A21D090F1C000404CA /* Release */,
|
||||
72E641A31D090F1C000404CA /* Release-HTTP */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = 0867D690FE84028FC02AAC07 /* Project object */;
|
||||
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// AgentConnection.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 7/17/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol AgentConnectionDelegate <NSObject>
|
||||
|
||||
- (void)agentConnectionDidInitiate;
|
||||
- (void)agentConnectionDidInvalidate;
|
||||
|
||||
@end
|
||||
|
||||
@protocol SUInstallerAgentProtocol;
|
||||
|
||||
@interface AgentConnection : NSObject
|
||||
|
||||
- (instancetype)initWithHostBundleIdentifier:(NSString *)bundleIdentifier delegate:(id<AgentConnectionDelegate>)delegate;
|
||||
|
||||
- (void)startListener;
|
||||
- (void)invalidate;
|
||||
|
||||
@property (nonatomic, readonly, nullable) id<SUInstallerAgentProtocol> agent;
|
||||
@property (nonatomic, readonly) BOOL connected;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Vendored
+109
@@ -0,0 +1,109 @@
|
||||
//
|
||||
// AgentConnection.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 7/17/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "AgentConnection.h"
|
||||
#import "SUMessageTypes.h"
|
||||
#import "SUInstallerAgentProtocol.h"
|
||||
#import "SUInstallerAgentInitiationProtocol.h"
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#error This is a "daemon-safe" class and should NOT import AppKit
|
||||
#endif
|
||||
|
||||
@interface AgentConnection () <NSXPCListenerDelegate, SUInstallerAgentInitiationProtocol>
|
||||
|
||||
@property (nonatomic) NSXPCListener *xpcListener;
|
||||
@property (nonatomic, nullable) NSXPCConnection *activeConnection;
|
||||
@property (nonatomic, nullable) id<SUInstallerAgentProtocol> agent;
|
||||
@property (nonatomic, weak) id<AgentConnectionDelegate> delegate;
|
||||
@property (nonatomic) BOOL connected;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AgentConnection
|
||||
|
||||
@synthesize xpcListener = _xpcListener;
|
||||
@synthesize activeConnection = _activeConnection;
|
||||
@synthesize agent = _agent;
|
||||
@synthesize delegate = _delegate;
|
||||
@synthesize connected = _connected;
|
||||
|
||||
- (instancetype)initWithHostBundleIdentifier:(NSString *)bundleIdentifier delegate:(id<AgentConnectionDelegate>)delegate
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
// Agents should always be the one that connect to daemons due to how mach bootstraps work
|
||||
// For this reason, we are the ones that are creating a listener, not the agent
|
||||
_xpcListener = [[NSXPCListener alloc] initWithMachServiceName:SUProgressAgentServiceNameForBundleIdentifier(bundleIdentifier)];
|
||||
_xpcListener.delegate = self;
|
||||
_delegate = delegate;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)startListener
|
||||
{
|
||||
[self.xpcListener resume];
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
self.delegate = nil;
|
||||
|
||||
[self.activeConnection invalidate];
|
||||
self.activeConnection = nil;
|
||||
|
||||
[self.xpcListener invalidate];
|
||||
self.xpcListener = nil;
|
||||
}
|
||||
|
||||
- (BOOL)listener:(NSXPCListener *)__unused listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection
|
||||
{
|
||||
if (self.activeConnection != nil) {
|
||||
[newConnection invalidate];
|
||||
return NO;
|
||||
}
|
||||
|
||||
newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerAgentInitiationProtocol)];
|
||||
newConnection.exportedObject = self;
|
||||
|
||||
newConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerAgentProtocol)];
|
||||
|
||||
self.activeConnection = newConnection;
|
||||
|
||||
__weak AgentConnection *weakSelf = self;
|
||||
newConnection.interruptionHandler = ^{
|
||||
[weakSelf.activeConnection invalidate];
|
||||
};
|
||||
|
||||
newConnection.invalidationHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[weakSelf.delegate agentConnectionDidInvalidate];
|
||||
});
|
||||
};
|
||||
|
||||
[newConnection resume];
|
||||
|
||||
self.agent = newConnection.remoteObjectProxy;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)connectionDidInitiateWithReply:(void (^)(void))acknowledgement
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.connected = YES;
|
||||
|
||||
[self.delegate agentConnectionDidInitiate];
|
||||
self.delegate = nil;
|
||||
});
|
||||
|
||||
acknowledgement();
|
||||
}
|
||||
|
||||
@end
|
||||
Vendored
+1
-1
@@ -6,7 +6,7 @@
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUUnarchiverProtocol.h"
|
||||
|
||||
@interface AppInstaller : NSObject <SUUnarchiverDelegate>
|
||||
|
||||
Vendored
+79
-101
@@ -23,12 +23,17 @@
|
||||
#import "SUFileManager.h"
|
||||
#import "SUInstallationInfo.h"
|
||||
#import "SUAppcastItem.h"
|
||||
#import "SUAuthorizationEnvironment.h"
|
||||
#import "SUApplicationInfo.h"
|
||||
#import "SUErrors.h"
|
||||
#import "SUInstallerCommunicationProtocol.h"
|
||||
#import "AgentConnection.h"
|
||||
#import "SUInstallerAgentProtocol.h"
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#error This is a "daemon-safe" class and should NOT import AppKit
|
||||
#endif
|
||||
|
||||
#define FIRST_UPDATER_MESSAGE_TIMEOUT 7ull
|
||||
#define RETRIEVE_PROCESS_IDENTIFIER_TIMEOUT 5ull
|
||||
|
||||
/*!
|
||||
* Terminate the application after a delay from launching the new update to avoid OS activation issues
|
||||
@@ -44,12 +49,13 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5;
|
||||
*/
|
||||
static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
@interface AppInstaller () <NSXPCListenerDelegate, SUInstallerCommunicationProtocol>
|
||||
@interface AppInstaller () <NSXPCListenerDelegate, SUInstallerCommunicationProtocol, AgentConnectionDelegate>
|
||||
|
||||
@property (nonatomic) NSXPCListener* xpcListener;
|
||||
@property (nonatomic) NSXPCConnection *activeConnection;
|
||||
@property (nonatomic) id<SUInstallerCommunicationProtocol> communicator;
|
||||
@property (nonatomic) StatusInfo *statusInfo;
|
||||
@property (nonatomic) AgentConnection *agentConnection;
|
||||
@property (nonatomic) BOOL receivedUpdaterPong;
|
||||
|
||||
@property (nonatomic, strong) TerminationListener *terminationListener;
|
||||
@@ -70,6 +76,8 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
@property (nonatomic) BOOL performedStage2Installation;
|
||||
@property (nonatomic) BOOL performedStage3Installation;
|
||||
|
||||
@property (nonatomic) NSUInteger agentConnectionCounter;
|
||||
|
||||
@end
|
||||
|
||||
@implementation AppInstaller
|
||||
@@ -78,6 +86,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
@synthesize activeConnection = _activeConnection;
|
||||
@synthesize communicator = _communicator;
|
||||
@synthesize statusInfo = _statusInfo;
|
||||
@synthesize agentConnection = _agentConnection;
|
||||
@synthesize receivedUpdaterPong = _receivedUpdaterPong;
|
||||
@synthesize hostBundleIdentifier = _hostBundleIdentifier;
|
||||
@synthesize allowsInteraction = _allowsInteraction;
|
||||
@@ -93,6 +102,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
@synthesize performedStage1Installation = _performedStage1Installation;
|
||||
@synthesize performedStage2Installation = _performedStage2Installation;
|
||||
@synthesize performedStage3Installation = _performedStage3Installation;
|
||||
@synthesize agentConnectionCounter = _agentConnectionCounter;
|
||||
|
||||
- (instancetype)initWithHostBundleIdentifier:(NSString *)hostBundleIdentifier allowingInteraction:(BOOL)allowsInteraction
|
||||
{
|
||||
@@ -108,6 +118,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
_xpcListener.delegate = self;
|
||||
|
||||
_statusInfo = [[StatusInfo alloc] initWithHostBundleIdentifier:hostBundleIdentifier];
|
||||
_agentConnection = [[AgentConnection alloc] initWithHostBundleIdentifier:hostBundleIdentifier delegate:self];
|
||||
|
||||
return self;
|
||||
}
|
||||
@@ -159,12 +170,18 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
{
|
||||
[self.xpcListener resume];
|
||||
[self.statusInfo startListener];
|
||||
[self.agentConnection startListener];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(FIRST_UPDATER_MESSAGE_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (!self.receivedInstallationData) {
|
||||
SULog(@"Timeout: installation data was never received");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
}
|
||||
|
||||
if (!self.agentConnection.connected) {
|
||||
SULog(@"Timeout: agent connection was never initiated");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -302,10 +319,50 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
} else {
|
||||
[self.communicator handleMessageWithIdentifier:SUInstallationStartedStage1 data:[NSData data]];
|
||||
|
||||
[self startInstallation];
|
||||
self.agentConnectionCounter++;
|
||||
if (self.agentConnectionCounter == 2) {
|
||||
[self retrieveProcessIdentifierAndStartInstallation];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)agentConnectionDidInitiate
|
||||
{
|
||||
self.agentConnectionCounter++;
|
||||
if (self.agentConnectionCounter == 2) {
|
||||
[self retrieveProcessIdentifierAndStartInstallation];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)agentConnectionDidInvalidate
|
||||
{
|
||||
if (self.agentConnectionCounter < 2) {
|
||||
SULog(@"Error: Agent connection invalidated before installation began");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)retrieveProcessIdentifierAndStartInstallation
|
||||
{
|
||||
// We use the relaunch path for the bundle to listen for termination instead of the host path
|
||||
// For a plug-in this makes a big difference; we want to wait until the app hosting the plug-in terminates
|
||||
// Otherwise for an app, the relaunch path and host path should be identical
|
||||
|
||||
[self.agentConnection.agent registerRelaunchBundlePath:self.installationData.relaunchPath reply:^(NSNumber * _Nullable processIdentifier) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
self.terminationListener = [[TerminationListener alloc] initWithProcessIdentifier:processIdentifier];
|
||||
[self startInstallation];
|
||||
});
|
||||
}];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(RETRIEVE_PROCESS_IDENTIFIER_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (self.terminationListener == nil) {
|
||||
SULog(@"Timeour error: failed to retreive process identifier from agent");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)handleMessageWithIdentifier:(int32_t)identifier data:(NSData *)data
|
||||
{
|
||||
if (identifier == SUInstallationData && self.installationData == nil) {
|
||||
@@ -328,23 +385,14 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
SULog(@"Error: Failed to match host bundle identifiers %@ and %@", self.hostBundleIdentifier, bundleIdentifier);
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
} else {
|
||||
NSBundle *relaunchBundle = [NSBundle bundleWithPath:nonNullInstallationData.relaunchPath];
|
||||
if (relaunchBundle == nil) {
|
||||
SULog(@"Error: Failed to locate relaunch bundle path %@", nonNullInstallationData.relaunchPath);
|
||||
// This will be important later
|
||||
if (nonNullInstallationData.relaunchPath == nil) {
|
||||
SULog(@"Error: Failed to obtain relaunch path from installation data");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
} else {
|
||||
self.host = host;
|
||||
self.installationData = installationData;
|
||||
|
||||
// We use the relaunch path for the bundle to listen for termination instead of the host path
|
||||
// For a plug-in this makes a big difference; we want to wait until the app hosting the plug-in terminates
|
||||
// Otherwise for an app, the relaunch path and host path should be identical
|
||||
|
||||
NSRunningApplication *runningApplication = [SUApplicationInfo runningApplicationWithBundle:host.bundle];
|
||||
NSNumber *processIdentifier = (runningApplication == nil || runningApplication.terminated) ? nil : @(runningApplication.processIdentifier);
|
||||
|
||||
self.terminationListener = [[TerminationListener alloc] initWithProcessIdentifier:processIdentifier];
|
||||
|
||||
[self extractAndInstallUpdate];
|
||||
}
|
||||
}
|
||||
@@ -442,53 +490,8 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
return;
|
||||
}
|
||||
|
||||
SUAuthorizationEnvironment *environment = nil;
|
||||
NSURL *tempIconDirectoryURL = nil;
|
||||
if (self.shouldShowUI && self.allowsInteraction && [self.installer mayNeedToRequestAuthorization]) {
|
||||
NSString *prompt = [NSString stringWithFormat:NSLocalizedString(@"%1$@ wants to update.", nil), self.host.name];
|
||||
|
||||
NSString *iconPath = nil;
|
||||
|
||||
// Authorization API requires a 32x32 icon image and accepts png (but not icns or tiff)
|
||||
NSImage *icon = [SUApplicationInfo bestIconForBundle:self.host.bundle];
|
||||
[icon setSize:NSMakeSize(32, 32)];
|
||||
|
||||
CGImageRef iconRef = [icon CGImageForProposedRect:NULL context:nil hints:nil];
|
||||
NSBitmapImageRep *representation = [[NSBitmapImageRep alloc] initWithCGImage:iconRef];
|
||||
NSData *pngData = [representation representationUsingType:NSPNGFileType properties:@{}];
|
||||
|
||||
// Write the icon to a temporary directory. This icon file should be in a directory that's readable to everyone.
|
||||
NSError *tempError = nil;
|
||||
tempIconDirectoryURL = [[SUFileManager defaultManager] makeTemporaryDirectoryWithPreferredName:@"sparkle-auth-icon" appropriateForDirectoryURL:[NSURL fileURLWithPath:NSTemporaryDirectory()] error:&tempError];
|
||||
if (tempIconDirectoryURL == nil) {
|
||||
SULog(@"Failed to create temporary directory for authorization icon: %@", tempError);
|
||||
} else {
|
||||
NSURL *iconURL = [tempIconDirectoryURL URLByAppendingPathComponent:@"icon.png"];
|
||||
if ([pngData writeToURL:iconURL atomically:YES]) {
|
||||
iconPath = iconURL.path;
|
||||
}
|
||||
}
|
||||
|
||||
environment = [[SUAuthorizationEnvironment alloc] initWithPrompt:prompt iconPath:(iconPath != nil ? iconPath : @"")];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// We should activate our app so that the auth prompt will be active
|
||||
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
|
||||
});
|
||||
}
|
||||
|
||||
NSString *fileOperationToolPath = [[[[NSBundle mainBundle] executablePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@""SPARKLE_FILEOP_TOOL_NAME];
|
||||
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:fileOperationToolPath]) {
|
||||
SULog(@"Potential Installation Error: File operation tool path %@ is not found", fileOperationToolPath);
|
||||
}
|
||||
|
||||
NSError *secondStageError = nil;
|
||||
BOOL performedSecondStage = [self.installer performSecondStageAllowingAuthorization:self.allowsInteraction fileOperationToolPath:fileOperationToolPath environment:environment allowingUI:self.shouldShowUI error:&secondStageError];
|
||||
|
||||
if (tempIconDirectoryURL != nil) {
|
||||
[[SUFileManager defaultManager] removeItemAtURL:tempIconDirectoryURL error:NULL];
|
||||
}
|
||||
BOOL performedSecondStage = [self.installer performSecondStageAllowingUI:self.shouldShowUI error:&secondStageError];
|
||||
|
||||
if (performedSecondStage) {
|
||||
self.performedStage2Installation = YES;
|
||||
@@ -543,37 +546,17 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
[self.communicator handleMessageWithIdentifier:SUUpdaterAlivePing data:[NSData data]];
|
||||
|
||||
// Launch our installer progress UI tool if only after a certain amount of time passes
|
||||
__block NSRunningApplication *installerProgressRunningApplication = nil;
|
||||
__block BOOL shouldLaunchInstallerProgress = YES;
|
||||
|
||||
NSString *progressToolPath = self.installationData.progressToolPath;
|
||||
if (progressToolPath != nil && self.shouldShowUI && ![self.installer displaysUserProgress]) {
|
||||
NSURL *progressToolURL = [NSURL fileURLWithPath:progressToolPath];
|
||||
if (progressToolURL != nil) {
|
||||
NSError *quarantineError = nil;
|
||||
if (![[SUFileManager defaultManager] releaseItemFromQuarantineAtRootURL:progressToolURL error:&quarantineError]) {
|
||||
SULog(@"Error: Failed releasing quarantine from installer progress tool: %@", quarantineError);
|
||||
if (self.shouldShowUI && ![self.installer displaysUserProgress]) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUDisplayProgressTimeDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
// Make sure we're still eligible for showing the installer progress
|
||||
// Also if the updater process is still alive, showing the progress should not be our duty
|
||||
// if the communicator object is nil, the updater definitely isn't alive. However, if it is not nil,
|
||||
// this does not necessarily mean the updater is alive, so we should also check if we got a recent response back from the updater
|
||||
if (shouldLaunchInstallerProgress && (!self.receivedUpdaterPong || self.communicator == nil)) {
|
||||
[self.agentConnection.agent showProgress];
|
||||
}
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUDisplayProgressTimeDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
// Make sure we're still eligible for showing the installer progress
|
||||
// Also if the updater process is still alive, showing the progress should not be our duty
|
||||
// if the communicator object is nil, the updater definitely isn't alive. However, if it is not nil,
|
||||
// this does not necessarily mean the updater is alive, so we should also check if we got a recent response back from the updater
|
||||
if (shouldLaunchInstallerProgress && (!self.receivedUpdaterPong || self.communicator == nil)) {
|
||||
NSError *launchError = nil;
|
||||
|
||||
NSArray *arguments = @[self.host.bundlePath];
|
||||
NSRunningApplication *runningApplication = [[NSWorkspace sharedWorkspace] launchApplicationAtURL:progressToolURL options:(NSWorkspaceLaunchOptions)(NSWorkspaceLaunchDefault | NSWorkspaceLaunchNewInstance) configuration:@{NSWorkspaceLaunchConfigurationArguments : arguments} error:&launchError];
|
||||
|
||||
if (runningApplication == nil) {
|
||||
SULog(@"Failed to launch installer progress tool with error: %@", launchError);
|
||||
} else {
|
||||
installerProgressRunningApplication = runningApplication;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
dispatch_async(self.installerQueue, ^{
|
||||
@@ -601,7 +584,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Make sure to terminate our displayed progress before we move onto cleanup
|
||||
[installerProgressRunningApplication terminate];
|
||||
[self.agentConnection.agent stopProgress];
|
||||
shouldLaunchInstallerProgress = NO;
|
||||
|
||||
[self.communicator handleMessageWithIdentifier:SUInstallationFinishedStage3 data:[NSData data]];
|
||||
@@ -624,7 +607,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
pathToRelaunch = self.installationData.relaunchPath;
|
||||
}
|
||||
|
||||
[self relaunchAtPath:pathToRelaunch];
|
||||
[self.agentConnection.agent relaunchPath:pathToRelaunch];
|
||||
}
|
||||
|
||||
dispatch_async(self.installerQueue, ^{
|
||||
@@ -652,6 +635,9 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
[self.statusInfo invalidate];
|
||||
self.statusInfo = nil;
|
||||
|
||||
[self.agentConnection invalidate];
|
||||
self.agentConnection = nil;
|
||||
|
||||
NSError *theError = nil;
|
||||
if (![[NSFileManager defaultManager] removeItemAtPath:self.installationData.updateDirectoryPath error:&theError]) {
|
||||
SULog(@"Couldn't remove update folder: %@.", theError);
|
||||
@@ -662,12 +648,4 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
exit(status);
|
||||
}
|
||||
|
||||
- (void)relaunchAtPath:(NSString *)relaunchPath
|
||||
{
|
||||
// Don't use -launchApplication: because we may not be launching an application. Eg: it could be a system prefpane
|
||||
if (![[NSWorkspace sharedWorkspace] openFile:relaunchPath]) {
|
||||
SULog(@"Failed to launch %@", relaunchPath);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
+1
-3
@@ -14,17 +14,15 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/*
|
||||
* relaunchPath - path to application bundle to relaunch and listen for termination
|
||||
* progressToolPath - path to optional GUI tool that shows update progress if installation is not quick
|
||||
* hostBundlePath - path to host bundle to update & replace
|
||||
* updateDirectoryPath - path to update directory (i.e, temporary directory containing the new update archive)
|
||||
* downloadName - name of update archive in update directory
|
||||
* dsaSignature - DSA signature for the update that came from the appcast item
|
||||
* decryptionPassword - optional decryption password for dmg archives
|
||||
*/
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath progressToolPath:(nullable NSString *)progressToolPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName dsaSignature:(NSString *)dsaSignature decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName dsaSignature:(NSString *)dsaSignature decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *relaunchPath;
|
||||
@property (nonatomic, copy, readonly, nullable) NSString *progressToolPath;
|
||||
@property (nonatomic, copy, readonly) NSString *hostBundlePath;
|
||||
@property (nonatomic, copy, readonly) NSString *updateDirectoryPath;
|
||||
@property (nonatomic, copy, readonly) NSString *downloadName;
|
||||
|
||||
+6
-10
@@ -8,8 +8,11 @@
|
||||
|
||||
#import "SUInstallationInputData.h"
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#error This is a "daemon-safe" class and should NOT import AppKit
|
||||
#endif
|
||||
|
||||
static NSString *SURelaunchPathKey = @"SURelaunchPath";
|
||||
static NSString *SUProgressToolPathKey = @"SUProgressToolPath";
|
||||
static NSString *SUHostBundlePathKey = @"SUHostBundlePath";
|
||||
static NSString *SUUpdateDirectoryPathKey = @"SUUpdateDirectoryPath";
|
||||
static NSString *SUDownloadNameKey = @"SUDownloadName";
|
||||
@@ -19,19 +22,17 @@ static NSString *SUDecryptionPasswordKey = @"SUDecryptionPassword";
|
||||
@implementation SUInstallationInputData
|
||||
|
||||
@synthesize relaunchPath = _relaunchPath;
|
||||
@synthesize progressToolPath = _progressToolPath;
|
||||
@synthesize hostBundlePath = _hostBundlePath;
|
||||
@synthesize updateDirectoryPath = _updateDirectoryPath;
|
||||
@synthesize downloadName = _downloadName;
|
||||
@synthesize dsaSignature = _dsaSignature;
|
||||
@synthesize decryptionPassword = _decryptionPassword;
|
||||
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath progressToolPath:(nullable NSString *)progressToolPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName dsaSignature:(NSString *)dsaSignature decryptionPassword:(nullable NSString *)decryptionPassword
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadName:(NSString *)downloadName dsaSignature:(NSString *)dsaSignature decryptionPassword:(nullable NSString *)decryptionPassword
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_relaunchPath = [relaunchPath copy];
|
||||
_progressToolPath = [progressToolPath copy];
|
||||
_hostBundlePath = [hostBundlePath copy];
|
||||
_updateDirectoryPath = [updateDirectoryPath copy];
|
||||
_downloadName = [downloadName copy];
|
||||
@@ -48,8 +49,6 @@ static NSString *SUDecryptionPasswordKey = @"SUDecryptionPassword";
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *progressToolPath = [decoder decodeObjectOfClass:[NSString class] forKey:SUProgressToolPathKey];
|
||||
|
||||
NSString *hostBundlePath = [decoder decodeObjectOfClass:[NSString class] forKey:SUHostBundlePathKey];
|
||||
if (hostBundlePath == nil) {
|
||||
return nil;
|
||||
@@ -72,15 +71,12 @@ static NSString *SUDecryptionPasswordKey = @"SUDecryptionPassword";
|
||||
|
||||
NSString *decryptionPassword = [decoder decodeObjectOfClass:[NSString class] forKey:SUDecryptionPasswordKey];
|
||||
|
||||
return [self initWithRelaunchPath:relaunchPath progressToolPath:progressToolPath hostBundlePath:hostBundlePath updateDirectoryPath:updateDirectoryPath downloadName:downloadName dsaSignature:dsaSignature decryptionPassword:decryptionPassword];
|
||||
return [self initWithRelaunchPath:relaunchPath hostBundlePath:hostBundlePath updateDirectoryPath:updateDirectoryPath downloadName:downloadName dsaSignature:dsaSignature decryptionPassword:decryptionPassword];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
{
|
||||
[coder encodeObject:self.relaunchPath forKey:SURelaunchPathKey];
|
||||
if (self.progressToolPath != nil) {
|
||||
[coder encodeObject:self.progressToolPath forKey:SUProgressToolPathKey];
|
||||
}
|
||||
[coder encodeObject:self.hostBundlePath forKey:SUHostBundlePathKey];
|
||||
[coder encodeObject:self.updateDirectoryPath forKey:SUUpdateDirectoryPathKey];
|
||||
[coder encodeObject:self.downloadName forKey:SUDownloadNameKey];
|
||||
|
||||
+1
-5
@@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
// The allowsUI flag indicates whether this and the 3rd stage can show UI or not, possibly affecting whether or not this stage succeeds.
|
||||
// Eg: This may be appropriate for first showing an authorization prompt before the user application is terminated (if the operation succeeds)
|
||||
// Should be able to be called from non-main thread
|
||||
- (BOOL)performSecondStageAllowingAuthorization:(BOOL)allowsAuthorization fileOperationToolPath:(NSString *)fileOperationToolPath environment:(SUAuthorizationEnvironment * _Nullable)authorizationEnvironment allowingUI:(BOOL)allowsUI error:(NSError **)error;
|
||||
- (BOOL)performSecondStageAllowingUI:(BOOL)allowsUI error:(NSError **)error;
|
||||
|
||||
// Stage 3 occurs after the user application has has been terminated. This is where the final installation work can be done.
|
||||
// After this stage is done, the user application will be relaunched.
|
||||
@@ -42,10 +42,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
// Should be thread safe
|
||||
- (BOOL)canInstallSilently;
|
||||
|
||||
// Indicates whether or not this installer may need authorization when performing the second stage of the installation
|
||||
// Should be thread safe
|
||||
- (BOOL)mayNeedToRequestAuthorization;
|
||||
|
||||
// Cleans up work done from any of the previous stages. This should be invoked after stage 3 succeeds,
|
||||
// or after any one of the stages fails.
|
||||
// Should be able to be called from non-main thread
|
||||
|
||||
Vendored
+4
@@ -43,4 +43,8 @@ NSString *SUInstallerServiceNameForBundleIdentifier(NSString *bundleIdentifier);
|
||||
|
||||
NSString *SUStatusInfoServiceNameForBundleIdentifier(NSString *bundleIdentifier);
|
||||
|
||||
NSString *SUProgressAgentServiceNameForBundleIdentifier(NSString *bundleIdentifier);
|
||||
|
||||
NSString *SUProgressAgentLauncherServiceNameForBundleIdentifier(NSString *bundleIdentifier);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Vendored
+12
@@ -15,6 +15,8 @@ NSString *SUAppcastItemArchiveKey = @"SUAppcastItemArchive";
|
||||
// These should be very short because length restrictions exist on earlier versions of macOS
|
||||
#define SPARKLE_INSTALLER_TAG @"-spki"
|
||||
#define SPARKLE_STATUS_TAG @"-spks"
|
||||
#define SPARKLE_PROGRESS_TAG @"-spkp"
|
||||
#define SPARKLE_PROGRESS_LAUNCH_INSTALLER_TAG @"-spkl"
|
||||
|
||||
// macOS 10.8 at least can't handle service names that are 64 characters or longer
|
||||
// This was fixed some point after 10.8, but I'm not sure if it was fixed in 10.9 or 10.10 or 10.11
|
||||
@@ -77,3 +79,13 @@ NSString *SUStatusInfoServiceNameForBundleIdentifier(NSString *bundleIdentifier)
|
||||
{
|
||||
return SUServiceNameWithTag(SPARKLE_STATUS_TAG, bundleIdentifier);
|
||||
}
|
||||
|
||||
NSString *SUProgressAgentServiceNameForBundleIdentifier(NSString *bundleIdentifier)
|
||||
{
|
||||
return SUServiceNameWithTag(SPARKLE_PROGRESS_TAG, bundleIdentifier);
|
||||
}
|
||||
|
||||
NSString *SUProgressAgentLauncherServiceNameForBundleIdentifier(NSString *bundleIdentifier)
|
||||
{
|
||||
return SUServiceNameWithTag(SPARKLE_PROGRESS_LAUNCH_INSTALLER_TAG, bundleIdentifier);
|
||||
}
|
||||
Vendored
+4
-1
@@ -8,7 +8,10 @@
|
||||
|
||||
#import "StatusInfo.h"
|
||||
#import "SUMessageTypes.h"
|
||||
#import "SULog.h"
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#error This is a "daemon-safe" class and should NOT import AppKit
|
||||
#endif
|
||||
|
||||
@interface StatusInfo () <NSXPCListenerDelegate>
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#error This is class should NOT import AppKit
|
||||
#error This is a "daemon-safe" class and should NOT import AppKit
|
||||
#endif
|
||||
|
||||
@interface TerminationListener ()
|
||||
|
||||
@@ -26,5 +26,9 @@
|
||||
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>LSBackgroundOnly</key>
|
||||
<string>1</string>
|
||||
<key>LSUIElement</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -10,14 +10,16 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol InstallerProgressAppControllerDelegate;
|
||||
@protocol InstallerProgressDelegate;
|
||||
|
||||
@interface InstallerProgressAppController : NSObject <NSApplicationDelegate>
|
||||
|
||||
- (instancetype)initWithApplication:(NSApplication *)application arguments:(NSArray<NSString *> *)arguments delegate:(id<InstallerProgressAppControllerDelegate>)delegate;
|
||||
- (instancetype)initWithApplication:(NSApplication *)application arguments:(NSArray<NSString *> *)arguments delegate:(id<InstallerProgressDelegate>)delegate;
|
||||
|
||||
- (void)run;
|
||||
|
||||
- (void)cleanupAndExitWithStatus:(int)status __attribute__((noreturn));
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+178
-33
@@ -7,11 +7,14 @@
|
||||
//
|
||||
|
||||
#import "InstallerProgressAppController.h"
|
||||
#import "InstallerProgressAppControllerDelegate.h"
|
||||
#import "SUInstallerStatus.h"
|
||||
#import "InstallerProgressDelegate.h"
|
||||
#import "SUMessageTypes.h"
|
||||
#import "SULog.h"
|
||||
#import "SUApplicationInfo.h"
|
||||
#import "SUInstallerAgentProtocol.h"
|
||||
#import "SUInstallerAgentInitiationProtocol.h"
|
||||
#import "InstallerProgressLauncher.h"
|
||||
#import <ServiceManagement/ServiceManagement.h>
|
||||
|
||||
/*!
|
||||
* Terminate the application after a delay from launching the new update to avoid OS activation issues
|
||||
@@ -20,59 +23,102 @@
|
||||
*/
|
||||
static const NSTimeInterval SUTerminationTimeDelay = 0.3;
|
||||
|
||||
@interface InstallerProgressAppController () <NSApplicationDelegate>
|
||||
@interface InstallerProgressAppController () <NSApplicationDelegate, SUInstallerAgentProtocol, InstallerProgressLauncherDelegate>
|
||||
|
||||
@property (nonatomic, readonly) NSApplication *application;
|
||||
@property (nonatomic, readonly) NSBundle *bundle;
|
||||
@property (nonatomic, readonly, weak) id<InstallerProgressAppControllerDelegate> delegate;
|
||||
@property (nonatomic, readonly) id<SUInstallerStatusProtocol> statusInfo;
|
||||
@property (nonatomic, weak) id<InstallerProgressDelegate> delegate;
|
||||
@property (nonatomic, readonly) NSXPCConnection *connection;
|
||||
@property (nonatomic) BOOL connected;
|
||||
@property (nonatomic) BOOL repliedToRegistration;
|
||||
@property (nonatomic, readonly) NSBundle *hostBundle;
|
||||
@property (nonatomic, readonly, nullable) InstallerProgressLauncher *progressLauncher;
|
||||
@property (nonatomic) BOOL submittedLauncherJob;
|
||||
|
||||
@end
|
||||
|
||||
#define CONNECTION_ACKNOWLEDGEMENT_TIMEOUT 7ull
|
||||
|
||||
@implementation InstallerProgressAppController
|
||||
|
||||
@synthesize application = _application;
|
||||
@synthesize bundle = _bundle;
|
||||
@synthesize delegate = _delegate;
|
||||
@synthesize statusInfo = _statusInfo;
|
||||
@synthesize connection = _connection;
|
||||
@synthesize connected = _connected;
|
||||
@synthesize repliedToRegistration = _repliedToRegistration;
|
||||
@synthesize hostBundle = _hostBundle;
|
||||
@synthesize progressLauncher = _progressLauncher;
|
||||
@synthesize submittedLauncherJob = _submittedLauncherJob;
|
||||
|
||||
- (instancetype)initWithApplication:(NSApplication *)application arguments:(NSArray<NSString *> *)arguments delegate:(id<InstallerProgressAppControllerDelegate>)delegate
|
||||
- (instancetype)initWithApplication:(NSApplication *)application arguments:(NSArray<NSString *> *)arguments delegate:(id<InstallerProgressDelegate>)delegate
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
if (arguments.count != 2) {
|
||||
exit(EXIT_FAILURE);
|
||||
if (arguments.count != 5) {
|
||||
SULog(@"Error: Invalid arguments");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
}
|
||||
|
||||
NSString *hostBundlePath = arguments[1];
|
||||
NSBundle *bundle = [NSBundle bundleWithPath:hostBundlePath];
|
||||
if (bundle == nil) {
|
||||
SULog(@"Error: bundle at %@ is nil", hostBundlePath);
|
||||
exit(EXIT_FAILURE);
|
||||
if (hostBundlePath.length == 0) {
|
||||
SULog(@"Error: Host bundle path length is 0");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
}
|
||||
|
||||
NSString *bundleIdentifier = bundle.bundleIdentifier;
|
||||
if (bundleIdentifier == nil) {
|
||||
SULog(@"Error: Bundle Identifier for target is nil");
|
||||
exit(EXIT_FAILURE);
|
||||
_hostBundle = [NSBundle bundleWithPath:hostBundlePath];
|
||||
if (_hostBundle == nil) {
|
||||
SULog(@"Error: Host bundle for target is nil");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
}
|
||||
|
||||
NSString *hostBundleIdentifier = _hostBundle.bundleIdentifier;
|
||||
if (hostBundleIdentifier == nil) {
|
||||
SULog(@"Error: Host bundle identifier for target is nil");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
}
|
||||
|
||||
BOOL allowingInteraction = arguments[2].boolValue;
|
||||
|
||||
NSString *installerPath = arguments[3];
|
||||
if (installerPath.length == 0) {
|
||||
SULog(@"Error: Installer path length is 0");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
}
|
||||
|
||||
BOOL shouldSubmitInstaller = arguments[4].boolValue;
|
||||
if (shouldSubmitInstaller) {
|
||||
_progressLauncher = [[InstallerProgressLauncher alloc] initWithHostBundle:_hostBundle installerPath:installerPath allowingInteraction:allowingInteraction delegate:self];
|
||||
}
|
||||
|
||||
application.applicationIconImage = [SUApplicationInfo bestIconForBundle:bundle];
|
||||
|
||||
application.delegate = self;
|
||||
|
||||
_application = application;
|
||||
_delegate = delegate;
|
||||
_bundle = bundle;
|
||||
_statusInfo = [[SUInstallerStatus alloc] init];
|
||||
|
||||
[_statusInfo setInvalidationHandler:^{
|
||||
NSXPCConnectionOptions connectionOptions = shouldSubmitInstaller ? NSXPCConnectionPrivileged : 0;
|
||||
_connection = [[NSXPCConnection alloc] initWithMachServiceName:SUProgressAgentServiceNameForBundleIdentifier(hostBundleIdentifier) options:connectionOptions];
|
||||
|
||||
_connection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerAgentProtocol)];
|
||||
_connection.exportedObject = self;
|
||||
|
||||
_connection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerAgentInitiationProtocol)];
|
||||
|
||||
__weak InstallerProgressAppController *weakSelf = self;
|
||||
_connection.interruptionHandler = ^{
|
||||
[weakSelf.connection invalidate];
|
||||
};
|
||||
|
||||
_connection.invalidationHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[application terminate:nil];
|
||||
InstallerProgressAppController *strongSelf = weakSelf;
|
||||
if (strongSelf != nil) {
|
||||
int exitStatus = (strongSelf.repliedToRegistration ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
if (!strongSelf.repliedToRegistration) {
|
||||
SULog(@"Error: Agent Invalidating without having the chance to reply to installer");
|
||||
}
|
||||
[strongSelf cleanupAndExitWithStatus:exitStatus];
|
||||
}
|
||||
});
|
||||
}];
|
||||
|
||||
[_statusInfo setServiceName:SUStatusInfoServiceNameForBundleIdentifier(bundleIdentifier)];
|
||||
};
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -82,16 +128,112 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.3;
|
||||
[self.application run];
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)__unused notification
|
||||
- (void)startConnection
|
||||
{
|
||||
[self.statusInfo probeStatusConnectivityWithReply:^{
|
||||
[self.connection resume];
|
||||
[self.connection.remoteObjectProxy connectionDidInitiateWithReply:^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.delegate applicationDidFinishLaunchingWithTargetBundle:self.bundle];
|
||||
self.connected = YES;
|
||||
});
|
||||
}];
|
||||
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(CONNECTION_ACKNOWLEDGEMENT_TIMEOUT * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (!self.connected) {
|
||||
SULog(@"Timeout error: failed to receive acknowledgement from installer");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Close status window immediately, but delay termination for a little bit to better increase the chance
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)__unused notification
|
||||
{
|
||||
if (self.progressLauncher == nil) {
|
||||
[self startConnection];
|
||||
} else {
|
||||
[self.progressLauncher startListener];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)cleanupAndExitWithStatus:(int)status __attribute__((noreturn))
|
||||
{
|
||||
[self.connection invalidate];
|
||||
[self.progressLauncher invalidate];
|
||||
|
||||
exit(status);
|
||||
}
|
||||
|
||||
- (void)installerProgressLauncherDidSubmitJob
|
||||
{
|
||||
self.submittedLauncherJob = YES;
|
||||
[self startConnection];
|
||||
}
|
||||
|
||||
- (void)installerProgressLauncherDidInvalidate
|
||||
{
|
||||
if (!self.submittedLauncherJob) {
|
||||
SULog(@"Installer progress launcher invalidated");
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)registerRelaunchBundlePath:(NSString *)relaunchBundlePath reply:(void (^)(NSNumber *))reply
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
assert(relaunchBundlePath != nil);
|
||||
NSBundle *relaunchBundle = [NSBundle bundleWithPath:relaunchBundlePath];
|
||||
if (relaunchBundle == nil) {
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
}
|
||||
|
||||
NSRunningApplication *runningApplication = [SUApplicationInfo runningApplicationWithBundle:relaunchBundle];
|
||||
NSNumber *processIdentifier = (runningApplication == nil || runningApplication.terminated) ? nil : @(runningApplication.processIdentifier);
|
||||
|
||||
reply(processIdentifier);
|
||||
|
||||
self.repliedToRegistration = YES;
|
||||
});
|
||||
}
|
||||
|
||||
- (void)relaunchPath:(NSString *)pathToRelaunch
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (![[NSWorkspace sharedWorkspace] openFile:pathToRelaunch]) {
|
||||
SULog(@"Error: Failed to relaunch bundle at %@", pathToRelaunch);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
- (void)showProgress
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
// Show app icon in the dock
|
||||
ProcessSerialNumber psn = { 0, kCurrentProcess };
|
||||
TransformProcessType(&psn, kProcessTransformToForegroundApplication);
|
||||
|
||||
// Note: the application icon needs to be set after showing the icon in the dock
|
||||
self.application.applicationIconImage = [SUApplicationInfo bestIconForBundle:self.hostBundle];
|
||||
|
||||
// Activate ourselves otherwise we will probably be in the background
|
||||
[self.application activateIgnoringOtherApps:YES];
|
||||
|
||||
[self.delegate installerProgressShouldDisplayWithBundle:self.hostBundle];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)stopProgress
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self _stopProgress];
|
||||
});
|
||||
}
|
||||
|
||||
- (void)_stopProgress
|
||||
{
|
||||
[self.delegate installerProgressShouldStop];
|
||||
self.delegate = nil;
|
||||
}
|
||||
|
||||
// Dismiss any UI immediately, but delay termination for a little bit to better increase the chance
|
||||
// the updated application when relaunched will be the frontmost application
|
||||
// This is related to macOS activation issues when terminating a frontmost application happens right before
|
||||
// launching another app
|
||||
@@ -99,8 +241,11 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.3;
|
||||
{
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUTerminationTimeDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
// Exit right away, don't go through the apple event process again
|
||||
exit(EXIT_SUCCESS);
|
||||
[self cleanupAndExitWithStatus:EXIT_SUCCESS];
|
||||
});
|
||||
|
||||
[self _stopProgress];
|
||||
|
||||
// Reply with a 'cancel' rather than 'later' because 'later' may make the runloop stop completely, not having the dispatch_after above invoked
|
||||
return NSTerminateCancel;
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
//
|
||||
// InstallerProgressAppControllerDelegate.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 4/10/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol InstallerProgressAppControllerDelegate <NSObject>
|
||||
|
||||
- (void)applicationDidFinishLaunchingWithTargetBundle:(NSBundle *)bundle;
|
||||
- (void)applicationWillTerminateAfterDelay;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// InstallerProgressDelegate.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 4/10/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol InstallerProgressDelegate <NSObject>
|
||||
|
||||
- (void)installerProgressShouldDisplayWithBundle:(NSBundle *)bundle;
|
||||
- (void)installerProgressShouldStop;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// SUInstallerAgentInitiationProtocol.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 7/17/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@protocol SUInstallerAgentInitiationProtocol
|
||||
|
||||
- (void)connectionDidInitiateWithReply:(void (^)(void))acknowledgement;
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// SUInstallerAgentProtocol.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 7/17/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol SUInstallerAgentProtocol
|
||||
|
||||
- (void)registerRelaunchBundlePath:(NSString *)relaunchBundlePath reply:(void (^)(NSNumber * _Nullable processIdentifier))reply;
|
||||
|
||||
- (void)showProgress;
|
||||
|
||||
- (void)stopProgress;
|
||||
|
||||
- (void)relaunchPath:(NSString *)pathToRelaunch;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+2
-2
@@ -7,11 +7,11 @@
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "InstallerProgressAppControllerDelegate.h"
|
||||
#import "InstallerProgressDelegate.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface ShowInstallerProgress : NSObject <InstallerProgressAppControllerDelegate>
|
||||
@interface ShowInstallerProgress : NSObject <InstallerProgressDelegate>
|
||||
|
||||
@end
|
||||
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@
|
||||
|
||||
@synthesize statusController = _statusController;
|
||||
|
||||
- (void)applicationDidFinishLaunchingWithTargetBundle:(NSBundle *)bundle
|
||||
- (void)installerProgressShouldDisplayWithBundle:(NSBundle *)bundle
|
||||
{
|
||||
SUHost *host = [[SUHost alloc] initWithBundle:bundle];
|
||||
self.statusController = [[SUStatusController alloc] initWithHost:host];
|
||||
@@ -32,7 +32,7 @@
|
||||
[self.statusController showWindow:self];
|
||||
}
|
||||
|
||||
- (void)applicationWillTerminateAfterDelay
|
||||
- (void)installerProgressShouldStop
|
||||
{
|
||||
[self.statusController close];
|
||||
self.statusController = nil;
|
||||
|
||||
Vendored
+10
-1
@@ -14,7 +14,7 @@ int main(int __unused argc, const char __unused *argv[])
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
ShowInstallerProgress *showInstallerProgress = [[ShowInstallerProgress alloc] init];
|
||||
id<InstallerProgressDelegate> showInstallerProgress = [[ShowInstallerProgress alloc] init];
|
||||
|
||||
InstallerProgressAppController *appController =
|
||||
[[InstallerProgressAppController alloc]
|
||||
@@ -22,6 +22,15 @@ int main(int __unused argc, const char __unused *argv[])
|
||||
arguments:[[NSProcessInfo processInfo] arguments]
|
||||
delegate:showInstallerProgress];
|
||||
|
||||
// Ignore SIGTERM because we are going to catch it ourselves
|
||||
signal(SIGTERM, SIG_IGN);
|
||||
|
||||
dispatch_source_t sigtermSource = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGTERM, 0, dispatch_get_main_queue());
|
||||
dispatch_source_set_event_handler(sigtermSource, ^{
|
||||
[appController cleanupAndExitWithStatus:SIGTERM];
|
||||
});
|
||||
dispatch_resume(sigtermSource);
|
||||
|
||||
[appController run];
|
||||
}
|
||||
|
||||
|
||||
Vendored
+2
-1
@@ -14,6 +14,7 @@
|
||||
#import "SUDownloadDriver.h"
|
||||
#import "SULocalCacheDirectory.h"
|
||||
#import "SULog.h"
|
||||
#import "SUErrors.h"
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#error This is a "core" class and should NOT import AppKit
|
||||
@@ -148,7 +149,7 @@
|
||||
|
||||
[self.installerDriver extractDownloadName:downloadName withUpdateItem:self.updateItem temporaryDirectory:temporaryDirectory completion:^(NSError * _Nullable error) {
|
||||
if (error != nil) {
|
||||
[self.delegate coreDriverIsRequestingAbortUpdateWithError:error];
|
||||
[self.delegate coreDriverIsRequestingAbortUpdateWithError:(error.code == SUInstallationCancelledError) ? nil : error];
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
Vendored
-33
@@ -9,8 +9,6 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUExport.h"
|
||||
|
||||
@class SUAuthorizationEnvironment;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
@@ -27,37 +25,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
+ (instancetype)defaultManager;
|
||||
|
||||
/**
|
||||
* Creates a file manager that allows authorizing for file operations
|
||||
* @param authorizationToolPath Specifies the path to the tool that can perform file operations and be run as root.
|
||||
* This tool will be invoked when read or write access is denied when attempting ordinary file operations. See the `fileop` tool included in Sparkle.
|
||||
* @param environment Specifies the authorization environment used when making an authorization request. Pass nil to use a default environment.
|
||||
* @return A new file manager instance
|
||||
*
|
||||
* This method just creates the file manager. It doesn't acquire authorization immediately or if it doesn't need to.
|
||||
*/
|
||||
+ (instancetype)fileManagerWithAuthorizationToolPath:(NSString *)authorizationToolPath environment:(SUAuthorizationEnvironment * _Nullable)environment;
|
||||
|
||||
/**
|
||||
* Returns a file manager that allows or disallows authorizing for file operations based on the current file manager
|
||||
* @return A file manager instance that can perform authorized operations if the current file manager has already performed them.
|
||||
* If the current file manager instance hasn't yet performed authorized operations, then neither can the instance returned by this method
|
||||
*
|
||||
* This may return a newly created file manager or re-use the existing file manager depending on the current authorization rights.
|
||||
*/
|
||||
- (instancetype)fileManagerByPreservingAuthorizationRights;
|
||||
|
||||
/**
|
||||
* Requests and grants authorization for performing authorized operations.
|
||||
*
|
||||
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL. An error code of SUInstallationCancelledError is returned if an authorization prompt occurs and the user decides to cancel the request.
|
||||
* @return YES on success otherwise returns NO
|
||||
*
|
||||
* This will prompt the user for an authorization dialog if the user's permission is needed to perform authorized operations.
|
||||
* If the process is running as root already, no authorization prompt is made.
|
||||
*/
|
||||
- (BOOL)grantAuthorizationPrivilegesWithError:(NSError * __autoreleasing *)error;
|
||||
|
||||
/**
|
||||
* Creates a temporary directory on the same volume as a provided URL
|
||||
* @param preferredName A name that may be used when creating the temporary directory. Note that in the uncothirdStageErrormmon case this name is used, the temporary directory will be created inside the directory pointed by appropriateURL
|
||||
|
||||
Vendored
+51
-391
@@ -7,10 +7,7 @@
|
||||
//
|
||||
|
||||
#import "SUFileManager.h"
|
||||
#import "SUAuthorizationEnvironment.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUErrors.h"
|
||||
#import "SUFileOperationConstants.h"
|
||||
|
||||
#include <sys/xattr.h>
|
||||
#include <sys/errno.h>
|
||||
@@ -46,11 +43,6 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
// Used to indicate if the type of NSError requires us to attempt to peform the same operation again except with authentication
|
||||
// To be safe, both read and write permission denied's are included because Cocoa's error methods are not very well documented
|
||||
// and at least one case is caused from lack of read permissions (-[NSURL setResourceValue:forKey:error:])
|
||||
#define NS_HAS_PERMISSION_ERROR(error) (error.code == NSFileReadNoPermissionError || error.code == NSFileWriteNoPermissionError)
|
||||
|
||||
#pragma clang diagnostic push
|
||||
// Use direct access because it's easier, clearer, and faster
|
||||
#pragma clang diagnostic ignored "-Wdirect-ivar-access"
|
||||
@@ -59,166 +51,20 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
{
|
||||
AuthorizationRef _auth;
|
||||
NSFileManager *_fileManager;
|
||||
NSString *_authorizationToolPath;
|
||||
SUAuthorizationEnvironment *_environment;
|
||||
}
|
||||
|
||||
- (instancetype)initWithAuthorizationToolPath:(NSString *)authorizationToolPath environment:(SUAuthorizationEnvironment *)environment
|
||||
- (instancetype)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_fileManager = [[NSFileManager alloc] init];
|
||||
_authorizationToolPath = [authorizationToolPath copy];
|
||||
_environment = environment;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)defaultManager
|
||||
{
|
||||
return [[self alloc] initWithAuthorizationToolPath:nil environment:nil];
|
||||
}
|
||||
|
||||
+ (instancetype)fileManagerWithAuthorizationToolPath:(NSString *)authorizationToolPath environment:(SUAuthorizationEnvironment * _Nullable)environment
|
||||
{
|
||||
return [[self alloc] initWithAuthorizationToolPath:authorizationToolPath environment:environment];
|
||||
}
|
||||
|
||||
- (instancetype)fileManagerByPreservingAuthorizationRights
|
||||
{
|
||||
// Check if we don't allow authorization, or that we haven't needed to authorize yet, to create or re-use a
|
||||
// file manager instance with these restrictions
|
||||
return (_authorizationToolPath != nil && _auth != NULL) ? self : [SUFileManager defaultManager];
|
||||
}
|
||||
|
||||
// Acquires an authorization reference with root privileges which is intended to be used for authorized file operations
|
||||
- (BOOL)_acquireAuthorizationWithError:(NSError *__autoreleasing *)error
|
||||
{
|
||||
// No need to continue if we already acquired an authorization reference
|
||||
if (_auth != NULL) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (_authorizationToolPath == nil) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: @"Unable to grant authorization to perform action because it is explicitly turned off" }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
// This should almost always succeed, fail in unusual/rare cases
|
||||
OSStatus createStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &_auth);
|
||||
if (createStatus != errAuthorizationSuccess) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed creating authorization reference with status code %d.", createStatus] }];
|
||||
}
|
||||
_auth = NULL;
|
||||
return NO;
|
||||
}
|
||||
|
||||
AuthorizationItem rightItems[] = {
|
||||
// The right that allows us to run tools as root user
|
||||
{.name = kAuthorizationRightExecute, .valueLength = 0, .value = NULL, .flags = 0}
|
||||
};
|
||||
|
||||
AuthorizationRights rights = {
|
||||
.count = sizeof(rightItems) / sizeof(*rightItems),
|
||||
.items = rightItems
|
||||
};
|
||||
|
||||
AuthorizationFlags flags =
|
||||
(AuthorizationFlags)(kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights | kAuthorizationFlagPreAuthorize);
|
||||
|
||||
// This will test if we can gain authorization for running utlities as root
|
||||
OSStatus copyStatus = AuthorizationCopyRights(_auth, &rights, (_environment != nil ? _environment.environment : kAuthorizationEmptyEnvironment), flags, NULL);
|
||||
if (copyStatus != errAuthorizationSuccess) {
|
||||
if (error != NULL) {
|
||||
if (copyStatus == errAuthorizationCanceled) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationCancelledError userInfo:@{ NSLocalizedDescriptionKey: @"Authorization access was cancelled by the user." }];
|
||||
} else {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed granting authorization rights with status code %d.", copyStatus] }];
|
||||
}
|
||||
}
|
||||
|
||||
AuthorizationFree(_auth, kAuthorizationFlagDefaults);
|
||||
_auth = NULL;
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)_authorizeAndExecuteCommand:(char *)command sourcePath:(char *)sourcePath destinationPath:(char *)destinationPath error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
NSError *acquireError = nil;
|
||||
if (![self _acquireAuthorizationWithError:&acquireError]) {
|
||||
if (error != NULL) {
|
||||
*error = acquireError;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
char *arguments[] = { command, sourcePath, destinationPath, NULL };
|
||||
|
||||
char toolPath[PATH_MAX] = {0};
|
||||
if (![_authorizationToolPath getFileSystemRepresentation:toolPath maxLength:sizeof(toolPath)]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Authorization tool (%@) cannot be represented as a valid file name.", _authorizationToolPath.lastPathComponent] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
FILE *pipe = NULL;
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
if (AuthorizationExecuteWithPrivileges(_auth, toolPath, kAuthorizationFlagDefaults, arguments, &pipe) != errAuthorizationSuccess) {
|
||||
#pragma clang diagnostic pop
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:@"Failed to run authorization tool." }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
uint32_t pidData = 0;
|
||||
if (fread(&pidData, sizeof(pidData), 1, pipe) < 1) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:@"Failed to retrieve authorized executable process identifier." }];
|
||||
}
|
||||
fclose(pipe);
|
||||
return NO;
|
||||
}
|
||||
|
||||
pid_t childPid = (int32_t)CFSwapInt32LittleToHost(pidData);
|
||||
int status = 0;
|
||||
|
||||
pid_t waitResult;
|
||||
do {
|
||||
waitResult = waitpid(childPid, &status, 0);
|
||||
} while (waitResult == -1 && errno == EINTR);
|
||||
|
||||
fclose(pipe);
|
||||
|
||||
if (waitResult == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Failed to execute authorized executable with result %d and status (%d, %d, %d).", waitResult, status, WIFEXITED(status), WEXITSTATUS(status)] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
if (_auth != NULL) {
|
||||
AuthorizationFree(_auth, kAuthorizationFlagDefaults);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)grantAuthorizationPrivilegesWithError:(NSError * __autoreleasing *)error
|
||||
{
|
||||
return [self _acquireAuthorizationWithError:error];
|
||||
return [[self alloc] init];
|
||||
}
|
||||
|
||||
// -[NSFileManager attributesOfItemAtPath:error:] won't follow symbolic links
|
||||
@@ -275,36 +121,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
return removexattr(path, attr, options);
|
||||
}
|
||||
|
||||
#define XATTR_UTILITY_PATH "/usr/bin/xattr"
|
||||
// Recursively remove an xattr at a specified root URL with authentication
|
||||
- (BOOL)_removeQuarantineWithAuthenticationAtRootURL:(NSURL *)rootURL error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
// Because this is a system utility, it's fine to follow the symbolic link if one exists
|
||||
if (![_fileManager fileExistsAtPath:@(XATTR_UTILITY_PATH)]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: @"xattr utility does not exist on this system." }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
char path[PATH_MAX] = {0};
|
||||
if (![rootURL.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"File to remove (%@) cannot be represented as a valid file name.", rootURL.path.lastPathComponent] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *executeError = nil;
|
||||
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpRemoveQuarantineCommand sourcePath:path destinationPath:NULL error:&executeError];
|
||||
if (!success && error != NULL) {
|
||||
*error = executeError;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
- (BOOL)_releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL withQuarantineRetrieval:(BOOL (^)(NSURL *))quarantineRetrieval quarantineRemoval:(BOOL (^)(NSURL *, NSError * __autoreleasing *))quarantineRemoval isAccessError:(BOOL (^)(NSError *))isAccessError error:(NSError * __autoreleasing *)error
|
||||
- (BOOL)_releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL withQuarantineRetrieval:(BOOL (^)(NSURL *))quarantineRetrieval quarantineRemoval:(BOOL (^)(NSURL *, NSError * __autoreleasing *))quarantineRemoval error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
if (![self _itemExistsAtURL:rootURL]) {
|
||||
if (error != NULL) {
|
||||
@@ -322,18 +139,13 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
if (quarantineRemoval(fileURL, &removalError)) {
|
||||
removedQuarantine = YES;
|
||||
} else {
|
||||
if (isAccessError(removalError)) {
|
||||
removedQuarantine = [self _removeQuarantineWithAuthenticationAtRootURL:rootURL error:error];
|
||||
attemptedAuthentication = YES;
|
||||
} else {
|
||||
if (success != NULL) {
|
||||
// Make sure we haven't already run into an error
|
||||
if (*success && error != NULL) {
|
||||
*error = removalError;
|
||||
}
|
||||
// Fail, but still try to release other items from quarantine
|
||||
*success = NO;
|
||||
if (success != NULL) {
|
||||
// Make sure we haven't already run into an error
|
||||
if (*success && error != NULL) {
|
||||
*error = removalError;
|
||||
}
|
||||
// Fail, but still try to release other items from quarantine
|
||||
*success = NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -400,6 +212,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
{
|
||||
static const int removeXAttrOptions = XATTR_NOFOLLOW;
|
||||
|
||||
#warning this code is over complicated now, needs to be rewritten
|
||||
return
|
||||
[self
|
||||
_releaseItemFromQuarantineAtRootURL:rootURL
|
||||
@@ -413,9 +226,6 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
}
|
||||
return removedQuarantine;
|
||||
}
|
||||
isAccessError:^BOOL(NSError *removalError) {
|
||||
return (removalError.code == EACCES);
|
||||
}
|
||||
error:error];
|
||||
}
|
||||
|
||||
@@ -464,43 +274,13 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
OSStatus copyResult = FSCopyObjectSync(&sourceRef, &destinationParentRef, (__bridge CFStringRef)(destinationURL.lastPathComponent), NULL, kFSFileOperationDefaultOptions);
|
||||
#pragma clang diagnostic pop
|
||||
if (copyResult == noErr) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
// Note: I have received afpAccessDenied error in testing even when not copying from/to an AFP mount,
|
||||
// when the error should have been a normal permission denied one
|
||||
if (copyResult != permErr && copyResult != afpAccessDenied) {
|
||||
|
||||
if (copyResult != noErr) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSOSStatusErrorDomain code:copyResult userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to copy file (%@)", sourceURL.lastPathComponent] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
char sourcePath[PATH_MAX] = {0};
|
||||
if (![sourceURL.path getFileSystemRepresentation:sourcePath maxLength:sizeof(sourcePath)]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination to copy file to (%@) cannot be represented as a valid file name.", sourceURL.lastPathComponent] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
char destinationPath[PATH_MAX] = {0};
|
||||
if (![destinationURL.path getFileSystemRepresentation:destinationPath maxLength:sizeof(destinationPath)]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination to copy file to (%@) cannot be represented as a valid file name.", destinationURL.lastPathComponent] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *executeError = nil;
|
||||
if (![self _authorizeAndExecuteCommand:SUFileOpCopyCommand sourcePath:sourcePath destinationPath:destinationPath error:&executeError]) {
|
||||
if (error != NULL) {
|
||||
*error = executeError;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@@ -572,48 +352,11 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
if (foundSourceVolume && foundDestinationVolume && sourceVolume != destinationVolume) {
|
||||
return ([self copyItemAtURL:sourceURL toURL:destinationURL error:error] && [self removeItemAtURL:sourceURL error:error]);
|
||||
}
|
||||
|
||||
NSError *moveError = nil;
|
||||
if ([_fileManager moveItemAtURL:sourceURL toURL:destinationURL error:&moveError]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (!NS_HAS_PERMISSION_ERROR(moveError)) {
|
||||
if (error != NULL) {
|
||||
*error = moveError;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
char sourcePath[PATH_MAX] = {0};
|
||||
if (![sourceURL.path getFileSystemRepresentation:sourcePath maxLength:sizeof(sourcePath)]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"File to move (%@) cannot be represented as a valid file name.", sourceURL.path.lastPathComponent] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
char destinationPath[PATH_MAX] = {0};
|
||||
if (![destinationURL.path getFileSystemRepresentation:destinationPath maxLength:sizeof(destinationPath)]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination (%@) cannot be represented as a valid file name.", destinationURL.path.lastPathComponent] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *executeError = nil;
|
||||
if (![self _authorizeAndExecuteCommand:SUFileOpMoveCommand sourcePath:sourcePath destinationPath:destinationPath error:&executeError]) {
|
||||
if (error != NULL) {
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Failed to perform authorized file move for %@.", sourceURL.lastPathComponent];
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:errorMessage, NSUnderlyingErrorKey: executeError }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
return YES;
|
||||
return [_fileManager moveItemAtURL:sourceURL toURL:destinationURL error:error];
|
||||
}
|
||||
|
||||
- (BOOL)_changeOwnerAndGroupOfItemAtURL:(NSURL *)targetURL ownerID:(NSNumber *)ownerID groupID:(NSNumber *)groupID needsAuth:(BOOL *)needsAuth error:(NSError * __autoreleasing *)error
|
||||
- (BOOL)_changeOwnerAndGroupOfItemAtURL:(NSURL *)targetURL ownerID:(NSNumber *)ownerID groupID:(NSNumber *)groupID error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
char path[PATH_MAX] = {0};
|
||||
if (![targetURL.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||
@@ -632,23 +375,16 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
}
|
||||
|
||||
// We use fchown instead of chown because the latter can follow symbolic links
|
||||
BOOL success = fchown(fileDescriptor, ownerID.unsignedIntValue, groupID.unsignedIntValue) == 0;
|
||||
BOOL success = (fchown(fileDescriptor, ownerID.unsignedIntValue, groupID.unsignedIntValue) == 0);
|
||||
close(fileDescriptor);
|
||||
|
||||
if (!success) {
|
||||
if (errno == EPERM) {
|
||||
if (needsAuth != NULL) {
|
||||
*needsAuth = YES;
|
||||
}
|
||||
} else {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to change owner & group for %@ with owner ID %u and group ID %u.", targetURL.path.lastPathComponent, ownerID.unsignedIntValue, groupID.unsignedIntValue] }];
|
||||
}
|
||||
return NO;
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to change owner & group for %@ with owner ID %u and group ID %u.", targetURL.path.lastPathComponent, ownerID.unsignedIntValue, groupID.unsignedIntValue] }];
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
return success;
|
||||
}
|
||||
|
||||
- (BOOL)changeOwnerAndGroupOfItemAtRootURL:(NSURL *)targetURL toMatchURL:(NSURL *)matchURL error:(NSError * __autoreleasing *)error
|
||||
@@ -715,53 +451,20 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
BOOL needsAuth = NO;
|
||||
|
||||
if (![self _changeOwnerAndGroupOfItemAtURL:targetURL ownerID:ownerID groupID:groupID needsAuth:&needsAuth error:error]) {
|
||||
if (![self _changeOwnerAndGroupOfItemAtURL:targetURL ownerID:ownerID groupID:groupID error:error]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (isTargetADirectory) {
|
||||
NSDirectoryEnumerator *directoryEnumerator = [_fileManager enumeratorAtURL:targetURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil];
|
||||
for (NSURL *url in directoryEnumerator) {
|
||||
if (![self _changeOwnerAndGroupOfItemAtURL:url ownerID:ownerID groupID:groupID needsAuth:&needsAuth error:error]) {
|
||||
if (![self _changeOwnerAndGroupOfItemAtURL:url ownerID:ownerID groupID:groupID error:error]) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
if (needsAuth) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!needsAuth) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
char targetPath[PATH_MAX] = {0};
|
||||
if (![targetURL.path getFileSystemRepresentation:targetPath maxLength:sizeof(targetPath)]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Target file (%@) cannot be represented as a valid file name.", targetURL.path.lastPathComponent] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
char matchPath[PATH_MAX] = {0};
|
||||
if (![matchURLPath getFileSystemRepresentation:matchPath maxLength:sizeof(matchPath)]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Match file (%@) cannot be represented as a valid file name.", matchURL.path.lastPathComponent] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *executeError = nil;
|
||||
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpChangeOwnerAndGroupCommand sourcePath:targetPath destinationPath:matchPath error:&executeError];
|
||||
if (!success && error != NULL) {
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Failed to change owner & group on %@ to match %@ with authorization.", targetURL.path.lastPathComponent, matchURLPath.lastPathComponent];
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage, NSUnderlyingErrorKey: executeError }];
|
||||
}
|
||||
|
||||
return success;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)_updateItemAtURL:(NSURL *)targetURL withAccessTime:(struct timeval)accessTime error:(NSError * __autoreleasing *)error
|
||||
@@ -859,7 +562,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
// The document says LSRegisterURL() can be used as well but this hasn't worked out well for me in practice
|
||||
// Anyway, updating the modification time of the application is important because the system will be aware a new version of your app is available,
|
||||
// Finder will report the correct file size and other metadata for it, URL schemes your app may register will be updated, etc.
|
||||
// Behind the scenes, touch calls to utimes() which is what we use here - unless we need to authenticate
|
||||
// Behind the scenes, touch calls to utimes() which is what we use here
|
||||
- (BOOL)updateModificationAndAccessTimeOfItemAtURL:(NSURL *)targetURL error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
if (![self _itemExistsAtURL:targetURL]) {
|
||||
@@ -887,28 +590,15 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
|
||||
// Using futimes() because utimes() follows symbolic links
|
||||
BOOL updatedTime = (futimes(fileDescriptor, NULL) == 0);
|
||||
|
||||
close(fileDescriptor);
|
||||
|
||||
if (updatedTime) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (errno != EACCES) {
|
||||
if (!updatedTime) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to update modification & access time for %@", targetURL.path.lastPathComponent] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *executeError = nil;
|
||||
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpUpdateModificationAndAccessTimeCommand sourcePath:path destinationPath:NULL error:&executeError];
|
||||
if (!success && error != NULL) {
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Failed to update modification & access time on %@ with authorization.", targetURL.path.lastPathComponent];
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage, NSUnderlyingErrorKey: executeError }];
|
||||
}
|
||||
|
||||
return success;
|
||||
return updatedTime;
|
||||
}
|
||||
|
||||
// Creates a directory at the item pointed by url
|
||||
@@ -932,35 +622,14 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
}
|
||||
|
||||
NSError *createDirectoryError = nil;
|
||||
if ([_fileManager createDirectoryAtURL:url withIntermediateDirectories:NO attributes:nil error:&createDirectoryError]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (!NS_HAS_PERMISSION_ERROR(createDirectoryError)) {
|
||||
if (![_fileManager createDirectoryAtURL:url withIntermediateDirectories:NO attributes:nil error:&createDirectoryError]) {
|
||||
if (error != NULL) {
|
||||
*error = createDirectoryError;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
char path[PATH_MAX] = {0};
|
||||
if (![url.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Directory to create (%@) cannot be represented as a valid file name.", url.path.lastPathComponent] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *executeError = nil;
|
||||
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpMakeDirectoryCommand sourcePath:path destinationPath:NULL error:&executeError];
|
||||
if (!success) {
|
||||
if (error != NULL) {
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Failed to make directory %@ with authorization.", url.path.lastPathComponent];
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage, NSUnderlyingErrorKey: executeError }];
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSURL *)makeTemporaryDirectoryWithPreferredName:(NSString *)preferredName appropriateForDirectoryURL:(NSURL *)directoryURL error:(NSError * __autoreleasing *)error
|
||||
@@ -994,33 +663,14 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
}
|
||||
|
||||
NSError *removeError = nil;
|
||||
if ([_fileManager removeItemAtURL:url error:&removeError]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
if (!NS_HAS_PERMISSION_ERROR(removeError)) {
|
||||
if (![_fileManager removeItemAtURL:url error:&removeError]) {
|
||||
if (error != NULL) {
|
||||
*error = removeError;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
char path[PATH_MAX] = {0};
|
||||
if (![url.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"File to remove (%@) cannot be represented as a valid file name.", url.path.lastPathComponent] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *executeError = nil;
|
||||
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpRemoveCommand sourcePath:path destinationPath:NULL error:&executeError];
|
||||
|
||||
if (!success && error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove %@ with authentication.", url.path.lastPathComponent], NSUnderlyingErrorKey: executeError }];
|
||||
}
|
||||
|
||||
return success;
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)moveItemAtURLToTrash:(NSURL *)url error:(NSError *__autoreleasing *)error
|
||||
@@ -1087,20 +737,30 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
char path[PATH_MAX] = {0};
|
||||
if (![packageURL.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Package to execute (%@) cannot be represented as a valid file name.", packageURL.path.lastPathComponent] }];
|
||||
// This command *must* be run as root
|
||||
NSString *installerPath = @"/usr/sbin/installer";
|
||||
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
task.launchPath = installerPath;
|
||||
task.arguments = @[@"-pkg", packageURL.path, @"-target", @"/"];
|
||||
task.standardError = [NSPipe pipe];
|
||||
task.standardOutput = [NSPipe pipe];
|
||||
|
||||
BOOL success = YES;
|
||||
@try {
|
||||
[task launch];
|
||||
[task waitUntilExit];
|
||||
if (task.terminationStatus != EXIT_SUCCESS) {
|
||||
success = NO;
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Guided package installer returned non-zero exit status (%d)", task.terminationStatus] }];
|
||||
}
|
||||
}
|
||||
} @catch (NSException *) {
|
||||
success = NO;
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Guided package installer task threw an exception"] }];
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSError *executeError = nil;
|
||||
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpInstallCommand sourcePath:path destinationPath:NULL error:&executeError];
|
||||
|
||||
if (!success && error != NULL) {
|
||||
NSString* errorMessage = @"Failed to execute package installer.";
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{NSLocalizedDescriptionKey: errorMessage, NSUnderlyingErrorKey: executeError}];
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
Vendored
+3
-8
@@ -43,7 +43,7 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)performSecondStageAllowingAuthorization:(BOOL)allowsAuthorization fileOperationToolPath:(NSString *)fileOperationToolPath environment:(SUAuthorizationEnvironment * _Nullable)authorizationEnvironment allowingUI:(BOOL)allowsUI error:(NSError * __autoreleasing *)error
|
||||
- (BOOL)performSecondStageAllowingUI:(BOOL)allowsUI error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
if (!allowsUI && ![self canInstallSilently]) {
|
||||
if (error != NULL) {
|
||||
@@ -53,9 +53,9 @@
|
||||
}
|
||||
|
||||
// If we're root, we can allow using the authorization APIs
|
||||
self.fileManager = (allowsAuthorization || [self isRootUser]) ? [SUFileManager fileManagerWithAuthorizationToolPath:fileOperationToolPath environment:authorizationEnvironment] : [SUFileManager defaultManager];
|
||||
self.fileManager = [SUFileManager defaultManager];
|
||||
|
||||
return [self.fileManager grantAuthorizationPrivilegesWithError:error];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)performThirdStage:(NSError * __autoreleasing *)error
|
||||
@@ -78,11 +78,6 @@
|
||||
return [self isRootUser];
|
||||
}
|
||||
|
||||
- (BOOL)mayNeedToRequestAuthorization
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)cleanup
|
||||
{
|
||||
}
|
||||
|
||||
Vendored
+18
-21
@@ -122,7 +122,8 @@
|
||||
|
||||
NSString *serviceName = SUInstallerServiceNameForBundleIdentifier(hostBundleIdentifier);
|
||||
|
||||
[self.installerConnection setServiceName:serviceName];
|
||||
#warning use self.updateItem later for passing guided option
|
||||
[self.installerConnection setServiceName:serviceName hostPath:self.host.bundlePath guided:NO];
|
||||
|
||||
[self sendInstallationData];
|
||||
}
|
||||
@@ -164,18 +165,7 @@
|
||||
decryptionPassword = [self.updaterDelegate decryptionPasswordForUpdater:self.updater];
|
||||
}
|
||||
|
||||
NSString *localProgressToolPath = [self.sparkleBundle pathForResource:@""SPARKLE_INSTALLER_PROGRESS_TOOL_NAME ofType:@"app"];
|
||||
if (localProgressToolPath == nil) {
|
||||
SULog(@"Error: Failed to find installer progress tool: %@", localProgressToolPath);
|
||||
}
|
||||
|
||||
NSError *progressToolError = nil;
|
||||
NSString *progressToolPath = [self copyPathToCacheDirectory:localProgressToolPath error:&progressToolError];
|
||||
if (progressToolPath == nil) {
|
||||
SULog(@"Error: Failed to copy or find installer progress tool: %@", progressToolError);
|
||||
}
|
||||
|
||||
SUInstallationInputData *installationData = [[SUInstallationInputData alloc] initWithRelaunchPath:pathToRelaunch progressToolPath:progressToolPath hostBundlePath:self.host.bundlePath updateDirectoryPath:self.temporaryDirectory downloadName:self.downloadName dsaSignature:dsaSignature decryptionPassword:decryptionPassword];
|
||||
SUInstallationInputData *installationData = [[SUInstallationInputData alloc] initWithRelaunchPath:pathToRelaunch hostBundlePath:self.host.bundlePath updateDirectoryPath:self.temporaryDirectory downloadName:self.downloadName dsaSignature:dsaSignature decryptionPassword:decryptionPassword];
|
||||
|
||||
NSData *archivedData = SUArchiveRootObjectSecurely(installationData);
|
||||
if (archivedData == nil) {
|
||||
@@ -392,12 +382,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *hostBundleIdentifier = self.host.bundle.bundleIdentifier;
|
||||
if (hostBundleIdentifier == nil) {
|
||||
NSError *error =
|
||||
[NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey:SULocalizedString(@"An error occurred while finding the application's bundle identifier. Please try again later.", nil) }];
|
||||
|
||||
completionHandler(error);
|
||||
// Copy the progress tool as well
|
||||
NSError *progressToolError = nil;
|
||||
NSString *progressToolPath = [self copyPathToCacheDirectory:[self.sparkleBundle pathForResource:@""SPARKLE_INSTALLER_PROGRESS_TOOL_NAME ofType:@"app"] error:&progressToolError];
|
||||
if (progressToolPath == nil) {
|
||||
completionHandler(progressToolError);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -412,6 +401,7 @@
|
||||
launcherConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerLauncherProtocol)];
|
||||
[launcherConnection resume];
|
||||
|
||||
#warning revisit weak connection
|
||||
__weak NSXPCConnection *weakConnection = launcherConnection;
|
||||
launcherConnection.interruptionHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
@@ -440,15 +430,22 @@
|
||||
shouldAllowInstallerInteraction = [self.updaterDelegate updaterShouldAllowInstallerInteraction:self.updater];
|
||||
}
|
||||
|
||||
[installerLauncher launchInstallerAtPath:relaunchToolPath withHostBundleIdentifier:hostBundleIdentifier allowingInteraction:shouldAllowInstallerInteraction completion:^(BOOL success) {
|
||||
NSString *hostBundlePath = self.host.bundle.bundlePath;
|
||||
assert(hostBundlePath != nil);
|
||||
|
||||
#warning pass actual guided flag eventually
|
||||
[installerLauncher launchInstallerAtPath:relaunchToolPath progressToolPath:progressToolPath withHostBundlePath:hostBundlePath guidedInstallation:NO allowingInteraction:shouldAllowInstallerInteraction completion:^(SUAuthorizationReply result) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
retrievedLaunchStatus = YES;
|
||||
[launcherConnection invalidate];
|
||||
|
||||
if (!success) {
|
||||
if (result == SUAuthorizationReplyFailure) {
|
||||
NSError *error =
|
||||
[NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey:SULocalizedString(@"An error occurred while launching the installer. Please try again later.", nil) }];
|
||||
|
||||
completionHandler(error);
|
||||
} else if (result == SUAuthorizationReplyCancelled) {
|
||||
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationCancelledError userInfo:nil];
|
||||
completionHandler(error);
|
||||
} else {
|
||||
[self setUpConnection];
|
||||
|
||||
Vendored
+1
-6
@@ -47,7 +47,7 @@ static NSString *SUOpenUtilityPath = @"/usr/bin/open";
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)performSecondStageAllowingAuthorization:(BOOL)__unused allowsAuthorization fileOperationToolPath:(NSString *)__unused fileOperationToolPath environment:(SUAuthorizationEnvironment * _Nullable)__unused authorizationEnvironment allowingUI:(BOOL)allowsUI error:(NSError * __autoreleasing *)error
|
||||
- (BOOL)performSecondStageAllowingUI:(BOOL)allowsUI error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
if (!allowsUI) {
|
||||
if (error != NULL) {
|
||||
@@ -91,11 +91,6 @@ static NSString *SUOpenUtilityPath = @"/usr/bin/open";
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)mayNeedToRequestAuthorization
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (void)cleanup
|
||||
{
|
||||
}
|
||||
|
||||
Vendored
+5
-25
@@ -227,22 +227,11 @@
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)performSecondStageAllowingAuthorization:(BOOL)allowsAuthorization fileOperationToolPath:(NSString *)fileOperationToolPath environment:(SUAuthorizationEnvironment * _Nullable)authorizationEnvironment allowingUI:(BOOL)allowsUI error:(NSError * __autoreleasing *)error
|
||||
- (BOOL)performSecondStageAllowingUI:(BOOL)allowsUI error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
self.fileManager = (allowsAuthorization && allowsUI) ? [SUFileManager fileManagerWithAuthorizationToolPath:fileOperationToolPath environment:authorizationEnvironment] : [SUFileManager defaultManager];
|
||||
self.fileManager = [SUFileManager defaultManager];
|
||||
|
||||
// Bring up authorization prompt right away if we need it
|
||||
BOOL canInstallSilently = [self canInstallSilently];
|
||||
if (allowsAuthorization && !canInstallSilently) {
|
||||
return [self.fileManager grantAuthorizationPrivilegesWithError:error];
|
||||
} else {
|
||||
if (!canInstallSilently) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:@{ NSLocalizedDescriptionKey: @"Sparkle cannot install the update silently" }];
|
||||
}
|
||||
}
|
||||
return canInstallSilently;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)performThirdStage:(NSError * __autoreleasing *)error
|
||||
@@ -259,21 +248,12 @@
|
||||
|
||||
- (BOOL)canInstallSilently
|
||||
{
|
||||
return ![self mayNeedToRequestAuthorization];
|
||||
}
|
||||
|
||||
- (BOOL)mayNeedToRequestAuthorization
|
||||
{
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
NSString *bundlePath = self.host.bundle.bundlePath;
|
||||
// It's very well possible to have the bundle be writable but not be able to write into the parent directory
|
||||
// And if the bundle isn't writable, but we can write into the parent directory, we will still need to authorize to replace it
|
||||
return ![fileManager isWritableFileAtPath:bundlePath] || ![fileManager isWritableFileAtPath:[bundlePath stringByDeletingLastPathComponent]];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)cleanup
|
||||
{
|
||||
SUFileManager *fileManager = [self.fileManager fileManagerByPreservingAuthorizationRights];;
|
||||
SUFileManager *fileManager = self.fileManager;
|
||||
NSURL *oldTempURL = self.oldTempURL;
|
||||
NSURL *tempOldDirectoryURL = self.tempOldDirectoryURL;
|
||||
NSURL *tempNewDirectoryURL = self.tempNewDirectoryURL;
|
||||
|
||||
Vendored
+1
-4
@@ -11,9 +11,6 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// Must free authorization ref later
|
||||
AuthorizationRef SUCreateAuthorization(BOOL * _Nullable grantedSystemPrivilege);
|
||||
|
||||
BOOL SUGrantsSystemAuthorizationAccess(void);
|
||||
BOOL SUNeedsSystemAuthorizationAccess(NSString *path, BOOL guided, BOOL * _Nullable preflighted);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Vendored
+36
-31
@@ -9,44 +9,49 @@
|
||||
#import "SUSystemAuthorization.h"
|
||||
#import <ServiceManagement/ServiceManagement.h>
|
||||
|
||||
AuthorizationRef SUCreateAuthorization(BOOL * _Nullable grantedSystemPrivilege)
|
||||
static BOOL SUPreflightSystemAuthorization(void)
|
||||
{
|
||||
// This should almost always succeed, fail in unusual/rare cases
|
||||
AuthorizationRef auth = NULL;
|
||||
OSStatus createStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &auth);
|
||||
if (createStatus != errAuthorizationSuccess) {
|
||||
auth = NULL;
|
||||
if (grantedSystemPrivilege != NULL) {
|
||||
*grantedSystemPrivilege = NO;
|
||||
}
|
||||
} else {
|
||||
AuthorizationItem rightItems[] = {
|
||||
{ .name = kSMRightModifySystemDaemons, .valueLength = 0, .value = NULL, .flags = 0}
|
||||
};
|
||||
|
||||
AuthorizationRights rights = {
|
||||
.count = sizeof(rightItems) / sizeof(*rightItems),
|
||||
.items = rightItems,
|
||||
};
|
||||
|
||||
AuthorizationFlags flags =
|
||||
(AuthorizationFlags)(kAuthorizationFlagExtendRights | kAuthorizationFlagPreAuthorize);
|
||||
|
||||
// This will test if we can gain authorization for running utlities as root
|
||||
OSStatus copyStatus = AuthorizationCopyRights(auth, &rights, kAuthorizationEmptyEnvironment, flags, NULL);
|
||||
if (grantedSystemPrivilege != NULL) {
|
||||
*grantedSystemPrivilege = (copyStatus == errAuthorizationSuccess);
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
return auth;
|
||||
}
|
||||
|
||||
BOOL SUGrantsSystemAuthorizationAccess(void)
|
||||
{
|
||||
BOOL grantedSystemPrivilege = NO;
|
||||
|
||||
AuthorizationRef auth = SUCreateAuthorization(&grantedSystemPrivilege);
|
||||
AuthorizationItem rightItems[] = {
|
||||
{ .name = kSMRightModifySystemDaemons, .valueLength = 0, .value = NULL, .flags = 0}
|
||||
};
|
||||
|
||||
AuthorizationRights rights = {
|
||||
.count = sizeof(rightItems) / sizeof(*rightItems),
|
||||
.items = rightItems,
|
||||
};
|
||||
|
||||
AuthorizationFlags flags =
|
||||
(AuthorizationFlags)(kAuthorizationFlagExtendRights | kAuthorizationFlagPreAuthorize);
|
||||
|
||||
// This will test if we can gain authorization for running utlities as root
|
||||
OSStatus copyStatus = AuthorizationCopyRights(auth, &rights, kAuthorizationEmptyEnvironment, flags, NULL);
|
||||
|
||||
AuthorizationFree(auth, kAuthorizationFlagDefaults);
|
||||
|
||||
return grantedSystemPrivilege;
|
||||
return (copyStatus == errAuthorizationSuccess);
|
||||
}
|
||||
|
||||
BOOL SUNeedsSystemAuthorizationAccess(NSString *path, BOOL guided, BOOL * _Nullable preflighted)
|
||||
{
|
||||
BOOL result;
|
||||
if (SUPreflightSystemAuthorization()) {
|
||||
if (preflighted != NULL) {
|
||||
*preflighted = YES;
|
||||
}
|
||||
result = YES;
|
||||
} else if (guided) {
|
||||
result = YES;
|
||||
} else {
|
||||
#pragma what about symbolic links?
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
result = ![fileManager isWritableFileAtPath:path] || ![fileManager isWritableFileAtPath:[path stringByDeletingLastPathComponent]];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Vendored
+1
@@ -25,6 +25,7 @@ void SUDownloadURLWithRequest(NSURLRequest * request, void (^completionBlock)(NS
|
||||
connection = [[NSXPCConnection alloc] initWithServiceName:@TEMPORARY_DOWNLOADER_BUNDLE_ID];
|
||||
connection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUTemporaryDownloaderProtocol)];
|
||||
|
||||
#warning revisit connection weak reference
|
||||
__weak NSXPCConnection *weakConnection = connection;
|
||||
connection.interruptionHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
|
||||
@@ -355,10 +355,4 @@ class SUFileManagerTest: XCTestCase
|
||||
XCTAssertNil(try? fileManager.makeDirectoryAtURL(validSymlinkURL))
|
||||
}
|
||||
}
|
||||
|
||||
func testAcquireBadAuthorization()
|
||||
{
|
||||
let fileManager = SUFileManager.defaultManager()
|
||||
XCTAssertNil(try? fileManager._acquireAuthorization())
|
||||
}
|
||||
}
|
||||
@@ -67,11 +67,8 @@
|
||||
return;
|
||||
}
|
||||
|
||||
NSString *fileOperationToolPath = [bundle pathForResource:@""SPARKLE_FILEOP_TOOL_NAME ofType:@""];
|
||||
XCTAssertNotNil(fileOperationToolPath);
|
||||
|
||||
NSError *secondStageError = nil;
|
||||
if (![installer performSecondStageAllowingAuthorization:YES fileOperationToolPath:fileOperationToolPath environment:nil allowingUI:YES error:&secondStageError]) {
|
||||
if (![installer performSecondStageAllowingUI:YES error:&secondStageError]) {
|
||||
NSLog(@"Underlying error: %@", [secondStageError.userInfo objectForKey:NSUnderlyingErrorKey]);
|
||||
XCTFail(@"Second Stage failed with error: %@", secondStageError);
|
||||
return;
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
//
|
||||
// SUFileOperationConstants.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 6/5/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
extern char * const SUFileOpRemoveQuarantineCommand;
|
||||
extern char * const SUFileOpCopyCommand;
|
||||
extern char * const SUFileOpMoveCommand;
|
||||
extern char * const SUFileOpChangeOwnerAndGroupCommand;
|
||||
extern char * const SUFileOpUpdateModificationAndAccessTimeCommand;
|
||||
extern char * const SUFileOpMakeDirectoryCommand;
|
||||
extern char * const SUFileOpRemoveCommand;
|
||||
extern char * const SUFileOpInstallCommand;
|
||||
@@ -1,18 +0,0 @@
|
||||
//
|
||||
// SUFileOperationConstants.m
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 6/5/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUFileOperationConstants.h"
|
||||
|
||||
char * const SUFileOpRemoveQuarantineCommand = "xattr-d-apple-quarantine";
|
||||
char * const SUFileOpCopyCommand = "cp";
|
||||
char * const SUFileOpMoveCommand = "mv";
|
||||
char * const SUFileOpChangeOwnerAndGroupCommand = "chown";
|
||||
char * const SUFileOpUpdateModificationAndAccessTimeCommand = "touch";
|
||||
char * const SUFileOpMakeDirectoryCommand = "mkdir";
|
||||
char * const SUFileOpRemoveCommand = "rm";
|
||||
char * const SUFileOpInstallCommand = "installer";
|
||||
-151
@@ -1,151 +0,0 @@
|
||||
//
|
||||
// fileop.m
|
||||
// fileop
|
||||
//
|
||||
// Created by Mayur Pawashe on 6/5/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUFileManager.h"
|
||||
#import "SUFileOperationConstants.h"
|
||||
|
||||
// If we fail, we exit with a unique status code
|
||||
// We don't try to NSLog because the logs can't be seen anywhere,
|
||||
// and we don't want to log to a file irresponsibly (especially as root),
|
||||
// nor want to communicate to the parent forcing the parent to read from the stdout pipe
|
||||
// (allowing us to avoid any sort of potential blocking issues?)
|
||||
typedef NS_ENUM(uint8_t, SUFileOpError)
|
||||
{
|
||||
SUWritePIDFailure = 0x02,
|
||||
SUFlushFailure = 0x03,
|
||||
SUInsufficientNumberOfArguments = 0x04,
|
||||
SUCommandNameUTF8ParseFailure = 0x05,
|
||||
SUPathUTF8ParseFailure = 0x06,
|
||||
SUQuarantineRemovalFailure = 0x07,
|
||||
SUCopyFailure = 0x08,
|
||||
SUMoveFailure = 0x09,
|
||||
SUChangeOwnerAndGroupFailure = 0x0A,
|
||||
SUTouchFailure = 0x0B,
|
||||
SUMakeDirectoryFailure = 0x0C,
|
||||
SURemoveFailure = 0x0D,
|
||||
SUPackageFailureStatusCode = 0x0E,
|
||||
SUPackageRaisedExceptionFailure = 0x0F,
|
||||
SUInvalidCommandFailure = 0x10,
|
||||
// This code can be OR'd with another one to produce a unique combination
|
||||
SUInvalidOrNoDestination = 0x80
|
||||
};
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
@autoreleasepool {
|
||||
// Before we do anything, we should let the parent know our pid so they can wait() on us
|
||||
// We do this because AuthorizationExecuteWithPrivileges() has no way of reporting back the child pid,
|
||||
// but it does give us a communication pipe
|
||||
uint32_t pid = CFSwapInt32HostToLittle((uint32_t)getpid());
|
||||
if (fwrite(&pid, sizeof(pid), 1, stdout) < 1) {
|
||||
exit(SUWritePIDFailure);
|
||||
}
|
||||
|
||||
if (fflush(stdout) != 0) {
|
||||
exit(SUFlushFailure);
|
||||
}
|
||||
|
||||
// At least we need the command name and file path arguments
|
||||
if (argc < 3) {
|
||||
exit(SUInsufficientNumberOfArguments);
|
||||
}
|
||||
|
||||
NSString *command = [[NSString alloc] initWithUTF8String:argv[1]];
|
||||
if (command == nil) {
|
||||
exit(SUCommandNameUTF8ParseFailure);
|
||||
}
|
||||
|
||||
NSString *filepath = [[NSString alloc] initWithUTF8String:argv[2]];
|
||||
if (filepath == nil) {
|
||||
exit(SUPathUTF8ParseFailure);
|
||||
}
|
||||
|
||||
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
|
||||
if (fileURL == nil) {
|
||||
exit(SUPathUTF8ParseFailure);
|
||||
}
|
||||
|
||||
NSURL *destinationURL = nil;
|
||||
if (argc >= 4) {
|
||||
NSString *destinationPath = [[NSString alloc] initWithUTF8String:argv[3]];
|
||||
if (destinationPath != nil) {
|
||||
destinationURL = [NSURL fileURLWithPath:destinationPath];
|
||||
}
|
||||
}
|
||||
|
||||
// This tool should be executed as root, so we should not try to authorize
|
||||
SUFileManager *fileManager = [SUFileManager defaultManager];
|
||||
|
||||
if ([command isEqualToString:@(SUFileOpRemoveQuarantineCommand)]) {
|
||||
if (![fileManager releaseItemFromQuarantineAtRootURL:fileURL error:NULL]) {
|
||||
exit(SUQuarantineRemovalFailure);
|
||||
}
|
||||
} else if ([command isEqualToString:@(SUFileOpCopyCommand)]) {
|
||||
if (destinationURL != nil) {
|
||||
if (![fileManager copyItemAtURL:fileURL toURL:destinationURL error:NULL]) {
|
||||
exit(SUCopyFailure);
|
||||
}
|
||||
} else {
|
||||
exit(SUInvalidOrNoDestination | SUCopyFailure);
|
||||
}
|
||||
} else if ([command isEqualToString:@(SUFileOpMoveCommand)]) {
|
||||
if (destinationURL != nil) {
|
||||
if (![fileManager moveItemAtURL:fileURL toURL:destinationURL error:NULL]) {
|
||||
exit(SUMoveFailure);
|
||||
}
|
||||
} else {
|
||||
exit(SUInvalidOrNoDestination | SUMoveFailure);
|
||||
}
|
||||
} else if ([command isEqualToString:@(SUFileOpChangeOwnerAndGroupCommand)]) {
|
||||
if (destinationURL != nil) {
|
||||
if (![fileManager changeOwnerAndGroupOfItemAtRootURL:fileURL toMatchURL:destinationURL error:NULL]) {
|
||||
exit(SUChangeOwnerAndGroupFailure);
|
||||
}
|
||||
} else {
|
||||
exit(SUInvalidOrNoDestination | SUChangeOwnerAndGroupFailure);
|
||||
}
|
||||
} else if ([command isEqualToString:@(SUFileOpUpdateModificationAndAccessTimeCommand)]) {
|
||||
if (![fileManager updateModificationAndAccessTimeOfItemAtURL:fileURL error:NULL]) {
|
||||
exit(SUTouchFailure);
|
||||
}
|
||||
} else if ([command isEqualToString:@(SUFileOpMakeDirectoryCommand)]) {
|
||||
if (![fileManager makeDirectoryAtURL:fileURL error:NULL]) {
|
||||
exit(SUMakeDirectoryFailure);
|
||||
}
|
||||
} else if ([command isEqualToString:@(SUFileOpRemoveCommand)]) {
|
||||
if (![fileManager removeItemAtURL:fileURL error:NULL]) {
|
||||
exit(SURemoveFailure);
|
||||
}
|
||||
} else if ([command isEqualToString:@(SUFileOpInstallCommand)]) {
|
||||
// The one command that can *only* be run as the root user
|
||||
NSString *installerPath = @"/usr/sbin/installer";
|
||||
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
task.launchPath = installerPath;
|
||||
task.arguments = @[@"-pkg", filepath, @"-target", @"/"];
|
||||
// Output won't show up anyway, so we may as well ignore it
|
||||
task.standardError = [NSPipe pipe];
|
||||
task.standardOutput = [NSPipe pipe];
|
||||
|
||||
@try {
|
||||
[task launch];
|
||||
[task waitUntilExit];
|
||||
if (task.terminationStatus != EXIT_SUCCESS) {
|
||||
exit(SUPackageFailureStatusCode);
|
||||
}
|
||||
} @catch (NSException *) {
|
||||
exit(SUPackageRaisedExceptionFailure);
|
||||
}
|
||||
} else {
|
||||
exit(SUInvalidCommandFailure);
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user