mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Allow tagging installation type in appcast item enclosure
This is now necessary for package type installations so we can know whether or not we should authenticate ahead of time. Of course, we also verify that the download contains the type of installation we expect (because the appcast is not very trusted).
This commit is contained in:
1 parent
35801a22f2
commit
1384b5a80f
19 files changed
+142
-38
No files matched your search
+18
-11
@@ -26,6 +26,7 @@
|
||||
#import "SUInstallerCommunicationProtocol.h"
|
||||
#import "AgentConnection.h"
|
||||
#import "SUInstallerAgentProtocol.h"
|
||||
#import "SUInstallationType.h"
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#error This is a "daemon-safe" class and should NOT import AppKit
|
||||
@@ -375,20 +376,26 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
NSBundle *hostBundle = [NSBundle bundleWithPath:nonNullInstallationData.hostBundlePath];
|
||||
SUHost *host = [[SUHost alloc] initWithBundle:hostBundle];
|
||||
|
||||
NSString *bundleIdentifier = hostBundle.bundleIdentifier;
|
||||
if (bundleIdentifier == nil || ![bundleIdentifier isEqualToString:self.hostBundleIdentifier]) {
|
||||
SULog(@"Error: Failed to match host bundle identifiers %@ and %@", self.hostBundleIdentifier, bundleIdentifier);
|
||||
NSString *installationType = nonNullInstallationData.installationType;
|
||||
if (!SUValidInstallationType(installationType)) {
|
||||
SULog(@"Error: Received invalid installation type: %@", installationType);
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
} else {
|
||||
// This will be important later
|
||||
if (nonNullInstallationData.relaunchPath == nil) {
|
||||
SULog(@"Error: Failed to obtain relaunch path from installation data");
|
||||
NSString *bundleIdentifier = hostBundle.bundleIdentifier;
|
||||
if (bundleIdentifier == nil || ![bundleIdentifier isEqualToString:self.hostBundleIdentifier]) {
|
||||
SULog(@"Error: Failed to match host bundle identifiers %@ and %@", self.hostBundleIdentifier, bundleIdentifier);
|
||||
[self cleanupAndExitWithStatus:EXIT_FAILURE];
|
||||
} else {
|
||||
self.host = host;
|
||||
self.installationData = installationData;
|
||||
|
||||
[self extractAndInstallUpdate];
|
||||
// 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;
|
||||
|
||||
[self extractAndInstallUpdate];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -436,7 +443,7 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
|
||||
|
||||
dispatch_async(self.installerQueue, ^{
|
||||
NSError *installerError = nil;
|
||||
id <SUInstallerProtocol> installer = [SUInstaller installerForHost:self.host updateDirectory:self.installationData.updateDirectoryPath allowingInteraction:self.allowsInteraction versionComparator:[SUStandardVersionComparator standardVersionComparator] error:&installerError];
|
||||
id <SUInstallerProtocol> installer = [SUInstaller installerForHost:self.host expectedInstallationType:self.installationData.installationType updateDirectory:self.installationData.updateDirectoryPath allowingInteraction:self.allowsInteraction versionComparator:[SUStandardVersionComparator standardVersionComparator] error:&installerError];
|
||||
|
||||
if (installer == nil) {
|
||||
SULog(@"Error: Failed to create installer instance with error: %@", installerError);
|
||||
|
||||
@@ -20,12 +20,13 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
* dsaSignature - DSA signature for the update that came from the appcast item
|
||||
* decryptionPassword - optional decryption password for dmg archives
|
||||
*/
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath 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 installationType:(NSString *)installationType dsaSignature:(NSString *)dsaSignature decryptionPassword:(nullable NSString *)decryptionPassword;
|
||||
|
||||
@property (nonatomic, copy, readonly) NSString *relaunchPath;
|
||||
@property (nonatomic, copy, readonly) NSString *hostBundlePath;
|
||||
@property (nonatomic, copy, readonly) NSString *updateDirectoryPath;
|
||||
@property (nonatomic, copy, readonly) NSString *downloadName;
|
||||
@property (nonatomic, copy, readonly) NSString *installationType;
|
||||
@property (nonatomic, copy, readonly) NSString *dsaSignature;
|
||||
@property (nonatomic, copy, readonly, nullable) NSString *decryptionPassword;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#import "SUInstallationInputData.h"
|
||||
#import "SUInstallationType.h"
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#error This is a "daemon-safe" class and should NOT import AppKit
|
||||
@@ -18,6 +19,7 @@ static NSString *SUUpdateDirectoryPathKey = @"SUUpdateDirectoryPath";
|
||||
static NSString *SUDownloadNameKey = @"SUDownloadName";
|
||||
static NSString *SUDSASignatureKey = @"SUDSASignature";
|
||||
static NSString *SUDecryptionPasswordKey = @"SUDecryptionPassword";
|
||||
static NSString *SUInstallationTypeKey = @"SUInstallationType";
|
||||
|
||||
@implementation SUInstallationInputData
|
||||
|
||||
@@ -27,8 +29,9 @@ static NSString *SUDecryptionPasswordKey = @"SUDecryptionPassword";
|
||||
@synthesize downloadName = _downloadName;
|
||||
@synthesize dsaSignature = _dsaSignature;
|
||||
@synthesize decryptionPassword = _decryptionPassword;
|
||||
@synthesize installationType = _installationType;
|
||||
|
||||
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath 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 installationType:(NSString *)installationType dsaSignature:(NSString *)dsaSignature decryptionPassword:(nullable NSString *)decryptionPassword
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
@@ -36,6 +39,10 @@ static NSString *SUDecryptionPasswordKey = @"SUDecryptionPassword";
|
||||
_hostBundlePath = [hostBundlePath copy];
|
||||
_updateDirectoryPath = [updateDirectoryPath copy];
|
||||
_downloadName = [downloadName copy];
|
||||
|
||||
_installationType = [installationType copy];
|
||||
assert(SUValidInstallationType(_installationType));
|
||||
|
||||
_dsaSignature = [dsaSignature copy];
|
||||
_decryptionPassword = [decryptionPassword copy];
|
||||
}
|
||||
@@ -64,6 +71,11 @@ static NSString *SUDecryptionPasswordKey = @"SUDecryptionPassword";
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *installationType = [decoder decodeObjectOfClass:[NSString class] forKey:SUInstallationTypeKey];
|
||||
if (!SUValidInstallationType(installationType)) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
NSString *dsaSignature = [decoder decodeObjectOfClass:[NSString class] forKey:SUDSASignatureKey];
|
||||
if (dsaSignature == nil) {
|
||||
return nil;
|
||||
@@ -71,7 +83,7 @@ static NSString *SUDecryptionPasswordKey = @"SUDecryptionPassword";
|
||||
|
||||
NSString *decryptionPassword = [decoder decodeObjectOfClass:[NSString class] forKey:SUDecryptionPasswordKey];
|
||||
|
||||
return [self initWithRelaunchPath:relaunchPath hostBundlePath:hostBundlePath updateDirectoryPath:updateDirectoryPath downloadName:downloadName dsaSignature:dsaSignature decryptionPassword:decryptionPassword];
|
||||
return [self initWithRelaunchPath:relaunchPath hostBundlePath:hostBundlePath updateDirectoryPath:updateDirectoryPath downloadName:downloadName installationType:installationType dsaSignature:dsaSignature decryptionPassword:decryptionPassword];
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(NSCoder *)coder
|
||||
@@ -79,6 +91,7 @@ static NSString *SUDecryptionPasswordKey = @"SUDecryptionPassword";
|
||||
[coder encodeObject:self.relaunchPath forKey:SURelaunchPathKey];
|
||||
[coder encodeObject:self.hostBundlePath forKey:SUHostBundlePathKey];
|
||||
[coder encodeObject:self.updateDirectoryPath forKey:SUUpdateDirectoryPathKey];
|
||||
[coder encodeObject:self.installationType forKey:SUInstallationTypeKey];
|
||||
[coder encodeObject:self.downloadName forKey:SUDownloadNameKey];
|
||||
[coder encodeObject:self.dsaSignature forKey:SUDSASignatureKey];
|
||||
if (self.decryptionPassword != nil) {
|
||||
|
||||
@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SUInstaller : NSObject
|
||||
|
||||
+ (nullable id<SUInstallerProtocol>)installerForHost:(SUHost *)host updateDirectory:(NSString *)updateDirectory allowingInteraction:(BOOL)allowsInteraction versionComparator:(id <SUVersionComparison>)comparator error:(NSError **)error;
|
||||
+ (nullable id<SUInstallerProtocol>)installerForHost:(SUHost *)host expectedInstallationType:(NSString *)expectedInstallationType updateDirectory:(NSString *)updateDirectory allowingInteraction:(BOOL)allowsInteraction versionComparator:(id <SUVersionComparison>)comparator error:(NSError **)error;
|
||||
|
||||
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(nullable BOOL *)isGuidedPtr;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#import "SULog.h"
|
||||
#import "SUParameterAssert.h"
|
||||
#import "SUErrors.h"
|
||||
#import "SUInstallationType.h"
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#error This is a "core" class and should NOT import AppKit
|
||||
@@ -112,7 +113,7 @@
|
||||
return newAppDownloadPath;
|
||||
}
|
||||
|
||||
+ (nullable id<SUInstallerProtocol>)installerForHost:(SUHost *)host updateDirectory:(NSString *)updateDirectory allowingInteraction:(BOOL)allowsInteraction versionComparator:(id <SUVersionComparison>)comparator error:(NSError * __autoreleasing *)error
|
||||
+ (nullable id<SUInstallerProtocol>)installerForHost:(SUHost *)host expectedInstallationType:(NSString *)expectedInstallationType updateDirectory:(NSString *)updateDirectory allowingInteraction:(BOOL)allowsInteraction versionComparator:(id <SUVersionComparison>)comparator error:(NSError * __autoreleasing *)error
|
||||
{
|
||||
BOOL isPackage = NO;
|
||||
BOOL isGuided = NO;
|
||||
@@ -125,16 +126,43 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
// If the installer does not allow interaction, we could be running as root
|
||||
// If we are running as root, using a non-guided package installer does not work properly so avoid it at all costs
|
||||
// Make sure we find the type of installer that we were expecting to find
|
||||
// We shouldn't implicitly trust the installation type fed into here from the appcast because the installation type helps us determine
|
||||
// ahead of time whether or not this installer tool should be ran as root or not
|
||||
id <SUInstallerProtocol> installer = nil;
|
||||
if (isPackage && (isGuided || !allowsInteraction)) {
|
||||
installer = [[SUGuidedPackageInstaller alloc] initWithPackagePath:newDownloadPath];
|
||||
if (isPackage && isGuided) {
|
||||
if (![expectedInstallationType isEqualToString:SUInstallationTypeGuidedPackage]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Found guided package installer but '%@=%@' was probably missing in the appcast item enclosure", SUAppcastAttributeInstallationType, SUInstallationTypeGuidedPackage] }];
|
||||
}
|
||||
} else {
|
||||
installer = [[SUGuidedPackageInstaller alloc] initWithPackagePath:newDownloadPath];
|
||||
}
|
||||
} else if (isPackage) {
|
||||
installer = [[SUPackageInstaller alloc] initWithPackagePath:newDownloadPath];
|
||||
if (![expectedInstallationType isEqualToString:SUInstallationTypePackage]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Found package installer but '%@=%@' was probably missing in the appcast item enclosure", SUAppcastAttributeInstallationType, SUInstallationTypePackage] }];
|
||||
}
|
||||
} else {
|
||||
#warning review this
|
||||
// Even if we expect an ordinary package, if we don't allow interaction (eg: because we're already running root) -
|
||||
// we should try a guided installation instead - because an ordinary package installation may not work well
|
||||
if (allowsInteraction) {
|
||||
installer = [[SUPackageInstaller alloc] initWithPackagePath:newDownloadPath];
|
||||
} else {
|
||||
installer = [[SUGuidedPackageInstaller alloc] initWithPackagePath:newDownloadPath];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
installer = [[SUPlainInstaller alloc] initWithHost:host applicationPath:newDownloadPath installationPath:[[self class] installationPathForHost:host] versionComparator:comparator];
|
||||
if (![expectedInstallationType isEqualToString:SUInstallationTypeApplication]) {
|
||||
if (error != NULL) {
|
||||
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Found regular application update but expected '%@=%@' from the appcast item enclosure instead", SUAppcastAttributeInstallationType, expectedInstallationType] }];
|
||||
}
|
||||
} else {
|
||||
installer = [[SUPlainInstaller alloc] initWithHost:host applicationPath:newDownloadPath installationPath:[[self class] installationPathForHost:host] versionComparator:comparator];
|
||||
}
|
||||
}
|
||||
|
||||
return installer;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,9 +58,9 @@ static NSString *SUInstallerConnectionKeepAliveReason = @"Installer Connection K
|
||||
[self enableAutomaticTermination];
|
||||
}
|
||||
|
||||
- (void)setServiceName:(NSString *)serviceName hostPath:(NSString *)hostPath guided:(BOOL)guided
|
||||
- (void)setServiceName:(NSString *)serviceName hostPath:(NSString *)hostPath installationType:(NSString *)installationType
|
||||
{
|
||||
NSXPCConnectionOptions options = SUNeedsSystemAuthorizationAccess(hostPath, guided, NULL) ? NSXPCConnectionPrivileged : 0;
|
||||
NSXPCConnectionOptions options = SUNeedsSystemAuthorizationAccess(hostPath, installationType, NULL) ? NSXPCConnectionPrivileged : 0;
|
||||
NSXPCConnection *connection = [[NSXPCConnection alloc] initWithMachServiceName:serviceName options:options];
|
||||
|
||||
connection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerCommunicationProtocol)];
|
||||
|
||||
@@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
- (void)setInvalidationHandler:(void (^)(void))invalidationHandler;
|
||||
|
||||
- (void)setServiceName:(NSString *)serviceName hostPath:(NSString *)hostPath guided:(BOOL)guided;
|
||||
- (void)setServiceName:(NSString *)serviceName hostPath:(NSString *)hostPath installationType:(NSString *)installationType;
|
||||
|
||||
- (void)invalidate;
|
||||
|
||||
|
||||
@@ -59,9 +59,9 @@
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)setServiceName:(NSString *)serviceName hostPath:(NSString *)hostPath guided:(BOOL)guided
|
||||
- (void)setServiceName:(NSString *)serviceName hostPath:(NSString *)hostPath installationType:(NSString *)installationType
|
||||
{
|
||||
[self.connection.remoteObjectProxy setServiceName:serviceName hostPath:hostPath guided:guided];
|
||||
[self.connection.remoteObjectProxy setServiceName:serviceName hostPath:hostPath installationType:installationType];
|
||||
}
|
||||
|
||||
- (void)handleMessageWithIdentifier:(int32_t)identifier data:(NSData *)data
|
||||
|
||||
@@ -264,13 +264,13 @@
|
||||
return reply;
|
||||
}
|
||||
|
||||
- (void)launchInstallerAtPath:(NSString *)installerPath progressToolPath:(NSString *)progressToolPath withHostBundlePath:(NSString *)hostBundlePath authorizationPrompt:(NSString *)authorizationPrompt guidedInstallation:(BOOL)guidedInstallation allowingInteraction:(BOOL)allowingInteraction completion:(void (^)(SUAuthorizationReply))completionHandler
|
||||
- (void)launchInstallerAtPath:(NSString *)installerPath progressToolPath:(NSString *)progressToolPath withHostBundlePath:(NSString *)hostBundlePath authorizationPrompt:(NSString *)authorizationPrompt installationType:(NSString *)installationType allowingInteraction:(BOOL)allowingInteraction completion:(void (^)(SUAuthorizationReply))completionHandler
|
||||
{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSBundle *hostBundle = [NSBundle bundleWithPath:hostBundlePath];
|
||||
|
||||
BOOL preflighted = NO;
|
||||
BOOL needsSystemAuthorization = SUNeedsSystemAuthorizationAccess(hostBundlePath, guidedInstallation, &preflighted);
|
||||
BOOL needsSystemAuthorization = SUNeedsSystemAuthorizationAccess(hostBundlePath, installationType, &preflighted);
|
||||
|
||||
// if we need to use the system domain and we aren't already root and we aren't allowed interaction, then try sometime later when interaction is allowed
|
||||
if (needsSystemAuthorization && !preflighted && !allowingInteraction) {
|
||||
|
||||
@@ -11,6 +11,6 @@
|
||||
|
||||
@protocol SUInstallerLauncherProtocol
|
||||
|
||||
- (void)launchInstallerAtPath:(NSString *)installerPath progressToolPath:(NSString *)progressToolPath withHostBundlePath:(NSString *)hostBundlePath authorizationPrompt:(NSString *)authorizationPrompt guidedInstallation:(BOOL)guidedInstallation allowingInteraction:(BOOL)allowingInteraction completion:(void (^)(SUAuthorizationReply))completionHandler;
|
||||
- (void)launchInstallerAtPath:(NSString *)installerPath progressToolPath:(NSString *)progressToolPath withHostBundlePath:(NSString *)hostBundlePath authorizationPrompt:(NSString *)authorizationPrompt installationType:(NSString *)installationType allowingInteraction:(BOOL)allowingInteraction completion:(void (^)(SUAuthorizationReply))completionHandler;
|
||||
|
||||
@end
|
||||
@@ -760,6 +760,7 @@
|
||||
7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUUnarchiverTest.swift; sourceTree = "<group>"; };
|
||||
7214B87F1D456A8500CB5CED /* SUBundleIcon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBundleIcon.h; sourceTree = "<group>"; };
|
||||
7214B8801D456A8500CB5CED /* SUBundleIcon.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBundleIcon.m; sourceTree = "<group>"; };
|
||||
7214B8851D45AD9A00CB5CED /* SUInstallationType.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SUInstallationType.h; 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>"; };
|
||||
721652671D3C8FED00FD13D8 /* SUAuthorizationReply.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SUAuthorizationReply.h; path = InstallerLauncher/SUAuthorizationReply.h; sourceTree = SOURCE_ROOT; };
|
||||
@@ -1385,6 +1386,7 @@
|
||||
61B5FB9509C4F04600B25A18 /* SUAppcast.m */,
|
||||
61B5FC5309C5182000B25A18 /* SUAppcastItem.h */,
|
||||
61B5FC5409C5182000B25A18 /* SUAppcastItem.m */,
|
||||
7214B8851D45AD9A00CB5CED /* SUInstallationType.h */,
|
||||
72B09CE51CE6BCBD0052EF9E /* SUURLDownload.h */,
|
||||
72B09CE61CE6BCBD0052EF9E /* SUURLDownload.m */,
|
||||
7293A1AC1CEE933800B957A7 /* SUURLRequest.h */,
|
||||
|
||||
Vendored
+1
@@ -30,6 +30,7 @@ SU_EXPORT @interface SUAppcastItem : NSObject<NSSecureCoding>
|
||||
@property (copy, readonly) NSString *displayVersionString;
|
||||
@property (copy, readonly) NSDictionary *deltaUpdates;
|
||||
@property (strong, readonly) NSURL *infoURL;
|
||||
@property (nonatomic, copy, readonly) NSString *installationType;
|
||||
|
||||
// Initializes with data from a dictionary provided by the RSS class.
|
||||
- (instancetype)initWithDictionary:(NSDictionary *)dict;
|
||||
|
||||
Vendored
+24
@@ -10,6 +10,7 @@
|
||||
#import "SUVersionComparisonProtocol.h"
|
||||
#import "SULog.h"
|
||||
#import "SUConstants.h"
|
||||
#import "SUInstallationType.h"
|
||||
|
||||
#ifdef _APPKITDEFINES_H
|
||||
#error This is a "core" class and should NOT import AppKit
|
||||
@@ -28,6 +29,7 @@ static NSString *SUAppcastItemReleaseNotesURLKey = @"releaseNotesURL";
|
||||
static NSString *SUAppcastItemTitleKey = @"title";
|
||||
static NSString *SUAppcastItemVersionStringKey = @"versionString";
|
||||
static NSString *SUAppcastItemPropertiesKey = @"propertiesDictionary";
|
||||
static NSString *SUAppcastItemInstallationTypeKey = @"SUAppcastItemInstallationType";
|
||||
|
||||
@implementation SUAppcastItem
|
||||
|
||||
@@ -45,6 +47,7 @@ static NSString *SUAppcastItemPropertiesKey = @"propertiesDictionary";
|
||||
@synthesize title = _title;
|
||||
@synthesize versionString = _versionString;
|
||||
@synthesize propertiesDictionary = _propertiesDictionary;
|
||||
@synthesize installationType = _installationType;
|
||||
|
||||
+ (BOOL)supportsSecureCoding
|
||||
{
|
||||
@@ -67,6 +70,11 @@ static NSString *SUAppcastItemPropertiesKey = @"propertiesDictionary";
|
||||
return nil;
|
||||
}
|
||||
|
||||
_installationType = [decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemInstallationTypeKey];
|
||||
if (!SUValidInstallationType(_installationType)) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
_itemDescription = [[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemDescriptionKey] copy];
|
||||
_maximumSystemVersion = [[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemMaximumSystemVersionKey] copy];
|
||||
_minimumSystemVersion = [[decoder decodeObjectOfClass:[NSString class] forKey:SUAppcastItemMinimumSystemVersionKey] copy];
|
||||
@@ -130,6 +138,10 @@ static NSString *SUAppcastItemPropertiesKey = @"propertiesDictionary";
|
||||
if (self.propertiesDictionary != nil) {
|
||||
[encoder encodeObject:self.propertiesDictionary forKey:SUAppcastItemPropertiesKey];
|
||||
}
|
||||
|
||||
if (self.installationType != nil) {
|
||||
[encoder encodeObject:self.installationType forKey:SUAppcastItemInstallationTypeKey];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isDeltaUpdate
|
||||
@@ -263,6 +275,18 @@ static NSString *SUAppcastItemPropertiesKey = @"propertiesDictionary";
|
||||
} else {
|
||||
_displayVersionString = [_versionString copy];
|
||||
}
|
||||
|
||||
_installationType = [enclosure objectForKey:SUAppcastAttributeInstallationType];
|
||||
if (_installationType == nil) {
|
||||
_installationType = SUInstallationTypeDefault;
|
||||
} else if (!SUValidInstallationType(_installationType)) {
|
||||
if (error != NULL) {
|
||||
*error = [NSString stringWithFormat:@"Feed item's enclosure lacks valid %@ (found %@)", SUAppcastAttributeInstallationType, _installationType];
|
||||
}
|
||||
return nil;
|
||||
} else if ([_installationType isEqualToString:SUInstallationTypePackage]) {
|
||||
SULog(@"warning: '%@' for %@ is deprecated. Use '%@' instead.", SUInstallationTypePackage, SUAppcastAttributeInstallationType, SUInstallationTypeGuidedPackage);
|
||||
}
|
||||
|
||||
// Find the appropriate release notes URL.
|
||||
NSString *releaseNotesString = [dict objectForKey:SUAppcastElementReleaseNotesLink];
|
||||
|
||||
Vendored
+1
@@ -66,6 +66,7 @@ extern NSString *const SUAppcastAttributeDeltaFrom;
|
||||
extern NSString *const SUAppcastAttributeDSASignature;
|
||||
extern NSString *const SUAppcastAttributeShortVersionString;
|
||||
extern NSString *const SUAppcastAttributeVersion;
|
||||
extern NSString *const SUAppcastAttributeInstallationType;
|
||||
|
||||
extern NSString *const SUAppcastElementCriticalUpdate;
|
||||
extern NSString *const SUAppcastElementDeltas;
|
||||
|
||||
Vendored
+1
@@ -64,6 +64,7 @@ NSString *const SUAppcastAttributeDeltaFrom = @"sparkle:deltaFrom";
|
||||
NSString *const SUAppcastAttributeDSASignature = @"sparkle:dsaSignature";
|
||||
NSString *const SUAppcastAttributeShortVersionString = @"sparkle:shortVersionString";
|
||||
NSString *const SUAppcastAttributeVersion = @"sparkle:version";
|
||||
NSString *const SUAppcastAttributeInstallationType = @"sparkle:installationType";
|
||||
|
||||
NSString *const SUAppcastElementCriticalUpdate = @"sparkle:criticalUpdate";
|
||||
NSString *const SUAppcastElementDeltas = @"sparkle:deltas";
|
||||
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
//
|
||||
// SUInstallationType.h
|
||||
// Sparkle
|
||||
//
|
||||
// Created by Mayur Pawashe on 7/24/16.
|
||||
// Copyright © 2016 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef SUInstallationType_h
|
||||
#define SUInstallationType_h
|
||||
|
||||
#define SUInstallationTypeApplication @"application" // the default installation type for ordinary application updates
|
||||
#define SUInstallationTypeGuidedPackage @"guided-package" // the preferred installation type for package installations
|
||||
#define SUInstallationTypePackage @"package" // the deprecated installation type; use guided package instead
|
||||
|
||||
#define SUInstallationTypeDefault SUInstallationTypeApplication
|
||||
#define SUInstallationTypesArray (@[SUInstallationTypeApplication, SUInstallationTypeGuidedPackage, SUInstallationTypePackage])
|
||||
#define SUValidInstallationType(x) ((x != nil) && [SUInstallationTypesArray containsObject:x])
|
||||
|
||||
#endif /* SUInstallationType_h */
|
||||
Vendored
+8
-5
@@ -125,9 +125,10 @@
|
||||
}];
|
||||
|
||||
NSString *serviceName = SUInstallerServiceNameForBundleIdentifier(hostBundleIdentifier);
|
||||
NSString *installationType = self.updateItem.installationType;
|
||||
assert(installationType != nil);
|
||||
|
||||
#warning use self.updateItem later for passing guided option
|
||||
[self.installerConnection setServiceName:serviceName hostPath:self.host.bundlePath guided:NO];
|
||||
[self.installerConnection setServiceName:serviceName hostPath:self.host.bundlePath installationType:installationType];
|
||||
|
||||
[self sendInstallationData];
|
||||
}
|
||||
@@ -169,7 +170,7 @@
|
||||
decryptionPassword = [self.updaterDelegate decryptionPasswordForUpdater:self.updater];
|
||||
}
|
||||
|
||||
SUInstallationInputData *installationData = [[SUInstallationInputData alloc] initWithRelaunchPath:pathToRelaunch 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 installationType:self.updateItem.installationType dsaSignature:dsaSignature decryptionPassword:decryptionPassword];
|
||||
|
||||
NSData *archivedData = SUArchiveRootObjectSecurely(installationData);
|
||||
if (archivedData == nil) {
|
||||
@@ -438,10 +439,12 @@
|
||||
NSString *hostBundlePath = self.host.bundle.bundlePath;
|
||||
assert(hostBundlePath != nil);
|
||||
|
||||
#warning pass actual guided flag eventually
|
||||
NSString *installationType = self.updateItem.installationType;
|
||||
assert(installationType != nil);
|
||||
|
||||
// The installer launcher could be in a XPC service, so we don't want to do localization in there
|
||||
NSString *authorizationPrompt = [NSString stringWithFormat:SULocalizedString(@"%1$@ wants to update.", nil), self.host.name];
|
||||
[installerLauncher launchInstallerAtPath:relaunchToolPath progressToolPath:progressToolPath withHostBundlePath:hostBundlePath authorizationPrompt:authorizationPrompt guidedInstallation:NO allowingInteraction:shouldAllowInstallerInteraction completion:^(SUAuthorizationReply result) {
|
||||
[installerLauncher launchInstallerAtPath:relaunchToolPath progressToolPath:progressToolPath withHostBundlePath:hostBundlePath authorizationPrompt:authorizationPrompt installationType:installationType allowingInteraction:shouldAllowInstallerInteraction completion:^(SUAuthorizationReply result) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
retrievedLaunchStatus = YES;
|
||||
[launcherConnection invalidate];
|
||||
|
||||
Vendored
+1
-1
@@ -11,6 +11,6 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
BOOL SUNeedsSystemAuthorizationAccess(NSString *path, BOOL guided, BOOL * _Nullable preflighted);
|
||||
BOOL SUNeedsSystemAuthorizationAccess(NSString *path, NSString *installationType, BOOL * _Nullable preflighted);
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Vendored
+5
-2
@@ -8,6 +8,7 @@
|
||||
|
||||
#import "SUSystemAuthorization.h"
|
||||
#import <ServiceManagement/ServiceManagement.h>
|
||||
#import "SUInstallationType.h"
|
||||
|
||||
static BOOL SUPreflightSystemAuthorization(void)
|
||||
{
|
||||
@@ -38,7 +39,7 @@ static BOOL SUPreflightSystemAuthorization(void)
|
||||
return (copyStatus == errAuthorizationSuccess);
|
||||
}
|
||||
|
||||
BOOL SUNeedsSystemAuthorizationAccess(NSString *path, BOOL guided, BOOL * _Nullable preflighted)
|
||||
BOOL SUNeedsSystemAuthorizationAccess(NSString *path, NSString *installationType, BOOL * _Nullable preflighted)
|
||||
{
|
||||
BOOL result;
|
||||
if (SUPreflightSystemAuthorization()) {
|
||||
@@ -46,8 +47,10 @@ BOOL SUNeedsSystemAuthorizationAccess(NSString *path, BOOL guided, BOOL * _Nulla
|
||||
*preflighted = YES;
|
||||
}
|
||||
result = YES;
|
||||
} else if (guided) {
|
||||
} else if ([installationType isEqualToString:SUInstallationTypeGuidedPackage]) {
|
||||
result = YES;
|
||||
} else if ([installationType isEqualToString:SUInstallationTypePackage]) {
|
||||
result = NO;
|
||||
} else {
|
||||
#warning what about symbolic links?
|
||||
NSFileManager *fileManager = [NSFileManager defaultManager];
|
||||
|
||||
Reference in new issue
Block a user