Decryption password should now be supported

This commit is contained in:
Zorg committed 2016-03-26 23:46:27 -04:00
1 parent 8184838835
commit eddf611ede
7 files changed
+28 -9

No files matched your search

+1 -2
View File
@@ -232,8 +232,7 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5;
- (void)extractAndInstallUpdate
{
#warning passing nothing for password atm
id <SUUnarchiver> unarchiver = [SUUnarchiver unarchiverForPath:self.installationData.downloadPath updatingHostBundlePath:self.host.bundlePath decryptionPassword:nil delegate:self];
id <SUUnarchiver> unarchiver = [SUUnarchiver unarchiverForPath:self.installationData.downloadPath updatingHostBundlePath:self.host.bundlePath decryptionPassword:self.installationData.decryptionPassword delegate:self];
if (!unarchiver) {
SULog(@"Error: No valid unarchiver for %@!", self.installationData.downloadPath);
[self unarchiverDidFail];
+2 -1
View File
@@ -12,13 +12,14 @@ NS_ASSUME_NONNULL_BEGIN
@interface SUInstallationInputData : NSObject <NSSecureCoding>
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadPath:(NSString *)downloadPath dsaSignature:(NSString *)dsaSignature;
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadPath:(NSString *)downloadPath 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 *downloadPath;
@property (nonatomic, copy, readonly) NSString *dsaSignature;
@property (nonatomic, copy, readonly, nullable) NSString *decryptionPassword;
@end
+10 -2
View File
@@ -13,6 +13,7 @@ static NSString *SUHostBundlePathKey = @"SUHostBundlePath";
static NSString *SUUpdateDirectoryPathKey = @"SUUpdateDirectoryPath";
static NSString *SUDownloadPathKey = @"SUDownloadPath";
static NSString *SUDSASignatureKey = @"SUDSASignature";
static NSString *SUDecryptionPasswordKey = @"SUDecryptionPassword";
@implementation SUInstallationInputData
@@ -21,8 +22,9 @@ static NSString *SUDSASignatureKey = @"SUDSASignature";
@synthesize updateDirectoryPath = _updateDirectoryPath;
@synthesize downloadPath = _downloadPath;
@synthesize dsaSignature = _dsaSignature;
@synthesize decryptionPassword = _decryptionPassword;
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadPath:(NSString *)downloadPath dsaSignature:(NSString *)dsaSignature
- (instancetype)initWithRelaunchPath:(NSString *)relaunchPath hostBundlePath:(NSString *)hostBundlePath updateDirectoryPath:(NSString *)updateDirectoryPath downloadPath:(NSString *)downloadPath dsaSignature:(NSString *)dsaSignature decryptionPassword:(nullable NSString *)decryptionPassword
{
self = [super init];
if (self != nil) {
@@ -31,6 +33,7 @@ static NSString *SUDSASignatureKey = @"SUDSASignature";
_updateDirectoryPath = [updateDirectoryPath copy];
_downloadPath = [downloadPath copy];
_dsaSignature = [dsaSignature copy];
_decryptionPassword = [decryptionPassword copy];
}
return self;
}
@@ -62,7 +65,9 @@ static NSString *SUDSASignatureKey = @"SUDSASignature";
return nil;
}
return [self initWithRelaunchPath:relaunchPath hostBundlePath:hostBundlePath updateDirectoryPath:updateDirectoryPath downloadPath:downloadPath dsaSignature:dsaSignature];
NSString *decryptionPassword = [decoder decodeObjectOfClass:[NSString class] forKey:SUDecryptionPasswordKey];
return [self initWithRelaunchPath:relaunchPath hostBundlePath:hostBundlePath updateDirectoryPath:updateDirectoryPath downloadPath:downloadPath dsaSignature:dsaSignature decryptionPassword:decryptionPassword];
}
- (void)encodeWithCoder:(NSCoder *)coder
@@ -72,6 +77,9 @@ static NSString *SUDSASignatureKey = @"SUDSASignature";
[coder encodeObject:self.updateDirectoryPath forKey:SUUpdateDirectoryPathKey];
[coder encodeObject:self.downloadPath forKey:SUDownloadPathKey];
[coder encodeObject:self.dsaSignature forKey:SUDSASignatureKey];
if (self.decryptionPassword != nil) {
[coder encodeObject:self.decryptionPassword forKey:SUDecryptionPasswordKey];
}
}
+ (BOOL)supportsSecureCoding
+6 -1
View File
@@ -217,7 +217,12 @@
NSString *dsaSignature = (self.updateItem.DSASignature == nil) ? @"" : self.updateItem.DSASignature;
SUInstallationInputData *installationData = [[SUInstallationInputData alloc] initWithRelaunchPath:pathToRelaunch hostBundlePath:self.host.bundlePath updateDirectoryPath:self.temporaryDirectory downloadPath:self.downloadPath dsaSignature:dsaSignature];
NSString *decryptionPassword = nil;
if ([self.updaterDelegate respondsToSelector:@selector(decryptionPasswordForUpdater:)]) {
decryptionPassword = [self.updaterDelegate decryptionPasswordForUpdater:self.updater];
}
SUInstallationInputData *installationData = [[SUInstallationInputData alloc] initWithRelaunchPath:pathToRelaunch hostBundlePath:self.host.bundlePath updateDirectoryPath:self.temporaryDirectory downloadPath:self.downloadPath dsaSignature:dsaSignature decryptionPassword:decryptionPassword];
NSData *archivedData = SUArchiveRootObjectSecurely(installationData);
-2
View File
@@ -70,8 +70,6 @@ SU_EXPORT @interface SUUpdater : NSObject
@property BOOL automaticallyDownloadsUpdates;
@property (nonatomic, copy) NSString *decryptionPassword;
/*!
Checks for updates, and displays progress while doing so
-1
View File
@@ -53,7 +53,6 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
@synthesize driver;
@synthesize host;
@synthesize sparkleBundle;
@synthesize decryptionPassword;
- (instancetype)initWithHostBundle:(NSBundle *)bundle userDriver:(id <SUUserDriver>)userDriver delegate:(id <SUUpdaterDelegate>)theDelegate
{
+9
View File
@@ -206,6 +206,15 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
*/
- (NSString *)pathToRelaunchForUpdater:(SUUpdater *)updater;
/*!
Returns the decryption password (if any) which is used to extract the update archive DMG.
Return nil if no password should be used.
\param updater The SUUpdater instance.
*/
- (NSString *)decryptionPasswordForUpdater:(SUUpdater *)updater;
/*!
Called before an updater shows a modal alert window,
to give the host the opportunity to hide attached windows that may get in the way.