diff --git a/Configurations/ConfigCommon.xcconfig b/Configurations/ConfigCommon.xcconfig index 89337f25..d9e78800 100644 --- a/Configurations/ConfigCommon.xcconfig +++ b/Configurations/ConfigCommon.xcconfig @@ -31,7 +31,8 @@ MACOSX_DEPLOYMENT_TARGET = 10.7 PRODUCT_NAME = ${TARGET_NAME} PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier} -GCC_PREPROCESSOR_DEFINITIONS = SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" +GCC_PREPROCESSOR_DEFINITIONS = 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)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" + CLANG_ENABLE_OBJC_ARC = YES // Enable warnings diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index e4300633..82d9b56b 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -423,15 +423,15 @@ // Copy the relauncher into a temporary directory so we can get to it after the new version's installed. // Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems. - NSString *const relaunchPathToCopy = [sparkleBundle pathForResource:[[sparkleBundle infoDictionary] objectForKey:SURelaunchToolNameKey] ofType:@"app"]; + NSString *const relaunchToolName = @"" SPARKLE_RELAUNCH_TOOL_NAME; + NSString *const relaunchPathToCopy = [sparkleBundle pathForResource:relaunchToolName ofType:@"app"]; if (relaunchPathToCopy != nil) { NSString *targetPath = [self.host.appCachePath stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]]; // Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems. NSError *error = nil; [[NSFileManager defaultManager] createDirectoryAtPath:[targetPath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:@{} error:&error]; - - BOOL appendVersion = [[sparkleBundle infoDictionary][SUAppendVersionNumberKey] boolValue]; - if ([SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:nil appendVersion:appendVersion error:&error]) { + + if ([SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:nil appendVersion:SPARKLE_APPEND_VERSION_NUMBER error:&error]) { self.relaunchPath = targetPath; } else { [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{ diff --git a/Sparkle/SUConstants.h b/Sparkle/SUConstants.h index dadef0c2..b717d843 100644 --- a/Sparkle/SUConstants.h +++ b/Sparkle/SUConstants.h @@ -51,11 +51,10 @@ extern NSString *const SUPromptUserOnFirstLaunchKey; extern NSString *const SUKeepDownloadOnFailedInstallKey; extern NSString *const SUDefaultsDomainKey; extern NSString *const SUFixedHTMLDisplaySizeKey __attribute__((deprecated("This key is obsolete and has no effect."))); - -extern NSString *const SUAppendVersionNumberKey; -extern NSString *const SUEnableAutomatedDowngradesKey; -extern NSString *const SUNormalizeInstalledApplicationNameKey; -extern NSString *const SURelaunchToolNameKey; +extern NSString *const SUAppendVersionNumberKey __attribute__((deprecated("This key is obsolete. See SPARKLE_APPEND_VERSION_NUMBER."))); +extern NSString *const SUEnableAutomatedDowngradesKey __attribute__((deprecated("This key is obsolete. See SPARKLE_AUTOMATED_DOWNGRADES."))); +extern NSString *const SUNormalizeInstalledApplicationNameKey __attribute__((deprecated("This key is obsolete. SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME."))); +extern NSString *const SURelaunchToolNameKey __attribute__((deprecated("This key is obsolete. SPARKLE_RELAUNCH_TOOL_NAME."))); // ----------------------------------------------------------------------------- // Appcast keys:: diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index 62033380..496f1760 100644 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -97,7 +97,7 @@ typedef struct { - (NSString *)installationPath { - if ([[self.sparkleBundle infoDictionary][SUNormalizeInstalledApplicationNameKey] boolValue]) { + if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) { // We'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name. NSString *normalizedAppPath = [[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[self.bundle bundlePath] pathExtension]]]; if (![[NSFileManager defaultManager] fileExistsAtPath:[[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[self.bundle bundlePath] pathExtension]]]]) { diff --git a/Sparkle/SUPlainInstaller.m b/Sparkle/SUPlainInstaller.m index 03fe061d..95afaba0 100644 --- a/Sparkle/SUPlainInstaller.m +++ b/Sparkle/SUPlainInstaller.m @@ -18,8 +18,10 @@ { SUParameterAssert(host); + BOOL allowDowngrades = SPARKLE_AUTOMATED_DOWNGRADES; + // Prevent malicious downgrades - if (![[host.sparkleBundle infoDictionary][SUEnableAutomatedDowngradesKey] boolValue]) { + if (!allowDowngrades) { if ([comparator compareVersion:[host version] toVersion:[[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]] == NSOrderedDescending) { NSString *errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Possible attack in progress! Attempting to \"upgrade\" from %@ to %@. Aborting update.", [host version], [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]]; NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:@{ NSLocalizedDescriptionKey: errorMessage }]; @@ -32,10 +34,9 @@ NSError *error = nil; NSString *oldPath = [host bundlePath]; NSString *tempName = [self temporaryNameForPath:[host installationPath]]; - BOOL appendVersion = [[host.sparkleBundle infoDictionary][SUAppendVersionNumberKey] boolValue]; - BOOL result = [self copyPathWithAuthentication:path overPath:installationPath temporaryName:tempName appendVersion:appendVersion error:&error]; - + BOOL result = [self copyPathWithAuthentication:path overPath:installationPath temporaryName:tempName appendVersion:SPARKLE_APPEND_VERSION_NUMBER error:&error]; + if (result) { if ([SUCodeSigningVerifier applicationAtPathIsCodeSigned:installationPath]) { result = [SUCodeSigningVerifier codeSignatureIsValidAtPath:installationPath error:&error]; @@ -46,7 +47,7 @@ BOOL haveOld = [[NSFileManager defaultManager] fileExistsAtPath:oldPath]; BOOL differentFromNew = ![oldPath isEqualToString:installationPath]; if (haveOld && differentFromNew) { - [self _movePathToTrash:oldPath appendVersion:appendVersion]; // On success, trash old copy if there's still one due to renaming. + [self _movePathToTrash:oldPath appendVersion:SPARKLE_APPEND_VERSION_NUMBER]; // On success, trash old copy if there's still one due to renaming. } } diff --git a/Sparkle/Sparkle-Info.plist b/Sparkle/Sparkle-Info.plist index 9efef523..0caff79f 100644 --- a/Sparkle/Sparkle-Info.plist +++ b/Sparkle/Sparkle-Info.plist @@ -24,13 +24,5 @@ ${CURRENT_PROJECT_VERSION} NSPrincipalClass - SUAppendVersionNumber - ${SPARKLE_APPEND_VERSION_NUMBER} - SUEnableAutomatedDowngrades - ${SPARKLE_AUTOMATED_DOWNGRADES} - SUNormalizeInstalledApplicationName - ${SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME} - SURelaunchToolName - ${SPARKLE_RELAUNCH_TOOL_NAME}