From 984c3dc0e17a897d78e4c9bf2160521353520f22 Mon Sep 17 00:00:00 2001 From: Zorg Date: Wed, 22 Jul 2015 23:38:07 -0400 Subject: [PATCH 01/87] Rewrote file operations for updating an app The improvements we want to achieve: * Stability - No more corrupt / incomplete updates by ensuring atomic move operations * Efficiency - Faster updates because of reduction of file copies that need to be done * Separation from Host and Helper - No usage of SUFileManager in the host application * Cleanness - Minimized deprecated APIs (no FSPathMakeRef, FSGetCatalogInfo, FSFindFolder, etc), use modern Cocoa APIs when possible, robust error handling, strong documentation, easier to read code. Many other small notes: * SUFileManager does not have class methods. Methods across an instance share an AuthorizationRef, instead of having to authorize every time a privileged operation needs to be done * The odd logic of `while (authStat == errAuthorizationDenied)` was removed * Instead of checking if we have write access, we try to invoke a normal operation first. If that doesn't work, with the right error returned back, we try authorizing, which is what Apple recommends doing * The trash is not used as a temporary location anymore. Rather we now request for a temporary directory to be created. This is more likely to succeed too (eg: on a drive that has no trash folder) * The old method for releasing the quarantine did not work until I used the "com.apple.quarantine" key instead of the LS constant that was being used. * For the old method for releasing the quarantine, we now check if a file has the quarantine xattr bit set before removing it. Just like how the new method works. * Quarantines can now be removed with authorization * The result of calling temporaryNameForPath: was never actually used in the old code * -[NSString fileSystemRepresentation] which can throw an exception is not used. Only getFileSystemRepresentation:maxLength: is used and the error on it is always checked * The desperate/hopeless check for if the code signature for the update is valid after the installation is complete is removed Potential issues that still needs to be looked in to: * Currently the method to move a file to the trash only works on 10.8+ * Appending of version number / picking destination name of app moved to trash --- Sparkle.xcodeproj/project.pbxproj | 20 +- Sparkle/Autoupdate/Autoupdate.m | 3 +- Sparkle/SUBasicUpdateDriver.m | 25 +- Sparkle/SUFileManager.h | 100 +++++ Sparkle/SUFileManager.m | 642 ++++++++++++++++++++++++++++ Sparkle/SUPlainInstaller.m | 146 ++++++- Sparkle/SUPlainInstallerInternals.h | 24 -- Sparkle/SUPlainInstallerInternals.m | 639 --------------------------- 8 files changed, 899 insertions(+), 700 deletions(-) create mode 100644 Sparkle/SUFileManager.h create mode 100644 Sparkle/SUFileManager.m delete mode 100644 Sparkle/SUPlainInstallerInternals.h delete mode 100644 Sparkle/SUPlainInstallerInternals.m diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 501ba0e3..b1ba4ec1 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -69,7 +69,6 @@ 55C14F24136EF86F00649790 /* SUPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 618FA5210DAE8E8A0026945C /* SUPackageInstaller.m */; }; 55C14F2A136EF9A900649790 /* SUWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 61180BC90D64138900B4E0D1 /* SUWindowController.m */; }; 55C14F32136EFC2400649790 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 55C14F31136EFC2400649790 /* SystemConfiguration.framework */; }; - 55C14F7E136F005000649790 /* SUPlainInstallerInternals.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B5F8E509C4CE3C00B25A18 /* SUPlainInstallerInternals.m */; }; 55C14F9A136F045400649790 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B5F8F609C4CEB300B25A18 /* Security.framework */; }; 55C14FC7136F05E100649790 /* Sparkle.strings in Resources */ = {isa = PBXBuildFile; fileRef = 61AAE8220A321A7F00D8810D /* Sparkle.strings */; }; 55E6F33319EC9F6C00005E76 /* SUErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = 55E6F33219EC9F6C00005E76 /* SUErrors.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -110,7 +109,6 @@ 6120721309CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = 6120721109CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.m */; }; 61299A2F09CA2DAB00B7442F /* SUDSAVerifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 61299A2D09CA2DAB00B7442F /* SUDSAVerifier.h */; settings = {ATTRIBUTES = (); }; }; 61299A3009CA2DAB00B7442F /* SUDSAVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A2E09CA2DAB00B7442F /* SUDSAVerifier.m */; settings = {COMPILER_FLAGS = "-Wno-deprecated-declarations"; }; }; - 61299A4A09CA2DD000B7442F /* SUPlainInstallerInternals.h in Headers */ = {isa = PBXBuildFile; fileRef = 6129984309C9E2DA00B7442F /* SUPlainInstallerInternals.h */; settings = {ATTRIBUTES = (); }; }; 61299A5C09CA6D4500B7442F /* SUConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 61299A5B09CA6D4500B7442F /* SUConstants.h */; settings = {ATTRIBUTES = (); }; }; 61299A6009CA6EB100B7442F /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; }; 61299A8D09CA790200B7442F /* SUUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61299A8B09CA790200B7442F /* SUUnarchiver.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -141,7 +139,6 @@ 61B078CF15A5FB6100600039 /* SUCodeSigningVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B078CD15A5FB6100600039 /* SUCodeSigningVerifier.m */; }; 61B5F8ED09C4CE3C00B25A18 /* SUUpdater.h in Headers */ = {isa = PBXBuildFile; fileRef = 61B5F8E309C4CE3C00B25A18 /* SUUpdater.h */; settings = {ATTRIBUTES = (Public, ); }; }; 61B5F8EE09C4CE3C00B25A18 /* SUUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B5F8E409C4CE3C00B25A18 /* SUUpdater.m */; }; - 61B5F8EF09C4CE3C00B25A18 /* SUPlainInstallerInternals.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B5F8E509C4CE3C00B25A18 /* SUPlainInstallerInternals.m */; }; 61B5F8F709C4CEB300B25A18 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B5F8F609C4CEB300B25A18 /* Security.framework */; }; 61B5F90F09C4CF3A00B25A18 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; }; 61B5F92E09C4CFD800B25A18 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 61B5F92A09C4CFD800B25A18 /* InfoPlist.strings */; }; @@ -174,6 +171,9 @@ 721CF1AB1AD764EB00D9AC09 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D06E8FB0FD68D61005AE3F6 /* libbz2.dylib */; }; 7223E7631AD1AEFF008E3161 /* sais.c in Sources */ = {isa = PBXBuildFile; fileRef = 7223E7611AD1AEFF008E3161 /* sais.c */; }; 7268AC631AD634C200C3E0C1 /* SUBinaryDeltaCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */; }; + 7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */; }; + 7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; + 7275F9C31B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; 72D4DAA11AD7632900B211E2 /* SUBinaryDeltaCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */; }; 767B61AC1972D488004E0C3C /* SUGuidedPackageInstaller.h in Headers */ = {isa = PBXBuildFile; fileRef = 767B61AA1972D488004E0C3C /* SUGuidedPackageInstaller.h */; }; 767B61AD1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; }; @@ -461,7 +461,6 @@ 612279D90DB5470200AB99EA /* Sparkle Unit Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Sparkle Unit Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; 612279DA0DB5470200AB99EA /* SparkleTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "SparkleTests-Info.plist"; sourceTree = ""; }; 61227A150DB548B800AB99EA /* SUVersionComparisonTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUVersionComparisonTest.m; sourceTree = ""; }; - 6129984309C9E2DA00B7442F /* SUPlainInstallerInternals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUPlainInstallerInternals.h; sourceTree = ""; }; 61299A2D09CA2DAB00B7442F /* SUDSAVerifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUDSAVerifier.h; sourceTree = ""; }; 61299A2E09CA2DAB00B7442F /* SUDSAVerifier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUDSAVerifier.m; sourceTree = ""; }; 61299A5B09CA6D4500B7442F /* SUConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUConstants.h; sourceTree = ""; }; @@ -513,7 +512,6 @@ 61B078CD15A5FB6100600039 /* SUCodeSigningVerifier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUCodeSigningVerifier.m; sourceTree = ""; }; 61B5F8E309C4CE3C00B25A18 /* SUUpdater.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SUUpdater.h; sourceTree = ""; }; 61B5F8E409C4CE3C00B25A18 /* SUUpdater.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = SUUpdater.m; sourceTree = ""; }; - 61B5F8E509C4CE3C00B25A18 /* SUPlainInstallerInternals.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = SUPlainInstallerInternals.m; sourceTree = ""; }; 61B5F8F609C4CEB300B25A18 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; 61B5F90209C4CEE200B25A18 /* Sparkle Test App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Sparkle Test App.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 61B5F90409C4CEE200B25A18 /* TestApplication-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TestApplication-Info.plist"; sourceTree = ""; }; @@ -553,6 +551,8 @@ 7223E7621AD1AEFF008E3161 /* sais.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sais.h; sourceTree = ""; }; 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBinaryDeltaCreate.m; sourceTree = ""; }; 7268AC641AD634E400C3E0C1 /* SUBinaryDeltaCreate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBinaryDeltaCreate.h; sourceTree = ""; }; + 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUFileManager.h; sourceTree = ""; }; + 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUFileManager.m; sourceTree = ""; }; 767B61AA1972D488004E0C3C /* SUGuidedPackageInstaller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUGuidedPackageInstaller.h; sourceTree = ""; }; 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUGuidedPackageInstaller.m; sourceTree = ""; }; 8DC2EF5A0486A6940098B216 /* Sparkle-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Sparkle-Info.plist"; sourceTree = ""; }; @@ -897,8 +897,8 @@ 618FA5210DAE8E8A0026945C /* SUPackageInstaller.m */, 618FA5030DAE8AB80026945C /* SUPlainInstaller.h */, 618FA5040DAE8AB80026945C /* SUPlainInstaller.m */, - 6129984309C9E2DA00B7442F /* SUPlainInstallerInternals.h */, - 61B5F8E509C4CE3C00B25A18 /* SUPlainInstallerInternals.m */, + 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */, + 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */, ); name = Installation; sourceTree = ""; @@ -1033,11 +1033,11 @@ 767B61AC1972D488004E0C3C /* SUGuidedPackageInstaller.h in Headers */, 61EF67590E25C5B400F754E0 /* SUHost.h in Headers */, 618FA5010DAE88B40026945C /* SUInstaller.h in Headers */, + 7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */, 55C14F06136EF6DB00649790 /* SULog.h in Headers */, 618FA5220DAE8E8A0026945C /* SUPackageInstaller.h in Headers */, 6102FE460E077FCE00F85D09 /* SUPipedUnarchiver.h in Headers */, 618FA5050DAE8AB80026945C /* SUPlainInstaller.h in Headers */, - 61299A4A09CA2DD000B7442F /* SUPlainInstallerInternals.h in Headers */, 6101347B0DD2541A0049ACDF /* SUProbingUpdateDriver.h in Headers */, 61B93C090DD112FF00DCD2F8 /* SUScheduledUpdateDriver.h in Headers */, 61A225A40D1C4AC000430CCD /* SUStandardVersionComparator.h in Headers */, @@ -1411,13 +1411,13 @@ 55C14BD4136EEFCE00649790 /* Autoupdate.m in Sources */, F8761EB61ADC5E7A000C9034 /* SUCodeSigningVerifier.m in Sources */, 55C14F00136EF6B700649790 /* SUConstants.m in Sources */, + 7275F9C31B5F1F2900B1D19E /* SUFileManager.m in Sources */, 767B61AE1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */, 55C14F0C136EF6EA00649790 /* SUHost.m in Sources */, 55C14F0D136EF6F200649790 /* SUInstaller.m in Sources */, 55C14F08136EF6DB00649790 /* SULog.m in Sources */, 55C14F24136EF86F00649790 /* SUPackageInstaller.m in Sources */, 55C14F21136EF84D00649790 /* SUPlainInstaller.m in Sources */, - 55C14F7E136F005000649790 /* SUPlainInstallerInternals.m in Sources */, 55C14F22136EF86000649790 /* SUStandardVersionComparator.m in Sources */, 55C14F20136EF84300649790 /* SUStatusController.m in Sources */, 55C14F23136EF86700649790 /* SUSystemProfiler.m in Sources */, @@ -1489,10 +1489,10 @@ 618FA5230DAE8E8A0026945C /* SUPackageInstaller.m in Sources */, 61D85D6D0E10B2ED00F9B4A9 /* SUPipedUnarchiver.m in Sources */, 618FA5060DAE8AB80026945C /* SUPlainInstaller.m in Sources */, - 61B5F8EF09C4CE3C00B25A18 /* SUPlainInstallerInternals.m in Sources */, 6101347C0DD2541A0049ACDF /* SUProbingUpdateDriver.m in Sources */, 61B93C0A0DD112FF00DCD2F8 /* SUScheduledUpdateDriver.m in Sources */, 61A225A50D1C4AC000430CCD /* SUStandardVersionComparator.m in Sources */, + 7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */, 6196CFFA09C72149000DC222 /* SUStatusController.m in Sources */, 61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */, 61B93A3D0DD02D7000DCD2F8 /* SUUIBasedUpdateDriver.m in Sources */, diff --git a/Sparkle/Autoupdate/Autoupdate.m b/Sparkle/Autoupdate/Autoupdate.m index 4d4dd138..f7a97388 100644 --- a/Sparkle/Autoupdate/Autoupdate.m +++ b/Sparkle/Autoupdate/Autoupdate.m @@ -3,7 +3,6 @@ #import "SUHost.h" #import "SUStandardVersionComparator.h" #import "SUStatusController.h" -#import "SUPlainInstallerInternals.h" #import "SULog.h" #include @@ -134,7 +133,7 @@ static const NSTimeInterval SUParentQuitCheckInterval = .25; if (self.folderpath) { NSError *theError = nil; - if (![SUPlainInstaller _removeFileAtPath:[SUInstaller updateFolder] error:&theError]) + if (![[NSFileManager defaultManager] removeItemAtPath:[SUInstaller updateFolder] error:&theError]) SULog(@"Couldn't remove update folder: %@.", theError); } [[NSFileManager defaultManager] removeItemAtPath:self.selfPath error:NULL]; diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 71c4151f..6371285d 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -15,8 +15,6 @@ #import "SUUnarchiver.h" #import "SUConstants.h" #import "SULog.h" -#import "SUPlainInstaller.h" -#import "SUPlainInstallerInternals.h" #import "SUBinaryDeltaCommon.h" #import "SUCodeSigningVerifier.h" #import "SUUpdater_Private.h" @@ -420,17 +418,30 @@ } NSBundle *sparkleBundle = [NSBundle bundleWithIdentifier:SUBundleIdentifier]; - // 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"]; 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. + + NSFileManager *fileManager = [[NSFileManager alloc] init]; + + BOOL shouldAbortUpdate = NO; NSError *error = nil; - [[NSFileManager defaultManager] createDirectoryAtPath:[targetPath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:@{} error:&error]; - - if ([SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:nil error:&error]) { + if ([fileManager fileExistsAtPath:targetPath]) { + if (![fileManager removeItemAtPath:targetPath error:&error]) { + shouldAbortUpdate = YES; + } + } else { + if (![fileManager createDirectoryAtPath:[targetPath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:@{} error:&error]) { + shouldAbortUpdate = YES; + } + } + + // We only need to run our copy of the app by spawning a task + // Since we are copying the app to a directory that is write-accessible, we don't need to muck with owner/group IDs + // And since we spawn a task, we don't need to clear the quarantine bits + if (!shouldAbortUpdate && [fileManager copyItemAtPath:relaunchPathToCopy toPath:targetPath error:&error]) { self.relaunchPath = targetPath; } else { [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{ diff --git a/Sparkle/SUFileManager.h b/Sparkle/SUFileManager.h new file mode 100644 index 00000000..5f07bff0 --- /dev/null +++ b/Sparkle/SUFileManager.h @@ -0,0 +1,100 @@ +// +// SUFileManager.h +// Sparkle +// +// Created by Mayur Pawashe on 7/18/15. +// Copyright (c) 2015 zgcoder. All rights reserved. +// + +#import + +/** + * A class used for performing file operations that may also perform authentication if permission is denied when trying to + * perform them normally as the running user. All operations on this class may be used on thread other than the main thread. + * This class provides basic file operations and stays away from including much application-level logic. + */ +@interface SUFileManager : NSObject + +/** + * 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 uncommon case this name is used, the temporary directory will be created inside the directory pointed by appropriateURL + * @param appropriateURL A URL to a directory that resides on the volume that the temporary directory will be created on. In the uncommon case, the temporary directory may be created inside this directory. + * @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. + * @return A URL pointing to the newly created temporary directory, or nil with a populated error object if an error occurs. + * + * When moving an item from a source to a destination, it is desirable to create a temporary intermediate destination on the same volume as the destination to ensure + * that the item will be moved, and not copied, from the intermediate point to the final destination. This ensures file atomicity. + */ +- (NSURL *)makeTemporaryDirectoryWithPreferredName:(NSString *)preferredName appropriateForDirectoryURL:(NSURL *)appropriateURL error:(NSError **)error; + +/** + * Moves an item from a source to a destination + * @param sourceURL A URL pointing to the item to move. The item at this URL must exist. + * @param destinationURL A URL pointing to the destination the item will be moved at. An item must not already exist at this URL. + * @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. + * @return YES if the item was moved successfully, otherwise NO along with a populated error object + * + * If sourceURL and destinationURL reside on the same volume, this operation will be an atomic move operation. + * Otherwise this will be equivalent to a copy & remove which will be a nonatomic operation. + */ +- (BOOL)moveItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError **)error; + +/** + * Moves an item at a specified URL to the running user's trash directory + * @param url A URL pointing to the item to move to the trash. The item at this URL must exist. + * @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. + * @return YES if the item was moved to the trash successfully, otherwise NO along with a populated error object + * + * + * This method has to locate the trash directory and uses an intermediate temporary directory before trashing the item. + * A copy may have to be done if the url is not on the same volume as the running user's trash directory. + * If a failure occurs in the middle of this operation, the item to remove may be lost forever or stuck in a temporary location. + * + * This is not an atomic operation, nor intended to be a recoverable operation if the worst comes to worst. + */ +- (BOOL)moveItemAtURLToTrash:(NSURL *)url error:(NSError **)error; + +/** + * Removes an item at a URL + * @param url A URL pointing to the item to remove. The item at this URL must exist. + * @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. + * @return YES if the item was removed successfully, otherwise NO along with a populated error object + * + * This is not an atomic operation. + */ +- (BOOL)removeItemAtURL:(NSURL *)url error:(NSError **)error; + +/** + * Changes the owner and group IDs of an item at a specified target URL to match another URL + * @param targetURL A URL pointing to the target item whose owner and group IDs to alter. This will be applied recursively if the item is a directory. The item at this URL must exist. + * @param matchURL A URL pointing to the item whose owner and group IDs will be used for changing on the targetURL. The item at this URL must exist. + * @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. + * @return YES if the target item's owner and group IDs have changed to match the origin's ones, otherwise NO along with a populated error object + * + * If the owner and group IDs match on the root items of targetURL and matchURL, this method stops and assumes that nothing needs to be done. + * Otherwise this method recursively changes the IDs if the target is a directory. If an item in the directory is encountered that is unable to be changed, + * then this method stops and returns NO. + * + * This is not an atomic operation. + */ +- (BOOL)changeOwnerAndGroupOfItemAtRootURL:(NSURL *)targetURL toMatchURL:(NSURL *)matchURL error:(NSError **)error; + +/** + * Releases Apple's quarantine extended attribute from the item at the specified root URL + * @param rootURL A URL pointing to the item to release from Apple's quarantine. This will be applied recursively if the item is a directory. The item at this URL must exist. + * @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. + * @return YES if all the items at the target could be released from quarantine, otherwise NO if any items couldn't along with a populated error object + * + * This method removes quarantine attributes from an item, ideally an application, so that when the user launches a new application themselves, they + * don't have to witness the OS X dialog alerting them that they downloaded an application from the internet and asking if they want to continue. + * Note that this may not exactly mimic OS X's behavior when a user opens an application for the first time (i.e, the xattr isn't deleted), + * but this should be sufficient enough for our purposes. + * + * This method may return NO even if some items do get released from quarantine if the target URL is pointing to a directory. + * Thus if an item cannot be released from quarantine, this method still continues on to the next enumerated item. + * + * This is not an atomic operation. + */ +- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError **)error; + +@end diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m new file mode 100644 index 00000000..59163b8d --- /dev/null +++ b/Sparkle/SUFileManager.m @@ -0,0 +1,642 @@ +// +// SUFileManager.m +// Sparkle +// +// Created by Mayur Pawashe on 7/18/15. +// Copyright (c) 2015 zgcoder. All rights reserved. +// + +#import "SUFileManager.h" + +#include +#include + +#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000 /* MAC_OS_X_VERSION_10_10 */ +extern NSString *const NSURLQuarantinePropertiesKey WEAK_IMPORT_ATTRIBUTE; +#endif + +// Authorization code based on generous contribution from Allan Odgaard. Thanks, Allan! +static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char *executablePath, AuthorizationFlags options, char *const *arguments) +{ + sig_t oldSigChildHandler = signal(SIGCHLD, SIG_DFL); + BOOL returnValue = YES; + +#pragma clang diagnostic push + // In the future, we may have to look at SMJobBless API to avoid deprecation. See issue #558 +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + if (AuthorizationExecuteWithPrivileges(authorization, executablePath, options, arguments, NULL) == errAuthorizationSuccess) +#pragma clang diagnostic pop + { + int status; + pid_t pid = wait(&status); + if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) + returnValue = NO; + } + else + returnValue = NO; + + signal(SIGCHLD, oldSigChildHandler); + return returnValue; +} + +// 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" + +@implementation SUFileManager +{ + AuthorizationRef _auth; + NSFileManager *_fileManager; +} + +- (id)init +{ + self = [super init]; + if (self != nil) { + _fileManager = [[NSFileManager alloc] init]; + } + return self; +} + +// Acquires an authorization reference which is intended to be used for future authorized file operations +- (BOOL)acquireAuthorizationWithError:(NSError *__autoreleasing *)error +{ + // No need to continue if we already acquired an authorization reference + if (_auth != NULL) { + return YES; + } + + OSStatus status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &_auth); + if (status != errAuthorizationSuccess) { + if (error != NULL) { + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed creating authorization reference with status code %d", status] }]; + } + _auth = NULL; + return NO; + } + return YES; +} + +- (void)dealloc +{ + if (_auth != NULL) { + AuthorizationFree(_auth, kAuthorizationFlagDefaults); + } +} + +// Wrapper around getxattr() +- (ssize_t)getXAttr:(NSString *)nameString fromFile:(NSString *)file options:(int)options +{ + char path[PATH_MAX] = {0}; + if (![file getFileSystemRepresentation:path maxLength:sizeof(path)]) { + errno = 0; + return -1; + } + + const char *name = [nameString cStringUsingEncoding:NSASCIIStringEncoding]; + if (name == NULL) { + errno = 0; + return -1; + } + + return getxattr(path, name, NULL, 0, 0, options); +} + +// Wrapper around removexattr() +- (int)removeXAttr:(NSString *)name fromFile:(NSString *)file options:(int)options +{ + char path[PATH_MAX] = {0}; + if (![file getFileSystemRepresentation:path maxLength:sizeof(path)]) { + errno = 0; + return -1; + } + + const char *attr = [name cStringUsingEncoding:NSASCIIStringEncoding]; + if (attr == NULL) { + errno = 0; + return -1; + } + + return removexattr(path, attr, options); +} + +#define XATTR_UTILITY_PATH "/usr/bin/xattr" +// Recursively remove an xattr at a specified root URL with authentication +- (BOOL)removeXAttrWithAuthentication:(NSString *)name fromRootURL:(NSURL *)rootURL error:(NSError *__autoreleasing *)error +{ + if (![_fileManager fileExistsAtPath:@(XATTR_UTILITY_PATH)]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"%@ does not exist", @(XATTR_UTILITY_PATH)] }]; + } + 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:@"%@ is not a valid file system representation", rootURL.path] }]; + } + return NO; + } + + const char *xattrName = [name cStringUsingEncoding:NSASCIIStringEncoding]; + if (xattrName == NULL) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteInapplicableStringEncodingError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"%@ is not a valid ASCII convertible string", name] }]; + } + return NO; + } + + if (![self acquireAuthorizationWithError:error]) { + return NO; + } + + BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, XATTR_UTILITY_PATH, kAuthorizationFlagDefaults, (char *[]){ "-s", "-r", "-d", (char *)xattrName, path, NULL }); + + if (!success && error != NULL) { + NSString *errorMessage = [NSString stringWithFormat:@"Authenticated xattr deletion for attribute %@ failed on %@", name, rootURL.path]; + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:errorMessage }]; + } + + return success; +} + +#define APPLE_QUARANTINE_IDENTIFIER @"com.apple.quarantine" + +// Removes the directory tree rooted at |root| from the file quarantine. +// The quarantine was introduced on OS X 10.5 and is described at: +// +// http://developer.apple.com/releasenotes/Carbon/RN-LaunchServices/index.html#apple_ref/doc/uid/TP40001369-DontLinkElementID_2 +// +// If |root| is not a directory, then it alone is removed from the quarantine. +// Symbolic links, including |root| if it is a symbolic link, will not be +// traversed. +- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError * __autoreleasing *)error +{ +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000 /* MAC_OS_X_VERSION_10_10 */ + if (!&NSURLQuarantinePropertiesKey) { + return [self releaseItemUsingOldMethodFromQuarantineAtRootURL:rootURL error:error]; + } +#endif + + BOOL success = YES; + id rootResourceValue = nil; + if ([rootURL getResourceValue:&rootResourceValue forKey:NSURLQuarantinePropertiesKey error:NULL] && rootResourceValue != nil) { + NSError *setResourceError = nil; + if (![rootURL setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:&setResourceError]) { + if (NS_HAS_PERMISSION_ERROR(setResourceError)) { + return [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; + } else { + if (error != NULL) { + *error = setResourceError; + } + // Fail, but still try to release other items from quarantine + success = NO; + } + } + } + + // Only recurse if it's actually a directory. Don't recurse into a + // root-level symbolic link. + NSDictionary *rootAttributes = [_fileManager attributesOfItemAtPath:rootURL.path error:nil]; + NSString *rootType = rootAttributes[NSFileType]; + + if (rootType == NSFileTypeDirectory) { + // The NSDirectoryEnumerator will avoid recursing into any contained + // symbolic links, so no further type checks are needed. + NSDirectoryEnumerator *directoryEnumerator = [_fileManager enumeratorAtURL:rootURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil]; + + for (NSURL *file in directoryEnumerator) { + id fileResourceValue = nil; + if ([file getResourceValue:&fileResourceValue forKey:NSURLQuarantinePropertiesKey error:NULL] && fileResourceValue != nil) { + NSError *setResourceError = nil; + if (![file setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:&setResourceError]) { + if (NS_HAS_PERMISSION_ERROR(setResourceError)) { + return [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; + } else { + // Make sure we haven't already run into an error + if (success && error != NULL) { + *error = setResourceError; + } + // Fail, but still try to release other items from quarantine + success = NO; + } + } + } + } + } + + return success; +} + +// Ordinarily, the quarantine is managed by calling LSSetItemAttribute +// to set the kLSItemQuarantineProperties attribute to a dictionary specifying +// the quarantine properties to be applied. However, it does not appear to be +// possible to remove an item from the quarantine directly through any public +// Launch Services calls. Instead, this method takes advantage of the fact +// that the quarantine is implemented in part by setting an extended attribute, +// "com.apple.quarantine", on affected files. Removing this attribute is +// sufficient to remove files from the quarantine. +- (BOOL)releaseItemUsingOldMethodFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError *__autoreleasing *)error +{ + BOOL success = YES; + NSString *root = rootURL.path; + const int removeXAttrOptions = XATTR_NOFOLLOW; + + if ([self getXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:root options:removeXAttrOptions] >= 0) { + if ([self removeXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:root options:removeXAttrOptions] != 0) { + if (errno == EACCES) { + return [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; + } else { + if (error != NULL) { + *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove xattr %@ on %@", APPLE_QUARANTINE_IDENTIFIER, root] }]; + } + // Fail, but still try to release other items from quarantine + success = NO; + } + } + } + + // Only recurse if it's actually a directory. Don't recurse into a + // root-level symbolic link. + NSDictionary *rootAttributes = [_fileManager attributesOfItemAtPath:root error:nil]; + NSString *rootType = rootAttributes[NSFileType]; + + if ([rootType isEqualToString:NSFileTypeDirectory]) { + // The NSDirectoryEnumerator will avoid recursing into any contained + // symbolic links, so no further type checks are needed. + NSDirectoryEnumerator *directoryEnumerator = [_fileManager enumeratorAtPath:root]; + NSString *file = nil; + while ((file = [directoryEnumerator nextObject])) { + NSString *filePath = [root stringByAppendingPathComponent:file]; + if ([self getXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:filePath options:removeXAttrOptions] >= 0) { + if ([self removeXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:filePath options:removeXAttrOptions] != 0) { + if (errno == EACCES) { + return [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; + } else { + // Make sure we haven't already run into an error + if (success && error != NULL) { + *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove xattr %@ on %@", APPLE_QUARANTINE_IDENTIFIER, filePath] }]; + } + // Fail, but still try to release other items from quarantine + success = NO; + } + } + } + } + } + + return success; +} + +- (BOOL)moveItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError *__autoreleasing *)error +{ + if (![_fileManager fileExistsAtPath:sourceURL.path]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source %@ does not exist", sourceURL.path] }]; + } + return NO; + } + + if ([_fileManager fileExistsAtPath:destinationURL.path]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination %@ already exists", destinationURL.path] }]; + } + return NO; + } + + 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; + } + + if (![self acquireAuthorizationWithError:error]) { + 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:@"%@ is not a valid file system representation", sourceURL.path] }]; + } + 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:@"%@ is not a valid file system representation", destinationURL.path] }]; + } + return NO; + } + + if (!AuthorizationExecuteWithPrivilegesAndWait(_auth, "/bin/mv", kAuthorizationFlagDefaults, (char *[]){ "-f", sourcePath, destinationPath, NULL })) { + if (error != NULL) { + NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file move from %@ to %@ failed.", sourceURL, destinationURL]; + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:errorMessage }]; + } + return NO; + } + + return YES; +} + +- (BOOL)changeOwnerAndGroupOfItemAtRootURL:(NSURL *)targetURL toMatchURL:(NSURL *)matchURL error:(NSError * __autoreleasing *)error +{ + if (![_fileManager fileExistsAtPath:targetURL.path]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Item at target %@ does not exist", targetURL.path] }]; + } + return NO; + } + + if (![_fileManager fileExistsAtPath:matchURL.path]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Item at URL to match %@ does not exist", matchURL.path] }]; + } + return NO; + } + + NSError *matchFileAttributesError = nil; + NSDictionary *matchFileAttributes = [_fileManager attributesOfItemAtPath:matchURL.path error:&matchFileAttributesError]; + if (matchFileAttributes == nil) { + if (error != NULL) { + *error = matchFileAttributesError; + } + return NO; + } + + NSError *targetFileAttributesError = nil; + NSDictionary *targetFileAttributes = [_fileManager attributesOfItemAtPath:targetURL.path error:&targetFileAttributesError]; + if (targetFileAttributes == nil) { + if (error != NULL) { + *error = targetFileAttributesError; + } + return NO; + } + + NSNumber *ownerID = matchFileAttributes[NSFileOwnerAccountID]; + if (ownerID == nil) { + // shouldn't be possible to error here, but just in case + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadNoPermissionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"owner ID could not be read from %@", matchURL.path] }]; + } + return NO; + } + + NSNumber *groupID = matchFileAttributes[NSFileGroupOwnerAccountID]; + if (groupID == nil) { + // shouldn't be possible to error here, but just in case + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadNoPermissionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"group ID could not be read from %@", matchURL.path] }]; + } + return NO; + } + + if ([ownerID isEqualToNumber:targetFileAttributes[NSFileOwnerAccountID]] && [groupID isEqualToNumber:targetFileAttributes[NSFileGroupOwnerAccountID]]) { + // Assume they're the same even if we don't check every file recursively + // Speeds up the common case + return YES; + } + + NSDirectoryEnumerator *directoryEnumerator = [_fileManager enumeratorAtURL:targetURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil]; + BOOL needsAuth = NO; + for (NSURL *url in directoryEnumerator) { + 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:@"%@ is not a valid file system representation", url.path] }]; + } + return NO; + } + + if (chown(path, ownerID.unsignedIntValue, groupID.unsignedIntValue) != 0) { + if (errno == EPERM) { + needsAuth = YES; + break; + } else { + if (error != NULL) { + *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to chown %@ with owner ID %u and group ID %u", url.path, ownerID.unsignedIntValue, groupID.unsignedIntValue] }]; + } + return NO; + } + } + } + + 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:@"%@ is not a valid file system representation", targetURL.path] }]; + } + return NO; + } + + NSString *formattedUserAndGroupIDs = [NSString stringWithFormat:@"%u:%u", ownerID.unsignedIntValue, groupID.unsignedIntValue]; + const char *userAndGroup = [formattedUserAndGroupIDs cStringUsingEncoding:NSASCIIStringEncoding]; + if (userAndGroup == NULL) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFormattingError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Owner ID %u and Group ID %u could not be formatted", ownerID.unsignedIntValue, groupID.unsignedIntValue] }]; + } + return NO; + } + + if (![self acquireAuthorizationWithError:error]) { + return NO; + } + + BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, (char *[]){ "-R", (char *)userAndGroup, targetPath, NULL }); + if (!success && error != NULL) { + NSString *errorMessage = [NSString stringWithFormat:@"Failed to chown -R \"%@\" \"%@\" with authentication", formattedUserAndGroupIDs, targetURL.path]; + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }]; + } + + return success; +} + +// Creates a directory at the item pointed by url +// An item cannot already exist at the url, but the parent must be a directory that exists +- (BOOL)makeDirectoryAtURL:(NSURL *)url error:(NSError * __autoreleasing *)error +{ + if ([_fileManager fileExistsAtPath:url.path]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Item at %@ already exists", url.path] }]; + } + return NO; + } + + NSURL *parentURL = [url URLByDeletingLastPathComponent]; + BOOL isParentADirectory = NO; + if (![_fileManager fileExistsAtPath:parentURL.path isDirectory:&isParentADirectory] || !isParentADirectory) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Directory at %@ does not exist", parentURL.path] }]; + } + return NO; + } + + NSError *createDirectoryError = nil; + if ([_fileManager createDirectoryAtURL:url withIntermediateDirectories:NO attributes:nil error:&createDirectoryError]) { + return YES; + } + + if (!NS_HAS_PERMISSION_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:@"%@ is not a valid file system representation", url.path] }]; + } + return NO; + } + + if (![self acquireAuthorizationWithError:error]) { + return NO; + } + + BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, "/bin/mkdir", kAuthorizationFlagDefaults, (char *[]){ path, NULL }); + if (!success && error != NULL) { + NSString *errorMessage = [NSString stringWithFormat:@"Failed to make directory %@ with authentication", url.path]; + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }]; + } + return success; +} + +- (NSURL *)makeTemporaryDirectoryWithPreferredName:(NSString *)preferredName appropriateForDirectoryURL:(NSURL *)directoryURL error:(NSError * __autoreleasing *)error +{ + NSError *tempError = nil; + NSURL *tempURL = [_fileManager URLForDirectory:NSItemReplacementDirectory inDomain:NSUserDomainMask appropriateForURL:directoryURL create:YES error:&tempError]; + + if (tempURL != nil) { + return tempURL; + } + + // It is pretty unlikely in my testing we will get here, but just in case we do, we should create a directory inside + // the directory pointed by directoryURL, using the preferredName + + NSURL *desiredURL = [directoryURL URLByAppendingPathComponent:preferredName]; + NSUInteger tagIndex = 1; + while ([_fileManager fileExistsAtPath:desiredURL.path] && tagIndex <= 9999) { + desiredURL = [directoryURL URLByAppendingPathComponent:[preferredName stringByAppendingFormat:@" (%lu)", (unsigned long)++tagIndex]]; + } + + return [self makeDirectoryAtURL:desiredURL error:error] ? desiredURL : nil; +} + +- (BOOL)removeItemAtURL:(NSURL *)url error:(NSError * __autoreleasing *)error +{ + if (![_fileManager fileExistsAtPath:url.path]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Item at %@ does not exist", url.path] }]; + } + return NO; + } + + NSError *removeError = nil; + if ([_fileManager removeItemAtURL:url error:&removeError]) { + return YES; + } + + if (!NS_HAS_PERMISSION_ERROR(removeError)) { + if (error != NULL) { + *error = removeError; + } + return NO; + } + + if (![self acquireAuthorizationWithError:error]) { + 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:@"%@ is not a valid file system representation", url.path] }]; + } + return NO; + } + + BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, "/bin/rm", kAuthorizationFlagDefaults, (char *[]){ "-rf", path, NULL }); + if (!success && error != NULL) { + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to rm -rf \"%@\" with authentication", url.path] }]; + } + return success; +} + +// TODO: Fix or address that this method only runs on 10.8 or later +- (BOOL)moveItemAtURLToTrash:(NSURL *)url error:(NSError *__autoreleasing *)error +{ + if (![_fileManager fileExistsAtPath:url.path]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Item at %@ does not exist", url.path] }]; + } + return NO; + } + + // TODO: address NSTrashDirectory being only available in 10.8 or later + NSURL *trashURL = [[_fileManager URLsForDirectory:NSTrashDirectory inDomains:NSUserDomainMask] firstObject]; + if (trashURL == nil) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: @"User's Trash directory was not found" }]; + } + return NO; + } + + // In the rare worst case scenario, our temporary directory will be labeled with "Incomplete" and be in the user's trash directory, + // indicating that whatever inside of there is not yet completely moved. + // Regardless, we want the item to be in our Volume before we try moving it to the trash + NSString *preferredName = [url.lastPathComponent.stringByDeletingPathExtension stringByAppendingString:@" (Incomplete)"]; + NSURL *tempDirectory = [self makeTemporaryDirectoryWithPreferredName:preferredName appropriateForDirectoryURL:trashURL error:error]; + if (tempDirectory == nil) { + return NO; + } + + NSURL *tempItemURL = [tempDirectory URLByAppendingPathComponent:url.lastPathComponent]; + if (![self moveItemAtURL:url toURL:tempItemURL error:error]) { + // If we can't move the item at url, just remove it completely; chances are it's not going to be missed + [self removeItemAtURL:url error:NULL]; + [self removeItemAtURL:tempDirectory error:NULL]; + return NO; + } + + if (![self changeOwnerAndGroupOfItemAtRootURL:tempItemURL toMatchURL:trashURL error:error]) { + // Removing the item inside of the temp directory is better than trying to move the item to the trash with incorrect ownership + [self removeItemAtURL:tempDirectory error:NULL]; + return NO; + } + + // If we get here, we should be able to trash the item normally without authentication + // TODO: address -[NSFileManager trashItemAtURL: resultingItemURL: error:] being 10.8+ only + NSError *trashError = nil; + BOOL success = [_fileManager trashItemAtURL:tempItemURL resultingItemURL:NULL error:&trashError]; + if (!success && error != NULL) { + *error = trashError; + } + + [self removeItemAtURL:tempDirectory error:NULL]; + + return success; +} + +@end + +#pragma clang diagnostic pop diff --git a/Sparkle/SUPlainInstaller.m b/Sparkle/SUPlainInstaller.m index cea72914..4ae02f75 100644 --- a/Sparkle/SUPlainInstaller.m +++ b/Sparkle/SUPlainInstaller.m @@ -7,13 +7,136 @@ // #import "SUPlainInstaller.h" -#import "SUPlainInstallerInternals.h" +#import "SUFileManager.h" #import "SUCodeSigningVerifier.h" #import "SUConstants.h" #import "SUHost.h" +#import "SULog.h" @implementation SUPlainInstaller ++ (BOOL)performInstallationToURL:(NSURL *)installationURL withOldURL:(NSURL *)oldURL newURL:(NSURL *)newURL error:(NSError * __autoreleasing *)error +{ + SUFileManager *fileManager = [[SUFileManager alloc] init]; + + // Create a temporary directory for our new app that resides on our destination's volume + NSURL *tempNewDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:[installationURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingString:@" (Incomplete)"] appropriateForDirectoryURL:installationURL.URLByDeletingLastPathComponent error:error]; + if (tempNewDirectoryURL == nil) { + SULog(@"Failed to make new temp directory"); + return NO; + } + + // Move the new app to our temporary directory + NSURL *newTempURL = [tempNewDirectoryURL URLByAppendingPathComponent:newURL.lastPathComponent]; + if (![fileManager moveItemAtURL:newURL toURL:newTempURL error:error]) { + SULog(@"Failed to move the new app from %@ to its temp directory at %@", newURL.path, newTempURL.path); + [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; + return NO; + } + + // Release our new app from quarantine and fix its owner and group IDs while it's at our temporary destination + // We must leave moving the app to its destination as the final step in installing it, so that + // it's not possible our new app can be left in an incomplete state at the final destination + + NSError *quarantineError = nil; + if (![fileManager releaseItemFromQuarantineAtRootURL:newTempURL error:&quarantineError]) { + // Not big enough of a deal to fail the entire installation + SULog(@"Failed to release quarantine at %@ with error %@", newTempURL.path, quarantineError); + } + + if (![fileManager changeOwnerAndGroupOfItemAtRootURL:newTempURL toMatchURL:oldURL error:error]) { + // But this is big enough of a deal to fail + SULog(@"Failed to change owner and group of new app at %@ to match old app at %@", newTempURL.path, oldURL.path); + [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; + return NO; + } + + // If the installation and old URL differ, the sooner we can install our new app + // because we won't have to move the old app out of the way first + // increasing our chances of having it installed in case something goes wrong + if (![installationURL isEqual:oldURL]) { + // Move the new app to its final destination + if (![fileManager moveItemAtURL:newTempURL toURL:installationURL error:error]) { + SULog(@"Failed to move new app at %@ to final destination %@ (with installationURL != oldURL)", newTempURL.path, installationURL.path); + [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; + return NO; + } + + // Cleanup: move the old app to the trash + // We will first have to move the app to a temporary location that the user may not care about + // This is necessary because the operation could fail mid-way through + // Nothing past here will be a fatal error because we already installed the new app + + // Create a temporary directory for our old app that resides on its volume + NSError *makeOldTempDirectoryError = nil; + NSURL *tempOldDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:oldURL.lastPathComponent.stringByDeletingPathExtension appropriateForDirectoryURL:oldURL.URLByDeletingLastPathComponent error:&makeOldTempDirectoryError]; + if (tempOldDirectoryURL == nil) { + SULog(@"Failed to create temporary directory for old app at %@ after finishing installation. This is not a fatal error. Error: %@", oldURL.path, makeOldTempDirectoryError); + } else { + // Move the old app to the temporary directory + NSURL *oldTempURL = [tempOldDirectoryURL URLByAppendingPathComponent:oldURL.lastPathComponent]; + NSError *moveOldAppError = nil; + if (![fileManager moveItemAtURL:oldURL toURL:oldTempURL error:&moveOldAppError]) { + SULog(@"Failed to move the old app at %@ to a temporary location at %@. This is not a fatal error. Error: %@", oldURL.path, oldTempURL.path, moveOldAppError); + } else { + // Finally try to trash our old app + NSError *trashError = nil; + if (![fileManager moveItemAtURLToTrash:oldTempURL error:&trashError]) { + SULog(@"Failed to move %@ to trash. This is not a fatal error. Error: %@", oldURL, trashError); + } + } + + [fileManager removeItemAtURL:tempOldDirectoryURL error:NULL]; + } + } else { + // Create a temporary directory for our old app that resides on its volume + NSURL *tempOldDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:oldURL.lastPathComponent.stringByDeletingPathExtension appropriateForDirectoryURL:oldURL.URLByDeletingLastPathComponent error:error]; + if (tempOldDirectoryURL == nil) { + SULog(@"Failed to create temporary directory for old app at %@", oldURL.path); + [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; + return NO; + } + + // Move the old app to the temporary directory + NSURL *oldTempURL = [tempOldDirectoryURL URLByAppendingPathComponent:oldURL.lastPathComponent]; + if (![fileManager moveItemAtURL:oldURL toURL:oldTempURL error:error]) { + SULog(@"Failed to move the old app at %@ to a temporary location at %@", oldURL.path, oldTempURL.path); + + // Just forget about our updated app on failure + [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; + [fileManager removeItemAtURL:tempOldDirectoryURL error:NULL]; + + return NO; + } + + // Move the new app to its final destination + if (![fileManager moveItemAtURL:newTempURL toURL:installationURL error:error]) { + SULog(@"Failed to move new app at %@ to final destination %@", newTempURL.path, installationURL.path); + + // Forget about our updated app on failure + [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; + + // Attempt to restore our old app back the way it was on failure + [fileManager moveItemAtURL:oldTempURL toURL:oldURL error:NULL]; + [fileManager removeItemAtURL:tempOldDirectoryURL error:NULL]; + + return NO; + } + + // Cleanup: move the old app to the trash + NSError *trashError = nil; + if (![fileManager moveItemAtURLToTrash:oldTempURL error:&trashError]) { + SULog(@"Failed to move %@ to trash with error %@", oldTempURL, trashError); + } + + [fileManager removeItemAtURL:tempOldDirectoryURL error:NULL]; + } + + [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; + + return YES; +} + + (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host versionComparator:(id)comparator completionHandler:(void (^)(NSError *))completionHandler { SUParameterAssert(host); @@ -30,24 +153,11 @@ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSError *error = nil; - NSString *oldPath = [host bundlePath]; - NSString *tempName = [self temporaryNameForPath:[host installationPath]]; - - BOOL result = [self copyPathWithAuthentication:path overPath:installationPath temporaryName:tempName error:&error]; + NSURL *oldURL = [NSURL fileURLWithPath:[host bundlePath]]; + NSURL *newURL = [NSURL fileURLWithPath:path]; + NSURL *installationURL = [NSURL fileURLWithPath:installationPath]; - if (result) { - if ([SUCodeSigningVerifier applicationAtPathIsCodeSigned:installationPath]) { - result = [SUCodeSigningVerifier codeSignatureIsValidAtPath:installationPath error:&error]; - } - } - - if (result) { - BOOL haveOld = [[NSFileManager defaultManager] fileExistsAtPath:oldPath]; - BOOL differentFromNew = ![oldPath isEqualToString:installationPath]; - if (haveOld && differentFromNew) { - [self _movePathToTrash:oldPath]; // On success, trash old copy if there's still one due to renaming. - } - } + BOOL result = [self performInstallationToURL:installationURL withOldURL:oldURL newURL:newURL error:&error]; dispatch_async(dispatch_get_main_queue(), ^{ [self finishInstallationToPath:installationPath withResult:result error:error completionHandler:completionHandler]; diff --git a/Sparkle/SUPlainInstallerInternals.h b/Sparkle/SUPlainInstallerInternals.h deleted file mode 100644 index f05cae91..00000000 --- a/Sparkle/SUPlainInstallerInternals.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// SUPlainInstallerInternals.m -// Sparkle -// -// Created by Andy Matuschak on 3/9/06. -// Copyright 2006 Andy Matuschak. All rights reserved. -// - -#ifndef SUPLAININSTALLERINTERNALS_H -#define SUPLAININSTALLERINTERNALS_H - -#import - -#import "SUPlainInstaller.h" - -@interface SUPlainInstaller (Internals) -+ (NSString *)temporaryNameForPath:(NSString *)path; -+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)tmp error:(NSError **)error; -+ (void)_movePathToTrash:(NSString *)path; -+ (BOOL)_removeFileAtPath:(NSString *)path error:(NSError **)error; -+ (BOOL)_removeFileAtPathWithForcedAuthentication:(NSString *)src error:(NSError **)error; -@end - -#endif diff --git a/Sparkle/SUPlainInstallerInternals.m b/Sparkle/SUPlainInstallerInternals.m deleted file mode 100644 index 75ae5a5c..00000000 --- a/Sparkle/SUPlainInstallerInternals.m +++ /dev/null @@ -1,639 +0,0 @@ -// -// SUPlainInstallerInternals.m -// Sparkle -// -// Created by Andy Matuschak on 3/9/06. -// Copyright 2006 Andy Matuschak. All rights reserved. -// - -#import "SUUpdater.h" - -#import "SUAppcast.h" -#import "SUAppcastItem.h" -#import "SUVersionComparisonProtocol.h" -#import "SUPlainInstallerInternals.h" -#import "SUConstants.h" -#import "SULog.h" - -#include -#include -#include -#include -#include -#include -#include - -#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000 -extern NSString *const NSURLQuarantinePropertiesKey WEAK_IMPORT_ATTRIBUTE; -#endif - -static inline void PerformOnMainThreadSync(dispatch_block_t theBlock) -{ - if ([NSThread isMainThread]) { - theBlock(); - } else { - dispatch_sync(dispatch_get_main_queue(), theBlock); - } -} - -@interface SUPlainInstaller (MMExtendedAttributes) -// Removes the directory tree rooted at |root| from the file quarantine. -// The quarantine was introduced on OS X 10.5 and is described at: -// -// http://developer.apple.com/releasenotes/Carbon/RN-LaunchServices/index.html -//#apple_ref/doc/uid/TP40001369-DontLinkElementID_2 -// -// If |root| is not a directory, then it alone is removed from the quarantine. -// Symbolic links, including |root| if it is a symbolic link, will not be -// traversed. -// -// Ordinarily, the quarantine is managed by calling LSSetItemAttribute -// to set the kLSItemQuarantineProperties attribute to a dictionary specifying -// the quarantine properties to be applied. However, it does not appear to be -// possible to remove an item from the quarantine directly through any public -// Launch Services calls. Instead, this method takes advantage of the fact -// that the quarantine is implemented in part by setting an extended attribute, -// "com.apple.quarantine", on affected files. Removing this attribute is -// sufficient to remove files from the quarantine. -+ (void)releaseFromQuarantine:(NSString *)root; -@end - -// Authorization code based on generous contribution from Allan Odgaard. Thanks, Allan! -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" // this is terrible; will fix later probably -static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char *executablePath, AuthorizationFlags options, char *const *arguments) -{ - // *** MUST BE SAFE TO CALL ON NON-MAIN THREAD! - - sig_t oldSigChildHandler = signal(SIGCHLD, SIG_DFL); - BOOL returnValue = YES; - - if (AuthorizationExecuteWithPrivileges(authorization, executablePath, options, arguments, NULL) == errAuthorizationSuccess) - { - int status; - pid_t pid = wait(&status); - if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) - returnValue = NO; - } - else - returnValue = NO; - - signal(SIGCHLD, oldSigChildHandler); - return returnValue; -} -#pragma clang diagnostic pop - -@implementation SUPlainInstaller (Internals) - -+ (NSString *)temporaryNameForPath:(NSString *)path -{ - // Let's try to read the version number so the filename will be more meaningful. - NSString *postFix; - NSString *version; - if ((version = [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]) && ![version isEqualToString:@""]) - { - NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet]; - [validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]]; - postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]]; - } - else - postFix = @"old"; - NSString *prefix = [[path stringByDeletingPathExtension] stringByAppendingFormat:@" (%@)", postFix]; - NSString *tempDir = [prefix stringByAppendingPathExtension:[path pathExtension]]; - // Now let's make sure we get a unique path. - unsigned int cnt = 2; - while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 999) - tempDir = [NSString stringWithFormat:@"%@ %u.%@", prefix, cnt++, [path pathExtension]]; - return [tempDir lastPathComponent]; -} - -+ (NSString *)_temporaryCopyNameForPath:(NSString *)path didFindTrash:(BOOL *)outDidFindTrash -{ - // *** MUST BE SAFE TO CALL ON NON-MAIN THREAD! - NSString *tempDir = nil; - - UInt8 trashPath[MAXPATHLEN + 1] = { 0 }; - FSRef trashRef, pathRef; - FSVolumeRefNum vSrcRefNum = kFSInvalidVolumeRefNum; - FSCatalogInfo catInfo; - memset(&catInfo, 0, sizeof(catInfo)); - OSStatus err = FSPathMakeRef((const UInt8 *)[path fileSystemRepresentation], &pathRef, NULL); - if( err == noErr ) - { - err = FSGetCatalogInfo(&pathRef, kFSCatInfoVolume, &catInfo, NULL, NULL, NULL); - vSrcRefNum = catInfo.volume; - } - if (err == noErr) - err = FSFindFolder(vSrcRefNum, kTrashFolderType, kCreateFolder, &trashRef); - if (err == noErr) - err = FSGetCatalogInfo(&trashRef, kFSCatInfoVolume, &catInfo, NULL, NULL, NULL); - if (err == noErr && vSrcRefNum != catInfo.volume) - err = nsvErr; // Couldn't find a trash folder on same volume as given path. Docs say this may happen in the future. - if (err == noErr) - err = FSRefMakePath(&trashRef, trashPath, MAXPATHLEN); - if (err == noErr) - tempDir = [[NSFileManager defaultManager] stringWithFileSystemRepresentation:(char *)trashPath length:strlen((char *)trashPath)]; - if (outDidFindTrash) - *outDidFindTrash = (tempDir != nil); - if (!tempDir) - tempDir = [path stringByDeletingLastPathComponent]; - - // Let's try to read the version number so the filename will be more meaningful - NSString *prefix; - if ([[[NSBundle bundleWithIdentifier:SUBundleIdentifier] infoDictionary][SUAppendVersionNumberKey] boolValue]) { - NSString *postFix = nil; - NSString *version = nil; - if ((version = [[NSBundle bundleWithPath: path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]) && ![version isEqualToString:@""]) - { - NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet]; - [validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]]; - postFix = [version stringByTrimmingCharactersInSet:[validCharacters invertedSet]]; - } - else { - postFix = @"old"; - } - prefix = [NSString stringWithFormat:@"%@ (%@)", [[path lastPathComponent] stringByDeletingPathExtension], postFix]; - } else { - prefix = [[path lastPathComponent] stringByDeletingPathExtension]; - } - NSString *tempName = [prefix stringByAppendingPathExtension:[path pathExtension]]; - tempDir = [tempDir stringByAppendingPathComponent:tempName]; - - // Now let's make sure we get a unique path. - int cnt = 2; - while ([[NSFileManager defaultManager] fileExistsAtPath:tempDir] && cnt <= 9999) { - tempDir = [[tempDir stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@ %d.%@", prefix, cnt++, [path pathExtension]]]; - } - - return tempDir; -} - -+ (BOOL)_copyPathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst temporaryPath:(NSString *)tmp error:(NSError *__autoreleasing *)error -{ - // *** MUST BE SAFE TO CALL ON NON-MAIN THREAD! - - char srcPath[PATH_MAX] = {0}; - [src getFileSystemRepresentation:srcPath maxLength:sizeof(srcPath)]; - - char tmpPath[PATH_MAX] = {0}; - [tmp getFileSystemRepresentation:tmpPath maxLength:sizeof(tmpPath)]; - - char dstPath[PATH_MAX] = {0}; - [dst getFileSystemRepresentation:dstPath maxLength:sizeof(dstPath)]; - - struct stat dstSB; - if (stat(dstPath, &dstSB) != 0) // Doesn't exist yet, try containing folder. - { - const char *dstDirPath = [[dst stringByDeletingLastPathComponent] fileSystemRepresentation]; - if( stat(dstDirPath, &dstSB) != 0 ) - { - NSString *errorMessage = [NSString stringWithFormat:@"Stat on %@ during authenticated file copy failed.", dst]; - if (error != NULL) - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }]; - return NO; - } - } - - AuthorizationRef auth = NULL; - OSStatus authStat = errAuthorizationDenied; - while (authStat == errAuthorizationDenied) { - authStat = AuthorizationCreate(NULL, - kAuthorizationEmptyEnvironment, - kAuthorizationFlagDefaults, - &auth); - } - - BOOL res = NO; - if (authStat == errAuthorizationSuccess) { - res = YES; - - char uidgid[42]; - snprintf(uidgid, sizeof(uidgid), "%u:%u", - dstSB.st_uid, dstSB.st_gid); - - // If the currently-running application is trusted, the new - // version should be trusted as well. Remove it from the - // quarantine to avoid a delay at launch, and to avoid - // presenting the user with a confusing trust dialog. - // - // This needs to be done after the application is moved to its - // new home with "mv" in case it's moved across filesystems: if - // that happens, "mv" actually performs a copy and may result - // in the application being quarantined. It also needs to be - // done before "chown" changes ownership, because the ownership - // change will almost certainly make it impossible to change - // attributes to release the files from the quarantine. - if (res) - { - SULog(@"releaseFromQuarantine"); - PerformOnMainThreadSync(^{ - [self releaseFromQuarantine:src]; - }); - } - - if (res) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination. - { - char *coParams[] = { "-R", uidgid, srcPath, NULL }; - res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams); - if (!res) - SULog(@"chown -R %@ %@ failed.", @(uidgid), @(srcPath)); - } - - BOOL haveDst = [[NSFileManager defaultManager] fileExistsAtPath:dst]; - if (res && haveDst) // If there's something at our tmp path (previous failed update or whatever) delete that first. - { - char *rmParams[] = { "-rf", tmpPath, NULL }; - res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams); - if (!res) - SULog(@"rm failed"); - } - - if (res && haveDst) // Move old exe to tmp path. - { - char *mvParams[] = { "-f", dstPath, tmpPath, NULL }; - res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams); - if (!res) - SULog(@"mv 1 failed"); - } - - if (res) // Move new exe to old exe's path. - { - char *mvParams2[] = { "-f", srcPath, dstPath, NULL }; - res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams2); - if (!res) - SULog(@"mv 2 failed"); - } - - // if( res && haveDst /*&& !foundTrash*/ ) // If we managed to put the old exe in the trash, leave it there for the user to delete or recover. - // { // ... Otherwise we better delete it, wouldn't want dozens of old versions lying around next to the new one. - // const char* rmParams2[] = { "-rf", tmpPath, NULL }; - // res = AuthorizationExecuteWithPrivilegesAndWait( auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams2 ); - // } - - AuthorizationFree(auth, 0); - - // If the currently-running application is trusted, the new - // version should be trusted as well. Remove it from the - // quarantine to avoid a delay at launch, and to avoid - // presenting the user with a confusing trust dialog. - // - // This needs to be done after the application is moved to its - // new home with "mv" in case it's moved across filesystems: if - // that happens, "mv" actually performs a copy and may result - // in the application being quarantined. - if (res) - { - SULog(@"releaseFromQuarantine after installing"); - PerformOnMainThreadSync(^{ - [self releaseFromQuarantine:dst]; - }); - } - - if (!res) - { - // Something went wrong somewhere along the way, but we're not sure exactly where. - NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file copy from %@ to %@ failed.", src, dst]; - if (error != nil) - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }]; - } - } - else - { - if (error != nil) - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't get permission to authenticate." }]; - } - return res; -} - -+ (BOOL)_movePathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst error:(NSError *__autoreleasing *)error -{ - // *** MUST BE SAFE TO CALL ON NON-MAIN THREAD! - - char srcPath[PATH_MAX] = {0}; - [src getFileSystemRepresentation:srcPath maxLength:sizeof(srcPath)]; - - char dstPath[PATH_MAX] = {0}; - [dst getFileSystemRepresentation:dstPath maxLength:sizeof(dstPath)]; - - char dstContainerPath[PATH_MAX] = {0}; - [dst.stringByDeletingLastPathComponent getFileSystemRepresentation:dstContainerPath maxLength:sizeof(dstContainerPath)]; - - struct stat dstSB; - stat(dstContainerPath, &dstSB); - - AuthorizationRef auth = NULL; - OSStatus authStat = errAuthorizationDenied; - while( authStat == errAuthorizationDenied ) - { - authStat = AuthorizationCreate(NULL, - kAuthorizationEmptyEnvironment, - kAuthorizationFlagDefaults, - &auth); - } - - BOOL res = NO; - if (authStat == errAuthorizationSuccess) - { - res = YES; - - char uidgid[42]; - snprintf(uidgid, sizeof(uidgid), "%d:%d", - dstSB.st_uid, dstSB.st_gid); - - if (res) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination. - { - char *coParams[] = { "-R", uidgid, srcPath, NULL }; - res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams); - if (!res) - SULog(@"Can't set permissions"); - } - - BOOL haveDst = [[NSFileManager defaultManager] fileExistsAtPath:dst]; - if (res && haveDst) // If there's something at our tmp path (previous failed update or whatever) delete that first. - { - char *rmParams[] = { "-rf", dstPath, NULL }; - res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams); - if (!res) - SULog(@"Can't remove destination file"); - } - - if (res) // Move!. - { - char *mvParams[] = { "-f", srcPath, dstPath, NULL }; - res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams); - if (!res) - SULog(@"Can't move source file"); - } - - AuthorizationFree(auth, 0); - - if (!res) - { - // Something went wrong somewhere along the way, but we're not sure exactly where. - NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file move from %@ to %@ failed.", src, dst]; - if (error != NULL) - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }]; - } - } - else - { - if (error != NULL) - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't get permission to authenticate." }]; - } - return res; -} - - -+ (BOOL)_removeFileAtPathWithForcedAuthentication:(NSString *)src error:(NSError *__autoreleasing *)error -{ - // *** MUST BE SAFE TO CALL ON NON-MAIN THREAD! - - char srcPath[PATH_MAX] = {0}; - [src getFileSystemRepresentation:srcPath maxLength:sizeof(srcPath)]; - - AuthorizationRef auth = NULL; - OSStatus authStat = errAuthorizationDenied; - while( authStat == errAuthorizationDenied ) - { - authStat = AuthorizationCreate(NULL, - kAuthorizationEmptyEnvironment, - kAuthorizationFlagDefaults, - &auth); - } - - BOOL res = NO; - if (authStat == errAuthorizationSuccess) - { - res = YES; - - if (res) // If there's something at our tmp path (previous failed update or whatever) delete that first. - { - char *rmParams[] = { "-rf", srcPath, NULL }; - res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams); - if (!res) - SULog(@"Can't remove destination file"); - } - - AuthorizationFree(auth, 0); - - if (!res) - { - // Something went wrong somewhere along the way, but we're not sure exactly where. - NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file remove from %@ failed.", src]; - if (error != NULL) - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }]; - } - } - else - { - if (error != NULL) - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't get permission to authenticate." }]; - } - return res; -} - -+ (BOOL)_removeFileAtPath:(NSString *)path error:(NSError *__autoreleasing *)error -{ - BOOL success = YES; - if( ![[NSFileManager defaultManager] removeItemAtPath: path error: NULL] ) - { - success = [self _removeFileAtPathWithForcedAuthentication:path error:error]; - } - - return success; -} - -+ (void)_movePathToTrash:(NSString *)path -{ - //SULog(@"Moving %@ to the trash.", path); - NSInteger tag = 0; - if (![[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:[path stringByDeletingLastPathComponent] destination:@"" files:@[[path lastPathComponent]] tag:&tag]) - { - BOOL didFindTrash = NO; - NSString *trashPath = [self _temporaryCopyNameForPath:path didFindTrash:&didFindTrash]; - if( didFindTrash ) - { - NSError *err = nil; - if (![self _movePathWithForcedAuthentication:path toPath:trashPath error:&err]) { - SULog(@"Error: couldn't move %@ to the trash (%@). %@", path, trashPath, err); - } - } - else { - SULog(@"Error: couldn't move %@ to the trash. This is often a sign of a permissions error.", path); - } - } -} - -+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)__unused tmp error:(NSError *__autoreleasing *)error -{ - FSRef srcRef, dstRef, dstDirRef, tmpDirRef; - OSStatus err; - BOOL hadFileAtDest = NO, didFindTrash = NO; - NSString *tmpPath = [self _temporaryCopyNameForPath:dst didFindTrash:&didFindTrash]; - - // Make FSRef for destination: - err = FSPathMakeRefWithOptions((const UInt8 *)[dst fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &dstRef, NULL); - hadFileAtDest = (err == noErr); // There is a file at the destination, move it aside. If we normalized the name, we might not get here, so don't error. - if( hadFileAtDest ) - { - if (0 != access([dst fileSystemRepresentation], W_OK) || 0 != access([[dst stringByDeletingLastPathComponent] fileSystemRepresentation], W_OK)) - { - return [self _copyPathWithForcedAuthentication:src toPath:dst temporaryPath:tmpPath error:error]; - } - } - else - { - if (0 != access([[dst stringByDeletingLastPathComponent] fileSystemRepresentation], W_OK) - || 0 != access([[[dst stringByDeletingLastPathComponent] stringByDeletingLastPathComponent] fileSystemRepresentation], W_OK)) - { - return [self _copyPathWithForcedAuthentication:src toPath:dst temporaryPath:tmpPath error:error]; - } - } - - if( hadFileAtDest ) - { - err = FSPathMakeRef((const UInt8 *)[[tmpPath stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL); - if (err != noErr) - FSPathMakeRef((const UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL); - } - - err = FSPathMakeRef((const UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &dstDirRef, NULL); - - if (err == noErr && hadFileAtDest) - { - NSFileManager *manager = [[NSFileManager alloc] init]; - BOOL success = [manager moveItemAtPath:dst toPath:tmpPath error:error]; - if (!success && hadFileAtDest) - { - if (error != NULL) - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] }]; - return NO; - } - } - - err = FSPathMakeRef((const UInt8 *)[src fileSystemRepresentation], &srcRef, NULL); - if (err == noErr) - { - NSFileManager *manager = [[NSFileManager alloc] init]; - BOOL success = [manager copyItemAtPath:src toPath:dst error:error]; - if (!success) - { - // We better move the old version back to its old location - if (hadFileAtDest) { - success = [manager moveItemAtPath:tmpPath toPath:dst error:error]; - } - if (!success && error != NULL) - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUFileCopyFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Couldn't move %@ to %@.", dst, tmpPath] }]; - return NO; - - } - } - - // If the currently-running application is trusted, the new - // version should be trusted as well. Remove it from the - // quarantine to avoid a delay at launch, and to avoid - // presenting the user with a confusing trust dialog. - // - // This needs to be done after the application is moved to its - // new home in case it's moved across filesystems: if that - // happens, the move is actually a copy, and it may result - // in the application being quarantined. - PerformOnMainThreadSync(^{ - [self releaseFromQuarantine:dst]; - }); - - return YES; -} - -@end - -#include -#include -#include - -@implementation SUPlainInstaller (MMExtendedAttributes) - -+ (int)removeXAttr:(NSString *)name - fromFile:(NSString *)file - options:(int)options -{ - // *** MUST BE SAFE TO CALL ON NON-MAIN THREAD! - - const char *path = NULL; - const char *attr = [name cStringUsingEncoding:NSASCIIStringEncoding]; - @try { - path = [file fileSystemRepresentation]; - } - @catch (id) { - // -[NSString fileSystemRepresentation] throws an exception if it's - // unable to convert the string to something suitable. Map that to - // EDOM, "argument out of domain", which sort of conveys that there - // was a conversion failure. - errno = EDOM; - return -1; - } - - return removexattr(path, attr, options); -} - -+ (void)releaseFromQuarantine:(NSString *)root -{ - // *** MUST BE SAFE TO CALL ON NON-MAIN THREAD! - - NSFileManager *manager = [NSFileManager defaultManager]; -#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000 - if (!&NSURLQuarantinePropertiesKey) { - NSString *const quarantineAttribute = (__bridge NSString *)kLSItemQuarantineProperties; - const int removeXAttrOptions = XATTR_NOFOLLOW; - - [self removeXAttr:quarantineAttribute - fromFile:root - options:removeXAttrOptions]; - - // Only recurse if it's actually a directory. Don't recurse into a - // root-level symbolic link. - NSDictionary *rootAttributes = [manager attributesOfItemAtPath:root error:nil]; - NSString *rootType = rootAttributes[NSFileType]; - - if (rootType == NSFileTypeDirectory) { - // The NSDirectoryEnumerator will avoid recursing into any contained - // symbolic links, so no further type checks are needed. - NSDirectoryEnumerator *directoryEnumerator = [manager enumeratorAtPath:root]; - NSString *file = nil; - while ((file = [directoryEnumerator nextObject])) { - [self removeXAttr:quarantineAttribute - fromFile:[root stringByAppendingPathComponent:file] - options:removeXAttrOptions]; - } - } - return; - } -#endif - NSURL *rootURL = [NSURL fileURLWithPath:root]; - id rootResourceValue = nil; - [rootURL getResourceValue:&rootResourceValue forKey:NSURLQuarantinePropertiesKey error:NULL]; - if (rootResourceValue) { - [rootURL setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL]; - } - - // Only recurse if it's actually a directory. Don't recurse into a - // root-level symbolic link. - NSDictionary *rootAttributes = [manager attributesOfItemAtPath:root error:nil]; - NSString *rootType = rootAttributes[NSFileType]; - - if (rootType == NSFileTypeDirectory) { - // The NSDirectoryEnumerator will avoid recursing into any contained - // symbolic links, so no further type checks are needed. - NSDirectoryEnumerator *directoryEnumerator = [manager enumeratorAtURL:rootURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil]; - - for (NSURL *file in directoryEnumerator) { - id fileResourceValue = nil; - [file getResourceValue:&fileResourceValue forKey:NSURLQuarantinePropertiesKey error:NULL]; - if (fileResourceValue) { - [file setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL]; - } - } - } -} - -@end From 9c8fb9918432940c8de05b5b33539a3d4c31ee10 Mon Sep 17 00:00:00 2001 From: Zorg Date: Fri, 24 Jul 2015 18:47:50 -0400 Subject: [PATCH 02/87] Move deciding to abort an update into a procedure --- Sparkle/SUBasicUpdateDriver.m | 38 ++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 6371285d..8f2a6c8c 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -377,6 +377,31 @@ [self installWithToolAndRelaunch:relaunch displayingUserInterface:relaunch]; } +// Creates intermediate directories up until targetPath if they don't already exist, +// and removes the directory at targetPath if one already exists there +- (BOOL)preparePathForRelaunchTool:(NSString *)targetPath error:(NSError * __autoreleasing *)error +{ + NSFileManager *fileManager = [[NSFileManager alloc] init]; + if ([fileManager fileExistsAtPath:targetPath]) { + NSError *removeError = nil; + if (![fileManager removeItemAtPath:targetPath error:&removeError]) { + if (error != NULL) { + *error = removeError; + } + return NO; + } + } else { + NSError *createDirectoryError = nil; + if (![fileManager createDirectoryAtPath:[targetPath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:@{} error:&createDirectoryError]) { + if (error != NULL) { + *error = createDirectoryError; + } + return NO; + } + } + return YES; +} + - (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI { assert(self.updateItem); @@ -425,23 +450,12 @@ NSString *targetPath = [self.host.appCachePath stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]]; NSFileManager *fileManager = [[NSFileManager alloc] init]; - - BOOL shouldAbortUpdate = NO; NSError *error = nil; - if ([fileManager fileExistsAtPath:targetPath]) { - if (![fileManager removeItemAtPath:targetPath error:&error]) { - shouldAbortUpdate = YES; - } - } else { - if (![fileManager createDirectoryAtPath:[targetPath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:@{} error:&error]) { - shouldAbortUpdate = YES; - } - } // We only need to run our copy of the app by spawning a task // Since we are copying the app to a directory that is write-accessible, we don't need to muck with owner/group IDs // And since we spawn a task, we don't need to clear the quarantine bits - if (!shouldAbortUpdate && [fileManager copyItemAtPath:relaunchPathToCopy toPath:targetPath error:&error]) { + if ([self preparePathForRelaunchTool:targetPath error:&error] && [fileManager copyItemAtPath:relaunchPathToCopy toPath:targetPath error:&error]) { self.relaunchPath = targetPath; } else { [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{ From 19876c5a56ce30df601433a7da0440168720c604 Mon Sep 17 00:00:00 2001 From: Zorg Date: Fri, 24 Jul 2015 23:45:04 -0400 Subject: [PATCH 03/87] -moveItemAtURLToTrash:error: now works on 10.7 --- Sparkle/SUFileManager.m | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 59163b8d..ae9a8f39 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -582,7 +582,6 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return success; } -// TODO: Fix or address that this method only runs on 10.8 or later - (BOOL)moveItemAtURLToTrash:(NSURL *)url error:(NSError *__autoreleasing *)error { if (![_fileManager fileExistsAtPath:url.path]) { @@ -592,8 +591,22 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return NO; } - // TODO: address NSTrashDirectory being only available in 10.8 or later - NSURL *trashURL = [[_fileManager URLsForDirectory:NSTrashDirectory inDomains:NSUserDomainMask] firstObject]; + NSURL *trashURL = nil; + BOOL canUseNewTrashAPI = YES; +#if __MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8 + canUseNewTrashAPI = [_fileManager respondsToSelector:@selector(trashItemAtURL:resultingItemURL:error:)]; + if (!canUseNewTrashAPI) { + FSRef trashRef; + if (FSFindFolder(kUserDomain, kTrashFolderType, kDontCreateFolder, &trashRef) == noErr) { + trashURL = CFBridgingRelease(CFURLCreateFromFSRef(kCFAllocatorDefault, &trashRef)); + } + } +#endif + + if (canUseNewTrashAPI) { + trashURL = [[_fileManager URLsForDirectory:NSTrashDirectory inDomains:NSUserDomainMask] firstObject]; + } + if (trashURL == nil) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: @"User's Trash directory was not found" }]; @@ -625,11 +638,23 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } // If we get here, we should be able to trash the item normally without authentication - // TODO: address -[NSFileManager trashItemAtURL: resultingItemURL: error:] being 10.8+ only - NSError *trashError = nil; - BOOL success = [_fileManager trashItemAtURL:tempItemURL resultingItemURL:NULL error:&trashError]; - if (!success && error != NULL) { - *error = trashError; + + BOOL success = NO; +#if __MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8 + if (!canUseNewTrashAPI) { + success = [[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:tempItemURL.URLByDeletingLastPathComponent.path destination:@"" files:@[tempItemURL.lastPathComponent] tag:NULL]; + if (!success && error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to move file into the trash" }]; + } + } +#endif + + if (canUseNewTrashAPI) { + NSError *trashError = nil; + success = [_fileManager trashItemAtURL:tempItemURL resultingItemURL:NULL error:&trashError]; + if (!success && error != NULL) { + *error = trashError; + } } [self removeItemAtURL:tempDirectory error:NULL]; From d4b7a696af8aa21d9e8ddc1e6dfbf42da32ddf92 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 25 Jul 2015 12:13:16 -0400 Subject: [PATCH 04/87] Append bundle version for older app when moving it --- Sparkle/SUPlainInstaller.m | 49 ++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 10 deletions(-) diff --git a/Sparkle/SUPlainInstaller.m b/Sparkle/SUPlainInstaller.m index 4ae02f75..03b8afd6 100644 --- a/Sparkle/SUPlainInstaller.m +++ b/Sparkle/SUPlainInstaller.m @@ -15,7 +15,23 @@ @implementation SUPlainInstaller -+ (BOOL)performInstallationToURL:(NSURL *)installationURL withOldURL:(NSURL *)oldURL newURL:(NSURL *)newURL error:(NSError * __autoreleasing *)error +// Returns the bundle version from the specified host that is appropriate to use as a filename, or nil if we're unable to retrieve one ++ (NSString *)bundleVersionAppropriateForFilenameFromHost:(SUHost *)host +{ + NSString *bundleVersion = [host objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey]; + NSString *trimmedVersion = @""; + + if (bundleVersion != nil) { + NSMutableCharacterSet *validCharacters = [NSMutableCharacterSet alphanumericCharacterSet]; + [validCharacters formUnionWithCharacterSet:[NSCharacterSet characterSetWithCharactersInString:@".-()"]]; + + trimmedVersion = [bundleVersion stringByTrimmingCharactersInSet:[validCharacters invertedSet]]; + } + + return trimmedVersion.length > 0 ? trimmedVersion : nil; +} + ++ (BOOL)performInstallationToURL:(NSURL *)installationURL fromUpdateAtURL:(NSURL *)newURL withHost:(SUHost *)host error:(NSError * __autoreleasing *)error { SUFileManager *fileManager = [[SUFileManager alloc] init]; @@ -44,6 +60,7 @@ SULog(@"Failed to release quarantine at %@ with error %@", newTempURL.path, quarantineError); } + NSURL *oldURL = [NSURL fileURLWithPath:host.bundlePath]; if (![fileManager changeOwnerAndGroupOfItemAtRootURL:newTempURL toMatchURL:oldURL error:error]) { // But this is big enough of a deal to fail SULog(@"Failed to change owner and group of new app at %@ to match old app at %@", newTempURL.path, oldURL.path); @@ -51,6 +68,22 @@ return NO; } + // Decide on a destination name we should use for the older app when we move it around the file system + // TODO: will need to merge finding sparkle bundle this with newer code + NSBundle *sparkleBundle = [NSBundle bundleWithIdentifier:SUBundleIdentifier]; + BOOL appendVersion = [[sparkleBundle infoDictionary][SUAppendVersionNumberKey] boolValue]; + + NSString *oldDestinationName = nil; + if (appendVersion) { + NSString *oldBundleVersion = [self bundleVersionAppropriateForFilenameFromHost:host]; + + oldDestinationName = [oldURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingFormat:@" (%@)", oldBundleVersion != nil ? oldBundleVersion : @"old"]; + } else { + oldDestinationName = oldURL.lastPathComponent.stringByDeletingPathExtension; + } + + NSString *oldDestinationNameWithPathExtension = [oldDestinationName stringByAppendingPathExtension:oldURL.pathExtension]; + // If the installation and old URL differ, the sooner we can install our new app // because we won't have to move the old app out of the way first // increasing our chances of having it installed in case something goes wrong @@ -69,12 +102,12 @@ // Create a temporary directory for our old app that resides on its volume NSError *makeOldTempDirectoryError = nil; - NSURL *tempOldDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:oldURL.lastPathComponent.stringByDeletingPathExtension appropriateForDirectoryURL:oldURL.URLByDeletingLastPathComponent error:&makeOldTempDirectoryError]; + NSURL *tempOldDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:oldDestinationName appropriateForDirectoryURL:oldURL.URLByDeletingLastPathComponent error:&makeOldTempDirectoryError]; if (tempOldDirectoryURL == nil) { SULog(@"Failed to create temporary directory for old app at %@ after finishing installation. This is not a fatal error. Error: %@", oldURL.path, makeOldTempDirectoryError); } else { // Move the old app to the temporary directory - NSURL *oldTempURL = [tempOldDirectoryURL URLByAppendingPathComponent:oldURL.lastPathComponent]; + NSURL *oldTempURL = [tempOldDirectoryURL URLByAppendingPathComponent:oldDestinationNameWithPathExtension]; NSError *moveOldAppError = nil; if (![fileManager moveItemAtURL:oldURL toURL:oldTempURL error:&moveOldAppError]) { SULog(@"Failed to move the old app at %@ to a temporary location at %@. This is not a fatal error. Error: %@", oldURL.path, oldTempURL.path, moveOldAppError); @@ -90,7 +123,7 @@ } } else { // Create a temporary directory for our old app that resides on its volume - NSURL *tempOldDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:oldURL.lastPathComponent.stringByDeletingPathExtension appropriateForDirectoryURL:oldURL.URLByDeletingLastPathComponent error:error]; + NSURL *tempOldDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:oldDestinationName appropriateForDirectoryURL:oldURL.URLByDeletingLastPathComponent error:error]; if (tempOldDirectoryURL == nil) { SULog(@"Failed to create temporary directory for old app at %@", oldURL.path); [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; @@ -98,7 +131,7 @@ } // Move the old app to the temporary directory - NSURL *oldTempURL = [tempOldDirectoryURL URLByAppendingPathComponent:oldURL.lastPathComponent]; + NSURL *oldTempURL = [tempOldDirectoryURL URLByAppendingPathComponent:oldDestinationNameWithPathExtension]; if (![fileManager moveItemAtURL:oldURL toURL:oldTempURL error:error]) { SULog(@"Failed to move the old app at %@ to a temporary location at %@", oldURL.path, oldTempURL.path); @@ -153,11 +186,7 @@ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSError *error = nil; - NSURL *oldURL = [NSURL fileURLWithPath:[host bundlePath]]; - NSURL *newURL = [NSURL fileURLWithPath:path]; - NSURL *installationURL = [NSURL fileURLWithPath:installationPath]; - - BOOL result = [self performInstallationToURL:installationURL withOldURL:oldURL newURL:newURL error:&error]; + BOOL result = [self performInstallationToURL:[NSURL fileURLWithPath:installationPath] fromUpdateAtURL:[NSURL fileURLWithPath:path] withHost:host error:&error]; dispatch_async(dispatch_get_main_queue(), ^{ [self finishInstallationToPath:installationPath withResult:result error:error completionHandler:completionHandler]; From dbae37bb5b8d65bc8aca4abf10533bd61e4779ef Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 25 Jul 2015 12:57:01 -0400 Subject: [PATCH 05/87] Make errors/directory names more user friendly Since it is possible for the user to see these strings, we should not make them seem as 'gibberish' or unfriendly. More detailed error information is logged to the console. --- Sparkle/SUFileManager.m | 66 +++++++++++++++++++------------------- Sparkle/SUPlainInstaller.m | 2 +- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index ae9a8f39..ddf507ba 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -74,7 +74,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza OSStatus status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &_auth); if (status != errAuthorizationSuccess) { if (error != NULL) { - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed creating authorization reference with status code %d", status] }]; + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed creating authorization reference with status code %d.", status] }]; } _auth = NULL; return NO; @@ -131,7 +131,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza { if (![_fileManager fileExistsAtPath:@(XATTR_UTILITY_PATH)]) { if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"%@ does not exist", @(XATTR_UTILITY_PATH)] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: @"xattr utility does not exist on this system." }]; } return NO; } @@ -139,7 +139,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza 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:@"%@ is not a valid file system representation", rootURL.path] }]; + *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; } @@ -147,7 +147,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza const char *xattrName = [name cStringUsingEncoding:NSASCIIStringEncoding]; if (xattrName == NULL) { if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteInapplicableStringEncodingError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"%@ is not a valid ASCII convertible string", name] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteInapplicableStringEncodingError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Extended attribute %@ is not a valid ASCII convertible string.", name] }]; } return NO; } @@ -159,7 +159,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, XATTR_UTILITY_PATH, kAuthorizationFlagDefaults, (char *[]){ "-s", "-r", "-d", (char *)xattrName, path, NULL }); if (!success && error != NULL) { - NSString *errorMessage = [NSString stringWithFormat:@"Authenticated xattr deletion for attribute %@ failed on %@", name, rootURL.path]; + NSString *errorMessage = [NSString stringWithFormat:@"Authenticated extended attribute deletion for %@ failed on %@.", name, rootURL.path.lastPathComponent]; *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:errorMessage }]; } @@ -254,7 +254,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; } else { if (error != NULL) { - *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove xattr %@ on %@", APPLE_QUARANTINE_IDENTIFIER, root] }]; + *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove file quarantine on %@.", root.lastPathComponent] }]; } // Fail, but still try to release other items from quarantine success = NO; @@ -281,7 +281,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } else { // Make sure we haven't already run into an error if (success && error != NULL) { - *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove xattr %@ on %@", APPLE_QUARANTINE_IDENTIFIER, filePath] }]; + *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove file quarantine on %@.", filePath.lastPathComponent] }]; } // Fail, but still try to release other items from quarantine success = NO; @@ -298,14 +298,14 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza { if (![_fileManager fileExistsAtPath:sourceURL.path]) { if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source %@ does not exist", sourceURL.path] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source file to move (%@) does not exist.", sourceURL.path.lastPathComponent] }]; } return NO; } if ([_fileManager fileExistsAtPath:destinationURL.path]) { if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination %@ already exists", destinationURL.path] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination file to move (%@) already exists.", destinationURL.path.lastPathComponent] }]; } return NO; } @@ -329,7 +329,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza 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:@"%@ is not a valid file system representation", sourceURL.path] }]; + *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; } @@ -337,14 +337,14 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza 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:@"%@ is not a valid file system representation", destinationURL.path] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination (%@) cannot be represented as a valid file name.", destinationURL.path.lastPathComponent] }]; } return NO; } if (!AuthorizationExecuteWithPrivilegesAndWait(_auth, "/bin/mv", kAuthorizationFlagDefaults, (char *[]){ "-f", sourcePath, destinationPath, NULL })) { if (error != NULL) { - NSString *errorMessage = [NSString stringWithFormat:@"Authenticated file move from %@ to %@ failed.", sourceURL, destinationURL]; + NSString *errorMessage = [NSString stringWithFormat:@"Failed to perform authenticated file move for %@.", sourceURL.lastPathComponent]; *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:errorMessage }]; } return NO; @@ -357,14 +357,14 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza { if (![_fileManager fileExistsAtPath:targetURL.path]) { if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Item at target %@ does not exist", targetURL.path] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to change owner & group IDs because %@ does not exist.", targetURL.path.lastPathComponent] }]; } return NO; } if (![_fileManager fileExistsAtPath:matchURL.path]) { if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Item at URL to match %@ does not exist", matchURL.path] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to match owner & group IDs because %@ does not exist.", matchURL.path.lastPathComponent] }]; } return NO; } @@ -391,7 +391,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza if (ownerID == nil) { // shouldn't be possible to error here, but just in case if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadNoPermissionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"owner ID could not be read from %@", matchURL.path] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadNoPermissionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Owner ID could not be read from %@.", matchURL.path.lastPathComponent] }]; } return NO; } @@ -400,7 +400,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza if (groupID == nil) { // shouldn't be possible to error here, but just in case if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadNoPermissionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"group ID could not be read from %@", matchURL.path] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadNoPermissionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Group ID could not be read from %@.", matchURL.path.lastPathComponent] }]; } return NO; } @@ -417,7 +417,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza 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:@"%@ is not a valid file system representation", url.path] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"File to change owner & group (%@) cannot be represented as a valid file name.", url.path.lastPathComponent] }]; } return NO; } @@ -428,7 +428,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza break; } else { if (error != NULL) { - *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to chown %@ with owner ID %u and group ID %u", url.path, ownerID.unsignedIntValue, groupID.unsignedIntValue] }]; + *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to change owner & group for %@ with owner ID %u and group ID %u.", url.path.lastPathComponent, ownerID.unsignedIntValue, groupID.unsignedIntValue] }]; } return NO; } @@ -442,7 +442,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza 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:@"%@ is not a valid file system representation", targetURL.path] }]; + *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; } @@ -451,7 +451,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza const char *userAndGroup = [formattedUserAndGroupIDs cStringUsingEncoding:NSASCIIStringEncoding]; if (userAndGroup == NULL) { if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFormattingError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Owner ID %u and Group ID %u could not be formatted", ownerID.unsignedIntValue, groupID.unsignedIntValue] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFormattingError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Owner ID %u and Group ID %u could not be formatted.", ownerID.unsignedIntValue, groupID.unsignedIntValue] }]; } return NO; } @@ -462,7 +462,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, (char *[]){ "-R", (char *)userAndGroup, targetPath, NULL }); if (!success && error != NULL) { - NSString *errorMessage = [NSString stringWithFormat:@"Failed to chown -R \"%@\" \"%@\" with authentication", formattedUserAndGroupIDs, targetURL.path]; + NSString *errorMessage = [NSString stringWithFormat:@"Failed to change owner:group %@ on %@ with authentication.", formattedUserAndGroupIDs, targetURL.path.lastPathComponent]; *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }]; } @@ -475,7 +475,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza { if ([_fileManager fileExistsAtPath:url.path]) { if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Item at %@ already exists", url.path] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create directory because file %@ already exists.", url.path.lastPathComponent] }]; } return NO; } @@ -484,7 +484,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza BOOL isParentADirectory = NO; if (![_fileManager fileExistsAtPath:parentURL.path isDirectory:&isParentADirectory] || !isParentADirectory) { if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Directory at %@ does not exist", parentURL.path] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create directory because parent directory %@ does not exist.", parentURL.path.lastPathComponent] }]; } return NO; } @@ -504,7 +504,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza 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:@"%@ is not a valid file system representation", url.path] }]; + *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; } @@ -515,7 +515,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, "/bin/mkdir", kAuthorizationFlagDefaults, (char *[]){ path, NULL }); if (!success && error != NULL) { - NSString *errorMessage = [NSString stringWithFormat:@"Failed to make directory %@ with authentication", url.path]; + NSString *errorMessage = [NSString stringWithFormat:@"Failed to make directory %@ with authentication.", url.path.lastPathComponent]; *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }]; } return success; @@ -546,7 +546,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza { if (![_fileManager fileExistsAtPath:url.path]) { if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Item at %@ does not exist", url.path] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove file %@ because it does not exist.", url.path.lastPathComponent] }]; } return NO; } @@ -570,14 +570,14 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza 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:@"%@ is not a valid file system representation", url.path] }]; + *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; } BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, "/bin/rm", kAuthorizationFlagDefaults, (char *[]){ "-rf", path, NULL }); if (!success && error != NULL) { - *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to rm -rf \"%@\" with authentication", url.path] }]; + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove %@ with authentication.", url.path.lastPathComponent] }]; } return success; } @@ -586,7 +586,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza { if (![_fileManager fileExistsAtPath:url.path]) { if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Item at %@ does not exist", url.path] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to move %@ to the trash because the file does not exist.", url.path.lastPathComponent] }]; } return NO; } @@ -609,15 +609,15 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza if (trashURL == nil) { if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: @"User's Trash directory was not found" }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to locate the user's trash folder." }]; } return NO; } - // In the rare worst case scenario, our temporary directory will be labeled with "Incomplete" and be in the user's trash directory, + // In the rare worst case scenario, our temporary directory will be labeled incomplete and be in the user's trash directory, // indicating that whatever inside of there is not yet completely moved. // Regardless, we want the item to be in our Volume before we try moving it to the trash - NSString *preferredName = [url.lastPathComponent.stringByDeletingPathExtension stringByAppendingString:@" (Incomplete)"]; + NSString *preferredName = [url.lastPathComponent.stringByDeletingPathExtension stringByAppendingString:@" (Incomplete Files)"]; NSURL *tempDirectory = [self makeTemporaryDirectoryWithPreferredName:preferredName appropriateForDirectoryURL:trashURL error:error]; if (tempDirectory == nil) { return NO; @@ -644,7 +644,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza if (!canUseNewTrashAPI) { success = [[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:tempItemURL.URLByDeletingLastPathComponent.path destination:@"" files:@[tempItemURL.lastPathComponent] tag:NULL]; if (!success && error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to move file into the trash" }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to move file %@ into the trash.", tempItemURL.lastPathComponent] }]; } } #endif diff --git a/Sparkle/SUPlainInstaller.m b/Sparkle/SUPlainInstaller.m index 03b8afd6..da02f674 100644 --- a/Sparkle/SUPlainInstaller.m +++ b/Sparkle/SUPlainInstaller.m @@ -36,7 +36,7 @@ SUFileManager *fileManager = [[SUFileManager alloc] init]; // Create a temporary directory for our new app that resides on our destination's volume - NSURL *tempNewDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:[installationURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingString:@" (Incomplete)"] appropriateForDirectoryURL:installationURL.URLByDeletingLastPathComponent error:error]; + NSURL *tempNewDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:[installationURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingString:@" (Incomplete Update)"] appropriateForDirectoryURL:installationURL.URLByDeletingLastPathComponent error:error]; if (tempNewDirectoryURL == nil) { SULog(@"Failed to make new temp directory"); return NO; From fd7628e658ef3f7045fdae88cd702bf2b8a296cb Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 15 Aug 2015 17:39:06 -0400 Subject: [PATCH 06/87] Don't follow symlinks for checking file existence --- Sparkle/SUFileManager.m | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index ddf507ba..c2f7d270 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -89,6 +89,27 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } } +// -[NSFileManager attributesOfItemAtPath:error:] won't follow symbolic links + +- (BOOL)itemExistsAtURL:(NSURL *)fileURL +{ + return [_fileManager attributesOfItemAtPath:fileURL.path error:NULL] != nil; +} + +- (BOOL)itemExistsAtURL:(NSURL *)fileURL isDirectory:(BOOL *)isDirectory +{ + NSDictionary *attributes = [_fileManager attributesOfItemAtPath:fileURL.path error:NULL]; + if (attributes == nil) { + return NO; + } + + if (isDirectory != NULL) { + *isDirectory = [attributes[NSFileType] isEqualToString:NSFileTypeDirectory]; + } + + return YES; +} + // Wrapper around getxattr() - (ssize_t)getXAttr:(NSString *)nameString fromFile:(NSString *)file options:(int)options { @@ -129,6 +150,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // Recursively remove an xattr at a specified root URL with authentication - (BOOL)removeXAttrWithAuthentication:(NSString *)name fromRootURL:(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." }]; @@ -296,14 +318,14 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza - (BOOL)moveItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError *__autoreleasing *)error { - if (![_fileManager fileExistsAtPath:sourceURL.path]) { + if (![self itemExistsAtURL:sourceURL]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source file to move (%@) does not exist.", sourceURL.path.lastPathComponent] }]; } return NO; } - if ([_fileManager fileExistsAtPath:destinationURL.path]) { + if ([self itemExistsAtURL:destinationURL]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination file to move (%@) already exists.", destinationURL.path.lastPathComponent] }]; } @@ -355,14 +377,14 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza - (BOOL)changeOwnerAndGroupOfItemAtRootURL:(NSURL *)targetURL toMatchURL:(NSURL *)matchURL error:(NSError * __autoreleasing *)error { - if (![_fileManager fileExistsAtPath:targetURL.path]) { + if (![self itemExistsAtURL:targetURL]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to change owner & group IDs because %@ does not exist.", targetURL.path.lastPathComponent] }]; } return NO; } - if (![_fileManager fileExistsAtPath:matchURL.path]) { + if (![self itemExistsAtURL:matchURL]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to match owner & group IDs because %@ does not exist.", matchURL.path.lastPathComponent] }]; } @@ -473,7 +495,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // An item cannot already exist at the url, but the parent must be a directory that exists - (BOOL)makeDirectoryAtURL:(NSURL *)url error:(NSError * __autoreleasing *)error { - if ([_fileManager fileExistsAtPath:url.path]) { + if ([self itemExistsAtURL:url]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create directory because file %@ already exists.", url.path.lastPathComponent] }]; } @@ -482,7 +504,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza NSURL *parentURL = [url URLByDeletingLastPathComponent]; BOOL isParentADirectory = NO; - if (![_fileManager fileExistsAtPath:parentURL.path isDirectory:&isParentADirectory] || !isParentADirectory) { + if (![self itemExistsAtURL:parentURL isDirectory:&isParentADirectory] || !isParentADirectory) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create directory because parent directory %@ does not exist.", parentURL.path.lastPathComponent] }]; } @@ -535,7 +557,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza NSURL *desiredURL = [directoryURL URLByAppendingPathComponent:preferredName]; NSUInteger tagIndex = 1; - while ([_fileManager fileExistsAtPath:desiredURL.path] && tagIndex <= 9999) { + while ([self itemExistsAtURL:desiredURL] && tagIndex <= 9999) { desiredURL = [directoryURL URLByAppendingPathComponent:[preferredName stringByAppendingFormat:@" (%lu)", (unsigned long)++tagIndex]]; } @@ -544,7 +566,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza - (BOOL)removeItemAtURL:(NSURL *)url error:(NSError * __autoreleasing *)error { - if (![_fileManager fileExistsAtPath:url.path]) { + if (![self itemExistsAtURL:url]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove file %@ because it does not exist.", url.path.lastPathComponent] }]; } @@ -584,7 +606,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza - (BOOL)moveItemAtURLToTrash:(NSURL *)url error:(NSError *__autoreleasing *)error { - if (![_fileManager fileExistsAtPath:url.path]) { + if (![self itemExistsAtURL:url]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to move %@ to the trash because the file does not exist.", url.path.lastPathComponent] }]; } From ea959cbd873d0b4e906e8f2c377f82b1794b9946 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 15 Aug 2015 18:05:20 -0400 Subject: [PATCH 07/87] Release quarantine for Autoupdate.app I don't think this is actually needed, but better be safe than sorry. --- Sparkle/SUBasicUpdateDriver.m | 8 +++++++- Sparkle/SUFileManager.h | 5 +++++ Sparkle/SUFileManager.m | 22 ++++++++++++++++------ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 85d5dd91..4e19024f 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -18,6 +18,7 @@ #import "SUBinaryDeltaCommon.h" #import "SUCodeSigningVerifier.h" #import "SUUpdater_Private.h" +#import "SUFileManager.h" @interface SUBasicUpdateDriver () @@ -456,8 +457,13 @@ // We only need to run our copy of the app by spawning a task // Since we are copying the app to a directory that is write-accessible, we don't need to muck with owner/group IDs - // And since we spawn a task, we don't need to clear the quarantine bits if ([self preparePathForRelaunchTool:targetPath error:&error] && [fileManager copyItemAtPath:relaunchPathToCopy toPath:targetPath error:&error]) { + // We probably don't need to release the quarantine, but we'll do it just in case it's necessary. + // Perhaps in a sandboxed environment this matters more. Note that this may not be a fatal error. + NSError *quarantineError = nil; + if (![[[SUFileManager alloc] init] releaseItemFromQuarantineWithoutAuthenticationAtRootURL:[NSURL fileURLWithPath:targetPath] error:&quarantineError]) { + SULog(@"Failed to release quarantine on %@ with error %@", targetPath, quarantineError); + } self.relaunchPath = targetPath; } else { [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{ diff --git a/Sparkle/SUFileManager.h b/Sparkle/SUFileManager.h index 5f07bff0..f5cba54a 100644 --- a/Sparkle/SUFileManager.h +++ b/Sparkle/SUFileManager.h @@ -97,4 +97,9 @@ */ - (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError **)error; +/** + * Behaves as -releaseItemFromQuarantineAtRootURL:error: does, except without the capability of authenticating when permission is denied + */ +- (BOOL)releaseItemFromQuarantineWithoutAuthenticationAtRootURL:(NSURL *)rootURL error:(NSError **)error; + @end diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index c2f7d270..5c43289b 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -198,11 +198,11 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // If |root| is not a directory, then it alone is removed from the quarantine. // Symbolic links, including |root| if it is a symbolic link, will not be // traversed. -- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError * __autoreleasing *)error +- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL allowingAuthentication:(BOOL)allowsAuthentication error:(NSError * __autoreleasing *)error { #if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000 /* MAC_OS_X_VERSION_10_10 */ if (!&NSURLQuarantinePropertiesKey) { - return [self releaseItemUsingOldMethodFromQuarantineAtRootURL:rootURL error:error]; + return [self releaseItemUsingOldMethodFromQuarantineAtRootURL:rootURL allowingAuthentication:allowsAuthentication error:error]; } #endif @@ -211,7 +211,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza if ([rootURL getResourceValue:&rootResourceValue forKey:NSURLQuarantinePropertiesKey error:NULL] && rootResourceValue != nil) { NSError *setResourceError = nil; if (![rootURL setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:&setResourceError]) { - if (NS_HAS_PERMISSION_ERROR(setResourceError)) { + if (allowsAuthentication && NS_HAS_PERMISSION_ERROR(setResourceError)) { return [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; } else { if (error != NULL) { @@ -238,7 +238,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza if ([file getResourceValue:&fileResourceValue forKey:NSURLQuarantinePropertiesKey error:NULL] && fileResourceValue != nil) { NSError *setResourceError = nil; if (![file setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:&setResourceError]) { - if (NS_HAS_PERMISSION_ERROR(setResourceError)) { + if (allowsAuthentication && NS_HAS_PERMISSION_ERROR(setResourceError)) { return [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; } else { // Make sure we haven't already run into an error @@ -264,7 +264,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // that the quarantine is implemented in part by setting an extended attribute, // "com.apple.quarantine", on affected files. Removing this attribute is // sufficient to remove files from the quarantine. -- (BOOL)releaseItemUsingOldMethodFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError *__autoreleasing *)error +- (BOOL)releaseItemUsingOldMethodFromQuarantineAtRootURL:(NSURL *)rootURL allowingAuthentication:(BOOL)allowsAuthentication error:(NSError *__autoreleasing *)error { BOOL success = YES; NSString *root = rootURL.path; @@ -298,7 +298,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza NSString *filePath = [root stringByAppendingPathComponent:file]; if ([self getXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:filePath options:removeXAttrOptions] >= 0) { if ([self removeXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:filePath options:removeXAttrOptions] != 0) { - if (errno == EACCES) { + if (allowsAuthentication && errno == EACCES) { return [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; } else { // Make sure we haven't already run into an error @@ -316,6 +316,16 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return success; } +- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError * __autoreleasing *)error +{ + return [self releaseItemFromQuarantineAtRootURL:rootURL allowingAuthentication:YES error:error]; +} + +- (BOOL)releaseItemFromQuarantineWithoutAuthenticationAtRootURL:(NSURL *)rootURL error:(NSError * __autoreleasing *)error +{ + return [self releaseItemFromQuarantineAtRootURL:rootURL allowingAuthentication:NO error:error]; +} + - (BOOL)moveItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError *__autoreleasing *)error { if (![self itemExistsAtURL:sourceURL]) { From 758ed1dc3885458314be18c5a75a09d98cf60e86 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 15 Aug 2015 22:56:47 -0400 Subject: [PATCH 08/87] Remove installation URL != old URL case By not taking account the rare case, we simplify the code by having less duplication. The tradeoff is that the rare case will be slightly less efficient. --- Sparkle/SUPlainInstaller.m | 119 +++++++++++++------------------------ 1 file changed, 40 insertions(+), 79 deletions(-) diff --git a/Sparkle/SUPlainInstaller.m b/Sparkle/SUPlainInstaller.m index 1fa1a8dd..b70be520 100644 --- a/Sparkle/SUPlainInstaller.m +++ b/Sparkle/SUPlainInstaller.m @@ -80,87 +80,48 @@ NSString *oldDestinationNameWithPathExtension = [oldDestinationName stringByAppendingPathExtension:oldURL.pathExtension]; - // If the installation and old URL differ, the sooner we can install our new app - // because we won't have to move the old app out of the way first - // increasing our chances of having it installed in case something goes wrong - if (![installationURL isEqual:oldURL]) { - // Move the new app to its final destination - if (![fileManager moveItemAtURL:newTempURL toURL:installationURL error:error]) { - SULog(@"Failed to move new app at %@ to final destination %@ (with installationURL != oldURL)", newTempURL.path, installationURL.path); - [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; - return NO; - } - - // Cleanup: move the old app to the trash - // We will first have to move the app to a temporary location that the user may not care about - // This is necessary because the operation could fail mid-way through - // Nothing past here will be a fatal error because we already installed the new app - - // Create a temporary directory for our old app that resides on its volume - NSError *makeOldTempDirectoryError = nil; - NSURL *tempOldDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:oldDestinationName appropriateForDirectoryURL:oldURL.URLByDeletingLastPathComponent error:&makeOldTempDirectoryError]; - if (tempOldDirectoryURL == nil) { - SULog(@"Failed to create temporary directory for old app at %@ after finishing installation. This is not a fatal error. Error: %@", oldURL.path, makeOldTempDirectoryError); - } else { - // Move the old app to the temporary directory - NSURL *oldTempURL = [tempOldDirectoryURL URLByAppendingPathComponent:oldDestinationNameWithPathExtension]; - NSError *moveOldAppError = nil; - if (![fileManager moveItemAtURL:oldURL toURL:oldTempURL error:&moveOldAppError]) { - SULog(@"Failed to move the old app at %@ to a temporary location at %@. This is not a fatal error. Error: %@", oldURL.path, oldTempURL.path, moveOldAppError); - } else { - // Finally try to trash our old app - NSError *trashError = nil; - if (![fileManager moveItemAtURLToTrash:oldTempURL error:&trashError]) { - SULog(@"Failed to move %@ to trash. This is not a fatal error. Error: %@", oldURL, trashError); - } - } - - [fileManager removeItemAtURL:tempOldDirectoryURL error:NULL]; - } - } else { - // Create a temporary directory for our old app that resides on its volume - NSURL *tempOldDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:oldDestinationName appropriateForDirectoryURL:oldURL.URLByDeletingLastPathComponent error:error]; - if (tempOldDirectoryURL == nil) { - SULog(@"Failed to create temporary directory for old app at %@", oldURL.path); - [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; - return NO; - } - - // Move the old app to the temporary directory - NSURL *oldTempURL = [tempOldDirectoryURL URLByAppendingPathComponent:oldDestinationNameWithPathExtension]; - if (![fileManager moveItemAtURL:oldURL toURL:oldTempURL error:error]) { - SULog(@"Failed to move the old app at %@ to a temporary location at %@", oldURL.path, oldTempURL.path); - - // Just forget about our updated app on failure - [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; - [fileManager removeItemAtURL:tempOldDirectoryURL error:NULL]; - - return NO; - } - - // Move the new app to its final destination - if (![fileManager moveItemAtURL:newTempURL toURL:installationURL error:error]) { - SULog(@"Failed to move new app at %@ to final destination %@", newTempURL.path, installationURL.path); - - // Forget about our updated app on failure - [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; - - // Attempt to restore our old app back the way it was on failure - [fileManager moveItemAtURL:oldTempURL toURL:oldURL error:NULL]; - [fileManager removeItemAtURL:tempOldDirectoryURL error:NULL]; - - return NO; - } - - // Cleanup: move the old app to the trash - NSError *trashError = nil; - if (![fileManager moveItemAtURLToTrash:oldTempURL error:&trashError]) { - SULog(@"Failed to move %@ to trash with error %@", oldTempURL, trashError); - } - - [fileManager removeItemAtURL:tempOldDirectoryURL error:NULL]; + // Create a temporary directory for our old app that resides on its volume + NSURL *tempOldDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:oldDestinationName appropriateForDirectoryURL:oldURL.URLByDeletingLastPathComponent error:error]; + if (tempOldDirectoryURL == nil) { + SULog(@"Failed to create temporary directory for old app at %@", oldURL.path); + [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; + return NO; } + // Move the old app to the temporary directory + NSURL *oldTempURL = [tempOldDirectoryURL URLByAppendingPathComponent:oldDestinationNameWithPathExtension]; + if (![fileManager moveItemAtURL:oldURL toURL:oldTempURL error:error]) { + SULog(@"Failed to move the old app at %@ to a temporary location at %@", oldURL.path, oldTempURL.path); + + // Just forget about our updated app on failure + [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; + [fileManager removeItemAtURL:tempOldDirectoryURL error:NULL]; + + return NO; + } + + // Move the new app to its final destination + if (![fileManager moveItemAtURL:newTempURL toURL:installationURL error:error]) { + SULog(@"Failed to move new app at %@ to final destination %@", newTempURL.path, installationURL.path); + + // Forget about our updated app on failure + [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; + + // Attempt to restore our old app back the way it was on failure + [fileManager moveItemAtURL:oldTempURL toURL:oldURL error:NULL]; + [fileManager removeItemAtURL:tempOldDirectoryURL error:NULL]; + + return NO; + } + + // Cleanup: move the old app to the trash + NSError *trashError = nil; + if (![fileManager moveItemAtURLToTrash:oldTempURL error:&trashError]) { + SULog(@"Failed to move %@ to trash with error %@", oldTempURL, trashError); + } + + [fileManager removeItemAtURL:tempOldDirectoryURL error:NULL]; + [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; return YES; From 5b469d702e27fe055deac58f86196e6462a0a005 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 16 Aug 2015 01:38:41 -0400 Subject: [PATCH 09/87] Reduce code duplication for releasing quarantine --- Sparkle/SUFileManager.m | 117 +++++++++++++++++++++++----------------- 1 file changed, 68 insertions(+), 49 deletions(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 5c43289b..4dd66c35 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -206,21 +206,40 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } #endif - BOOL success = YES; - id rootResourceValue = nil; - if ([rootURL getResourceValue:&rootResourceValue forKey:NSURLQuarantinePropertiesKey error:NULL] && rootResourceValue != nil) { - NSError *setResourceError = nil; - if (![rootURL setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:&setResourceError]) { - if (allowsAuthentication && NS_HAS_PERMISSION_ERROR(setResourceError)) { - return [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; - } else { - if (error != NULL) { - *error = setResourceError; + __block BOOL success = YES; + + BOOL (^releasingQuarantineRequiredAuthentication)(NSURL *, BOOL *) = ^(NSURL *fileURL, BOOL *didReleaseQuarantine){ + BOOL removedQuarantine = NO; + BOOL attemptedAuthentication = NO; + + id resourceValue = nil; + if ([fileURL getResourceValue:&resourceValue forKey:NSURLQuarantinePropertiesKey error:NULL] && resourceValue != nil) { + NSError *setResourceError = nil; + if (![fileURL setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:&setResourceError]) { + if (allowsAuthentication && NS_HAS_PERMISSION_ERROR(setResourceError)) { + attemptedAuthentication = YES; + return [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; + } else { + // Make sure we haven't already run into an error + if (success && error != NULL) { + *error = setResourceError; + } + // Fail, but still try to release other items from quarantine + success = NO; } - // Fail, but still try to release other items from quarantine - success = NO; } } + + if (didReleaseQuarantine != NULL) { + *didReleaseQuarantine = removedQuarantine; + } + + return attemptedAuthentication; + }; + + BOOL releasedRootQuarantine = NO; + if (releasingQuarantineRequiredAuthentication(rootURL, &releasedRootQuarantine)) { + return releasedRootQuarantine; } // Only recurse if it's actually a directory. Don't recurse into a @@ -234,21 +253,9 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza NSDirectoryEnumerator *directoryEnumerator = [_fileManager enumeratorAtURL:rootURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil]; for (NSURL *file in directoryEnumerator) { - id fileResourceValue = nil; - if ([file getResourceValue:&fileResourceValue forKey:NSURLQuarantinePropertiesKey error:NULL] && fileResourceValue != nil) { - NSError *setResourceError = nil; - if (![file setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:&setResourceError]) { - if (allowsAuthentication && NS_HAS_PERMISSION_ERROR(setResourceError)) { - return [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; - } else { - // Make sure we haven't already run into an error - if (success && error != NULL) { - *error = setResourceError; - } - // Fail, but still try to release other items from quarantine - success = NO; - } - } + BOOL releasedQuarantine = NO; + if (releasingQuarantineRequiredAuthentication(file, &releasedQuarantine)) { + return releasedQuarantine; } } } @@ -264,24 +271,45 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // that the quarantine is implemented in part by setting an extended attribute, // "com.apple.quarantine", on affected files. Removing this attribute is // sufficient to remove files from the quarantine. + - (BOOL)releaseItemUsingOldMethodFromQuarantineAtRootURL:(NSURL *)rootURL allowingAuthentication:(BOOL)allowsAuthentication error:(NSError *__autoreleasing *)error { - BOOL success = YES; + __block BOOL success = YES; NSString *root = rootURL.path; const int removeXAttrOptions = XATTR_NOFOLLOW; - if ([self getXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:root options:removeXAttrOptions] >= 0) { - if ([self removeXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:root options:removeXAttrOptions] != 0) { - if (errno == EACCES) { - return [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; + BOOL (^releasingQuarantineRequiredAuthentication)(NSString *, BOOL *) = ^(NSString *path, BOOL *didReleaseQuarantine){ + BOOL removedQuarantine = NO; + BOOL attemptedAuthentication = NO; + + if ([self getXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:path options:removeXAttrOptions] >= 0) { + if ([self removeXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:path options:removeXAttrOptions] == 0) { + removedQuarantine = YES; } else { - if (error != NULL) { - *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove file quarantine on %@.", root.lastPathComponent] }]; + if (allowsAuthentication && errno == EACCES) { + attemptedAuthentication = YES; + removedQuarantine = [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; + } else { + // Make sure we haven't already run into an error + if (success && error != NULL) { + *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove file quarantine on %@.", path.lastPathComponent] }]; + } + // Fail, but still try to release other items from quarantine + success = NO; } - // Fail, but still try to release other items from quarantine - success = NO; } } + + if (didReleaseQuarantine != NULL) { + *didReleaseQuarantine = removedQuarantine; + } + + return attemptedAuthentication; + }; + + BOOL releasedRootQuarantine = NO; + if (releasingQuarantineRequiredAuthentication(root, &releasedRootQuarantine)) { + return releasedRootQuarantine; } // Only recurse if it's actually a directory. Don't recurse into a @@ -296,19 +324,10 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza NSString *file = nil; while ((file = [directoryEnumerator nextObject])) { NSString *filePath = [root stringByAppendingPathComponent:file]; - if ([self getXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:filePath options:removeXAttrOptions] >= 0) { - if ([self removeXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:filePath options:removeXAttrOptions] != 0) { - if (allowsAuthentication && errno == EACCES) { - return [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; - } else { - // Make sure we haven't already run into an error - if (success && error != NULL) { - *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove file quarantine on %@.", filePath.lastPathComponent] }]; - } - // Fail, but still try to release other items from quarantine - success = NO; - } - } + + BOOL releasedQuarantine = NO; + if (releasingQuarantineRequiredAuthentication(filePath, &releasedQuarantine)) { + return releasedQuarantine; } } } From ba73e52f092ad1e133572a92540901ce61ffe837 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 16 Aug 2015 10:47:37 -0400 Subject: [PATCH 10/87] Reduce more duplication for releasing quarantine --- Sparkle/SUFileManager.m | 126 +++++++++++++++++----------------------- 1 file changed, 52 insertions(+), 74 deletions(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 4dd66c35..1eddc110 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -188,6 +188,36 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return success; } +- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL usingMethod:(BOOL (^)(NSURL *, BOOL *, BOOL *))releasingQuarantineRequiredAuthentication +{ + BOOL success = YES; + + BOOL releasedRootQuarantine = NO; + if (releasingQuarantineRequiredAuthentication(rootURL, &releasedRootQuarantine, &success)) { + return releasedRootQuarantine; + } + + // Only recurse if it's actually a directory. Don't recurse into a + // root-level symbolic link. + NSDictionary *rootAttributes = [_fileManager attributesOfItemAtPath:rootURL.path error:nil]; + NSString *rootType = rootAttributes[NSFileType]; + + if ([rootType isEqualToString:NSFileTypeDirectory]) { + // The NSDirectoryEnumerator will avoid recursing into any contained + // symbolic links, so no further type checks are needed. + NSDirectoryEnumerator *directoryEnumerator = [_fileManager enumeratorAtURL:rootURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil]; + + for (NSURL *file in directoryEnumerator) { + BOOL releasedQuarantine = NO; + if (releasingQuarantineRequiredAuthentication(file, &releasedQuarantine, &success)) { + return releasedQuarantine; + } + } + } + + return success; +} + #define APPLE_QUARANTINE_IDENTIFIER @"com.apple.quarantine" // Removes the directory tree rooted at |root| from the file quarantine. @@ -206,9 +236,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } #endif - __block BOOL success = YES; - - BOOL (^releasingQuarantineRequiredAuthentication)(NSURL *, BOOL *) = ^(NSURL *fileURL, BOOL *didReleaseQuarantine){ + return [self releaseItemFromQuarantineAtRootURL:rootURL usingMethod:^BOOL(NSURL *fileURL, BOOL *didReleaseQuarantine, BOOL *success) { BOOL removedQuarantine = NO; BOOL attemptedAuthentication = NO; @@ -218,14 +246,16 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza if (![fileURL setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:&setResourceError]) { if (allowsAuthentication && NS_HAS_PERMISSION_ERROR(setResourceError)) { attemptedAuthentication = YES; - return [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; + removedQuarantine = [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; } else { - // Make sure we haven't already run into an error - if (success && error != NULL) { - *error = setResourceError; + if (success != NULL) { + // Make sure we haven't already run into an error + if (*success && error != NULL) { + *error = setResourceError; + } + // Fail, but still try to release other items from quarantine + *success = NO; } - // Fail, but still try to release other items from quarantine - success = NO; } } } @@ -235,32 +265,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } return attemptedAuthentication; - }; - - BOOL releasedRootQuarantine = NO; - if (releasingQuarantineRequiredAuthentication(rootURL, &releasedRootQuarantine)) { - return releasedRootQuarantine; - } - - // Only recurse if it's actually a directory. Don't recurse into a - // root-level symbolic link. - NSDictionary *rootAttributes = [_fileManager attributesOfItemAtPath:rootURL.path error:nil]; - NSString *rootType = rootAttributes[NSFileType]; - - if (rootType == NSFileTypeDirectory) { - // The NSDirectoryEnumerator will avoid recursing into any contained - // symbolic links, so no further type checks are needed. - NSDirectoryEnumerator *directoryEnumerator = [_fileManager enumeratorAtURL:rootURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil]; - - for (NSURL *file in directoryEnumerator) { - BOOL releasedQuarantine = NO; - if (releasingQuarantineRequiredAuthentication(file, &releasedQuarantine)) { - return releasedQuarantine; - } - } - } - - return success; + }]; } // Ordinarily, the quarantine is managed by calling LSSetItemAttribute @@ -274,28 +279,28 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza - (BOOL)releaseItemUsingOldMethodFromQuarantineAtRootURL:(NSURL *)rootURL allowingAuthentication:(BOOL)allowsAuthentication error:(NSError *__autoreleasing *)error { - __block BOOL success = YES; - NSString *root = rootURL.path; - const int removeXAttrOptions = XATTR_NOFOLLOW; + static const int removeXAttrOptions = XATTR_NOFOLLOW; - BOOL (^releasingQuarantineRequiredAuthentication)(NSString *, BOOL *) = ^(NSString *path, BOOL *didReleaseQuarantine){ + return [self releaseItemFromQuarantineAtRootURL:rootURL usingMethod:^BOOL(NSURL *fileURL, BOOL *didReleaseQuarantine, BOOL *success) { BOOL removedQuarantine = NO; BOOL attemptedAuthentication = NO; - if ([self getXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:path options:removeXAttrOptions] >= 0) { - if ([self removeXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:path options:removeXAttrOptions] == 0) { + if ([self getXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:fileURL.path options:removeXAttrOptions] >= 0) { + if ([self removeXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:fileURL.path options:removeXAttrOptions] == 0) { removedQuarantine = YES; } else { if (allowsAuthentication && errno == EACCES) { attemptedAuthentication = YES; removedQuarantine = [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; } else { - // Make sure we haven't already run into an error - if (success && error != NULL) { - *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove file quarantine on %@.", path.lastPathComponent] }]; + if (success != NULL) { + // Make sure we haven't already run into an error + if (*success && error != NULL) { + *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove file quarantine on %@.", fileURL.lastPathComponent] }]; + } + // Fail, but still try to release other items from quarantine + *success = NO; } - // Fail, but still try to release other items from quarantine - success = NO; } } } @@ -305,34 +310,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } return attemptedAuthentication; - }; - - BOOL releasedRootQuarantine = NO; - if (releasingQuarantineRequiredAuthentication(root, &releasedRootQuarantine)) { - return releasedRootQuarantine; - } - - // Only recurse if it's actually a directory. Don't recurse into a - // root-level symbolic link. - NSDictionary *rootAttributes = [_fileManager attributesOfItemAtPath:root error:nil]; - NSString *rootType = rootAttributes[NSFileType]; - - if ([rootType isEqualToString:NSFileTypeDirectory]) { - // The NSDirectoryEnumerator will avoid recursing into any contained - // symbolic links, so no further type checks are needed. - NSDirectoryEnumerator *directoryEnumerator = [_fileManager enumeratorAtPath:root]; - NSString *file = nil; - while ((file = [directoryEnumerator nextObject])) { - NSString *filePath = [root stringByAppendingPathComponent:file]; - - BOOL releasedQuarantine = NO; - if (releasingQuarantineRequiredAuthentication(filePath, &releasedQuarantine)) { - return releasedQuarantine; - } - } - } - - return success; + }]; } - (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError * __autoreleasing *)error From 182652a231116136d5ecf0bf43e4b6f156f05696 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 16 Aug 2015 11:01:04 -0400 Subject: [PATCH 11/87] Error if file doesn't exist when releasing quarantine --- Sparkle/SUFileManager.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 1eddc110..69d8b2e2 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -188,8 +188,15 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return success; } -- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL usingMethod:(BOOL (^)(NSURL *, BOOL *, BOOL *))releasingQuarantineRequiredAuthentication +- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL usingMethod:(BOOL (^)(NSURL *, BOOL *, BOOL *))releasingQuarantineRequiredAuthentication error:(NSError * __autoreleasing *)error { + if (![self itemExistsAtURL:rootURL]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove quarantine because %@ does not exist.", rootURL.path.lastPathComponent] }]; + } + return NO; + } + BOOL success = YES; BOOL releasedRootQuarantine = NO; @@ -265,7 +272,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } return attemptedAuthentication; - }]; + } error:error]; } // Ordinarily, the quarantine is managed by calling LSSetItemAttribute @@ -310,7 +317,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } return attemptedAuthentication; - }]; + } error:error]; } - (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError * __autoreleasing *)error From 2782b426d92407513c5ff1fd4b5a25c53480396f Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 16 Aug 2015 12:08:24 -0400 Subject: [PATCH 12/87] Reduce even more releasing quarantine duplication --- Sparkle/SUFileManager.m | 131 +++++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 63 deletions(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 69d8b2e2..7bf38b33 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -188,7 +188,9 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return success; } -- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL usingMethod:(BOOL (^)(NSURL *, BOOL *, BOOL *))releasingQuarantineRequiredAuthentication error:(NSError * __autoreleasing *)error +#define APPLE_QUARANTINE_IDENTIFIER @"com.apple.quarantine" + +- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL allowingAuthentication:(BOOL)allowsAuthentication withQuarantineRetrieval:(BOOL (^)(NSURL *))quarantineRetrieval quarantineRemoval:(BOOL (^)(NSURL *, NSError * __autoreleasing *))quarantineRemoval isAccessError:(BOOL (^)(NSError *))isAccessError error:(NSError * __autoreleasing *)error { if (![self itemExistsAtURL:rootURL]) { if (error != NULL) { @@ -197,6 +199,38 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return NO; } + BOOL (^releasingQuarantineRequiredAuthentication)(NSURL *, BOOL *, BOOL *) = ^(NSURL *fileURL, BOOL *didReleaseQuarantine, BOOL *success) { + BOOL removedQuarantine = NO; + BOOL attemptedAuthentication = NO; + + if (quarantineRetrieval(fileURL)) { + NSError *removalError = nil; + if (quarantineRemoval(fileURL, &removalError)) { + removedQuarantine = YES; + } else { + if (allowsAuthentication && isAccessError(removalError)) { + removedQuarantine = [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL: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 (didReleaseQuarantine != NULL) { + *didReleaseQuarantine = removedQuarantine; + } + + return attemptedAuthentication; + }; + BOOL success = YES; BOOL releasedRootQuarantine = NO; @@ -225,8 +259,6 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return success; } -#define APPLE_QUARANTINE_IDENTIFIER @"com.apple.quarantine" - // Removes the directory tree rooted at |root| from the file quarantine. // The quarantine was introduced on OS X 10.5 and is described at: // @@ -243,36 +275,21 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } #endif - return [self releaseItemFromQuarantineAtRootURL:rootURL usingMethod:^BOOL(NSURL *fileURL, BOOL *didReleaseQuarantine, BOOL *success) { - BOOL removedQuarantine = NO; - BOOL attemptedAuthentication = NO; - - id resourceValue = nil; - if ([fileURL getResourceValue:&resourceValue forKey:NSURLQuarantinePropertiesKey error:NULL] && resourceValue != nil) { - NSError *setResourceError = nil; - if (![fileURL setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:&setResourceError]) { - if (allowsAuthentication && NS_HAS_PERMISSION_ERROR(setResourceError)) { - attemptedAuthentication = YES; - removedQuarantine = [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; - } else { - if (success != NULL) { - // Make sure we haven't already run into an error - if (*success && error != NULL) { - *error = setResourceError; - } - // Fail, but still try to release other items from quarantine - *success = NO; - } - } - } - } - - if (didReleaseQuarantine != NULL) { - *didReleaseQuarantine = removedQuarantine; - } - - return attemptedAuthentication; - } error:error]; + return + [self + releaseItemFromQuarantineAtRootURL:rootURL + allowingAuthentication:allowsAuthentication + withQuarantineRetrieval:^BOOL(NSURL *fileURL) { + id resourceValue = nil; + return ([fileURL getResourceValue:&resourceValue forKey:NSURLQuarantinePropertiesKey error:NULL] && resourceValue != nil); + } + quarantineRemoval:^BOOL(NSURL *fileURL, NSError *__autoreleasing *removalError) { + return [fileURL setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:removalError]; + } + isAccessError:^BOOL(NSError *removalError) { + return NS_HAS_PERMISSION_ERROR(removalError); + } + error:error]; } // Ordinarily, the quarantine is managed by calling LSSetItemAttribute @@ -288,36 +305,24 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza { static const int removeXAttrOptions = XATTR_NOFOLLOW; - return [self releaseItemFromQuarantineAtRootURL:rootURL usingMethod:^BOOL(NSURL *fileURL, BOOL *didReleaseQuarantine, BOOL *success) { - BOOL removedQuarantine = NO; - BOOL attemptedAuthentication = NO; - - if ([self getXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:fileURL.path options:removeXAttrOptions] >= 0) { - if ([self removeXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:fileURL.path options:removeXAttrOptions] == 0) { - removedQuarantine = YES; - } else { - if (allowsAuthentication && errno == EACCES) { - attemptedAuthentication = YES; - removedQuarantine = [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; - } else { - if (success != NULL) { - // Make sure we haven't already run into an error - if (*success && error != NULL) { - *error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove file quarantine on %@.", fileURL.lastPathComponent] }]; - } - // Fail, but still try to release other items from quarantine - *success = NO; - } - } - } - } - - if (didReleaseQuarantine != NULL) { - *didReleaseQuarantine = removedQuarantine; - } - - return attemptedAuthentication; - } error:error]; + return + [self + releaseItemFromQuarantineAtRootURL:rootURL + allowingAuthentication:allowsAuthentication + withQuarantineRetrieval:^BOOL(NSURL *fileURL) { + return ([self getXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:fileURL.path options:removeXAttrOptions] >= 0); + } + quarantineRemoval:^BOOL(NSURL *fileURL, NSError * __autoreleasing *removalError) { + BOOL removedQuarantine = ([self removeXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:fileURL.path options:removeXAttrOptions] == 0); + if (!removedQuarantine && removalError != NULL) { + *removalError = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove file quarantine on %@.", fileURL.lastPathComponent] }]; + } + return removedQuarantine; + } + isAccessError:^BOOL(NSError *removalError) { + return (removalError.code == EACCES); + } + error:error]; } - (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError * __autoreleasing *)error From e60baaeec8eeaba41d719c82a5aa9591b5586dec Mon Sep 17 00:00:00 2001 From: Zorg Date: Mon, 21 Sep 2015 23:26:41 -0400 Subject: [PATCH 13/87] Keep Auto Updater alive for small delay before launching app This increases the likelihood that the updated launched app will be brought up front and active. --- Sparkle/Autoupdate/Autoupdate.m | 66 +++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/Sparkle/Autoupdate/Autoupdate.m b/Sparkle/Autoupdate/Autoupdate.m index 0c7db37c..d06a8653 100644 --- a/Sparkle/Autoupdate/Autoupdate.m +++ b/Sparkle/Autoupdate/Autoupdate.m @@ -72,6 +72,13 @@ static const NSTimeInterval SUParentQuitCheckInterval = .25; */ static const NSTimeInterval SUInstallationTimeLimit = 5; +/*! + * Terminate the application after a delay from launching the new update to avoid OS activation issues + * This delay should be be high enough to increase the likelihood that our updated app will be launched up front, + * but should be low enough so that the user doesn't ponder why the updater hasn't finished terminating yet + */ +static const NSTimeInterval SUTerminationTimeDelay = 0.5; + @interface AppInstaller : NSObject /* @@ -97,6 +104,8 @@ static const NSTimeInterval SUInstallationTimeLimit = 5; @property (nonatomic, assign) BOOL shouldRelaunch; @property (nonatomic, assign) BOOL shouldShowUI; +@property (nonatomic, assign) BOOL isTerminating; + @end @implementation AppInstaller @@ -108,6 +117,7 @@ static const NSTimeInterval SUInstallationTimeLimit = 5; @synthesize relaunchPath = _relaunchPath; @synthesize shouldRelaunch = _shouldRelaunch; @synthesize shouldShowUI = _shouldShowUI; +@synthesize isTerminating = _isTerminating; - (instancetype)initWithHostPath:(NSString *)hostPath relaunchPath:(NSString *)relaunchPath parentProcessId:(pid_t)parentProcessId updateFolderPath:(NSString *)updateFolderPath shouldRelaunch:(BOOL)shouldRelaunch shouldShowUI:(BOOL)shouldShowUI { @@ -131,12 +141,14 @@ static const NSTimeInterval SUInstallationTimeLimit = 5; self.terminationListener = nil; dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUInstallationTimeLimit * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - // Show app icon in the dock - ProcessSerialNumber psn = { 0, kCurrentProcess }; - TransformProcessType(&psn, kProcessTransformToForegroundApplication); + if (!self.isTerminating) { + // Show app icon in the dock + ProcessSerialNumber psn = { 0, kCurrentProcess }; + TransformProcessType(&psn, kProcessTransformToForegroundApplication); + } }); - [self install]; + [self install]; }]; } @@ -150,7 +162,7 @@ static const NSTimeInterval SUInstallationTimeLimit = 5; self.statusController = [[SUStatusController alloc] initWithHost:host]; [self.statusController setButtonTitle:SULocalizedString(@"Cancel Update", @"") target:nil action:Nil isDefault:NO]; [self.statusController beginActionWithTitle:SULocalizedString(@"Installing update...", @"") - maxProgressValue: 0 statusText: @""]; + maxProgressValue: 0 statusText: @""]; [self.statusController showWindow:self]; } @@ -181,21 +193,43 @@ static const NSTimeInterval SUInstallationTimeLimit = 5; }]; } -- (void)cleanupAndTerminateWithPathToRelaunch:(NSString *)relaunchPath __attribute__((noreturn)) +- (void)cleanupAndTerminateWithPathToRelaunch:(NSString *)relaunchPath { + self.isTerminating = YES; + + dispatch_block_t cleanupAndExit = ^{ + NSError *theError = nil; + if (![SUPlainInstaller _removeFileAtPath:self.updateFolderPath error:&theError]) { + SULog(@"Couldn't remove update folder: %@.", theError); + } + + [[NSFileManager defaultManager] removeItemAtPath:[[NSBundle mainBundle] bundlePath] error:NULL]; + + exit(EXIT_SUCCESS); + }; + if (self.shouldRelaunch) { - if (![[NSWorkspace sharedWorkspace] openFile:relaunchPath]) { + // The auto updater can terminate before the newly updated app is finished launching + // If that happens, the OS may not make the updated app active and frontmost + // (Or it does become frontmost, but the OS backgrounds it afterwards.. It's some kind of timing/activation issue that doesn't occur all the time) + // The only remedy I've been able to find is waiting an arbitrary delay before exiting our application + + if (![[NSWorkspace sharedWorkspace] launchApplication:relaunchPath]) { SULog(@"Failed to launch %@", relaunchPath); } + + [self.statusController close]; + + // Don't even think about hiding the app icon from the dock if we've already shown it + // Transforming the app back to a background one has a backfiring effect, decreasing the likelihood + // that the updated app will be brought up front + + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUTerminationTimeDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + cleanupAndExit(); + }); + } else { + cleanupAndExit(); } - - NSError *theError = nil; - if (![SUPlainInstaller _removeFileAtPath:self.updateFolderPath error:&theError]) - SULog(@"Couldn't remove update folder: %@.", theError); - - [[NSFileManager defaultManager] removeItemAtPath:[[NSBundle mainBundle] bundlePath] error:NULL]; - - exit(EXIT_SUCCESS); } @end @@ -219,7 +253,7 @@ int main(int __unused argc, const char __unused *argv[]) AppInstaller *appInstaller = [[AppInstaller alloc] initWithHostPath:args[1] relaunchPath:args[2] parentProcessId:[args[3] intValue] - updateFolderPath:args[4] + updateFolderPath:args[4] shouldRelaunch:(args.count > 5) ? [args[5] boolValue] : YES shouldShowUI:shouldShowUI]; [application setDelegate:appInstaller]; From 39f17764e3ac7a336cbc0fec520f22c69eec66a6 Mon Sep 17 00:00:00 2001 From: Zorg Date: Thu, 24 Sep 2015 20:43:20 -0400 Subject: [PATCH 14/87] Don't show Autoupdate dock icon if we shouldn't show UI --- Sparkle/Autoupdate/Autoupdate.m | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Sparkle/Autoupdate/Autoupdate.m b/Sparkle/Autoupdate/Autoupdate.m index 0c7db37c..cfbc3f5d 100644 --- a/Sparkle/Autoupdate/Autoupdate.m +++ b/Sparkle/Autoupdate/Autoupdate.m @@ -130,11 +130,13 @@ static const NSTimeInterval SUInstallationTimeLimit = 5; [self.terminationListener startListeningWithCompletion:^{ self.terminationListener = nil; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUInstallationTimeLimit * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - // Show app icon in the dock - ProcessSerialNumber psn = { 0, kCurrentProcess }; - TransformProcessType(&psn, kProcessTransformToForegroundApplication); - }); + if (self.shouldShowUI) { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUInstallationTimeLimit * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + // Show app icon in the dock + ProcessSerialNumber psn = { 0, kCurrentProcess }; + TransformProcessType(&psn, kProcessTransformToForegroundApplication); + }); + } [self install]; }]; From eead36eb47029b7062afb972fbec8cefa710b735 Mon Sep 17 00:00:00 2001 From: Kevin Wojniak Date: Thu, 24 Sep 2015 19:28:31 -0700 Subject: [PATCH 15/87] Fix analyzer warning "Value stored to completionBlock is never read" --- Sparkle/Autoupdate/Autoupdate.m | 1 - 1 file changed, 1 deletion(-) diff --git a/Sparkle/Autoupdate/Autoupdate.m b/Sparkle/Autoupdate/Autoupdate.m index 0c7db37c..a66ce347 100644 --- a/Sparkle/Autoupdate/Autoupdate.m +++ b/Sparkle/Autoupdate/Autoupdate.m @@ -46,7 +46,6 @@ static const NSTimeInterval SUParentQuitCheckInterval = .25; { [self.watchdogTimer invalidate]; completionBlock(); - completionBlock = nil; } - (void)startListeningWithCompletion:(void (^)(void))completionBlock From aa4cc6a7dcb85befaec67a81d333650d65a4a5bd Mon Sep 17 00:00:00 2001 From: Zorg Date: Thu, 24 Sep 2015 23:07:49 -0400 Subject: [PATCH 16/87] Don't install automatic updates if the system might shut off --- Sparkle/SUAutomaticUpdateDriver.m | 11 +++++++++++ Sparkle/SUErrors.h | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Sparkle/SUAutomaticUpdateDriver.m b/Sparkle/SUAutomaticUpdateDriver.m index 45b3d546..562f2d05 100644 --- a/Sparkle/SUAutomaticUpdateDriver.m +++ b/Sparkle/SUAutomaticUpdateDriver.m @@ -63,6 +63,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 - (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil]; + [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil]; // Sudden termination is available on 10.6+ NSProcessInfo *processInfo = [NSProcessInfo processInfo]; @@ -103,6 +104,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 if (self.willUpdateOnTermination) { [[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationWillTerminateNotification object:nil]; + [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self name:NSWorkspaceWillPowerOffNotification object:nil]; + NSProcessInfo *processInfo = [NSProcessInfo processInfo]; [processInfo enableSuddenTermination]; @@ -151,6 +154,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 case SUInstallLaterChoice: self.postponingInstallation = YES; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil]; + [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil]; // We're already waiting on quit, just indicate that we're idle. self.interruptible = YES; break; @@ -172,6 +176,13 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 [super installWithToolAndRelaunch:relaunch displayingUserInterface:showUI]; } +- (void)systemWillPowerOff:(NSNotification *)__unused note +{ + [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSystemPowerOffError userInfo:@{ + NSLocalizedDescriptionKey: SULocalizedString(@"The update will not be installed because the user requested for the system to power off", nil) + }]]; +} + - (void)applicationWillTerminate:(NSNotification *)__unused note { [self installWithToolAndRelaunch:NO]; diff --git a/Sparkle/SUErrors.h b/Sparkle/SUErrors.h index e624bb05..d73aadba 100644 --- a/Sparkle/SUErrors.h +++ b/Sparkle/SUErrors.h @@ -38,7 +38,10 @@ typedef NS_ENUM(OSStatus, SUError) { SUMissingInstallerToolError = 4003, SURelaunchError = 4004, SUInstallationError = 4005, - SUDowngradeError = 4006 + SUDowngradeError = 4006, + + // System phase errors + SUSystemPowerOffError = 5000 }; #endif From dc0aca1d1634986715700c5b13d904e96882d233 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 25 Sep 2015 09:26:54 -0700 Subject: [PATCH 17/87] Avoid firstObject method in order to build with older SDKs. --- Sparkle/SUFileManager.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 7bf38b33..4c987f43 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -645,7 +645,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza #endif if (canUseNewTrashAPI) { - trashURL = [[_fileManager URLsForDirectory:NSTrashDirectory inDomains:NSUserDomainMask] firstObject]; + trashURL = [_fileManager URLForDirectory:NSTrashDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil]; } if (trashURL == nil) { From aae9e12b8a172eb80aeb74f9eddf9dd03dc1059a Mon Sep 17 00:00:00 2001 From: Kevin Wojniak Date: Fri, 25 Sep 2015 09:34:40 -0700 Subject: [PATCH 18/87] Make requirements more explicit --- README.markdown | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 824729f7..09cdee54 100644 --- a/README.markdown +++ b/README.markdown @@ -31,9 +31,10 @@ An easy-to-use software update framework for Cocoa developers. * Supports bundles, preference panes, plugins, and other non-.app software. Can install .pkg files for more complicated products. * Supports branches due to minimum OS version requirements. -## Developers +## Requirements -Building Sparkle requires Xcode 5 or above. +* OS X 10.7+ +* Xcode 5+ to build from source ### API From 222fe94a05bfee029f3e5c2d2f67e710e15c196e Mon Sep 17 00:00:00 2001 From: Kevin Wojniak Date: Fri, 25 Sep 2015 09:54:32 -0700 Subject: [PATCH 19/87] Specify required SDK --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 09cdee54..5669da02 100644 --- a/README.markdown +++ b/README.markdown @@ -33,8 +33,8 @@ An easy-to-use software update framework for Cocoa developers. ## Requirements -* OS X 10.7+ -* Xcode 5+ to build from source +* Runtime: OS X 10.7 or greater +* Build: Xcode 5 and 10.8 SDK or greater ### API From e1002f066249db59fef3b6ec532086351b389a26 Mon Sep 17 00:00:00 2001 From: Zorg Date: Fri, 25 Sep 2015 18:51:55 -0400 Subject: [PATCH 20/87] Revert using -[NSWorkspace openFile:] --- Sparkle/Autoupdate/Autoupdate.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Sparkle/Autoupdate/Autoupdate.m b/Sparkle/Autoupdate/Autoupdate.m index d06a8653..3fa016d3 100644 --- a/Sparkle/Autoupdate/Autoupdate.m +++ b/Sparkle/Autoupdate/Autoupdate.m @@ -214,7 +214,8 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5; // (Or it does become frontmost, but the OS backgrounds it afterwards.. It's some kind of timing/activation issue that doesn't occur all the time) // The only remedy I've been able to find is waiting an arbitrary delay before exiting our application - if (![[NSWorkspace sharedWorkspace] launchApplication: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); } From 32591954bcb565a049b751e69e202f900c6ae4b3 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 26 Sep 2015 10:09:05 -0400 Subject: [PATCH 21/87] Add SUFileManager tests and fix issues along the way * Fix uid / gid not being applied to the root path or non-directory inputs * Remove the code that released quarantines using the NSURL way. It turned out not to be very reliable and didn't pass the tests. More explanation is given in the code. * Prefix private methods with _ and expose some of them to the tests --- Sparkle.xcodeproj/project.pbxproj | 6 + Sparkle/SUFileManager.m | 158 +++++++------- Tests/SUFileManagerTest.swift | 229 +++++++++++++++++++++ Tests/Sparkle Unit Tests-Bridging-Header.h | 14 ++ 4 files changed, 329 insertions(+), 78 deletions(-) create mode 100644 Tests/SUFileManagerTest.swift diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index b1f6dddb..25b05069 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -173,6 +173,8 @@ 7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */; }; 7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; 7275F9C31B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; + 72A4A2401BB6567D00E7820D /* SUFileManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72A4A23F1BB6567D00E7820D /* SUFileManagerTest.swift */; settings = {ASSET_TAGS = (); }; }; + 72A4A2411BB656FA00E7820D /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; 72AC6B261B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B251B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz */; settings = {ASSET_TAGS = (); }; }; 72AC6B281B9AAD6700F62325 /* SparkleTestCodeSignApp.tar in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B271B9AAD6700F62325 /* SparkleTestCodeSignApp.tar */; settings = {ASSET_TAGS = (); }; }; 72AC6B2A1B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B291B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 */; settings = {ASSET_TAGS = (); }; }; @@ -569,6 +571,7 @@ 7268AC641AD634E400C3E0C1 /* SUBinaryDeltaCreate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBinaryDeltaCreate.h; sourceTree = ""; }; 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUFileManager.h; sourceTree = ""; }; 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUFileManager.m; sourceTree = ""; }; + 72A4A23F1BB6567D00E7820D /* SUFileManagerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUFileManagerTest.swift; sourceTree = ""; }; 72AC6B251B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz */ = {isa = PBXFileReference; lastKnownFileType = archive.gzip; path = SparkleTestCodeSignApp.tar.gz; sourceTree = ""; }; 72AC6B271B9AAD6700F62325 /* SparkleTestCodeSignApp.tar */ = {isa = PBXFileReference; lastKnownFileType = archive.tar; path = SparkleTestCodeSignApp.tar; sourceTree = ""; }; 72AC6B291B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 */ = {isa = PBXFileReference; lastKnownFileType = file; path = SparkleTestCodeSignApp.tar.bz2; sourceTree = ""; }; @@ -883,6 +886,7 @@ 14950074195FDF5900BC5B5B /* SUUpdaterTest.m */, 61227A150DB548B800AB99EA /* SUVersionComparisonTest.m */, 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */, + 72A4A23F1BB6567D00E7820D /* SUFileManagerTest.swift */, 72AFC6121B9A944200F6B565 /* Sparkle Unit Tests-Bridging-Header.h */, ); path = Tests; @@ -1483,6 +1487,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 72A4A2411BB656FA00E7820D /* SUFileManager.m in Sources */, 721CF1A71AD7643600D9AC09 /* bsdiff.c in Sources */, 721CF1A81AD7644100D9AC09 /* bspatch.c in Sources */, 721CF1A91AD7644C00D9AC09 /* sais.c in Sources */, @@ -1493,6 +1498,7 @@ 5AF9DC3C1981DBEE001EA135 /* SUDSAVerifierTest.m in Sources */, 5AF6C7541AEA49840014A3AB /* SUInstallerTest.m in Sources */, 14652F8219A9746000959E44 /* SULog.m in Sources */, + 72A4A2401BB6567D00E7820D /* SUFileManagerTest.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 4c987f43..122c8b56 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -11,9 +11,11 @@ #include #include -#if __MAC_OS_X_VERSION_MAX_ALLOWED < 101000 /* MAC_OS_X_VERSION_10_10 */ -extern NSString *const NSURLQuarantinePropertiesKey WEAK_IMPORT_ATTRIBUTE; -#endif +#pragma clang diagnostic push +// This is a private constant but it's referenced from our unit tests +#pragma clang diagnostic ignored "-Wmissing-variable-declarations" +NSString *SUAppleQuarantineIdentifier = @"com.apple.quarantine"; +#pragma clang diagnostic pop // Authorization code based on generous contribution from Allan Odgaard. Thanks, Allan! static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char *executablePath, AuthorizationFlags options, char *const *arguments) @@ -64,7 +66,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } // Acquires an authorization reference which is intended to be used for future authorized file operations -- (BOOL)acquireAuthorizationWithError:(NSError *__autoreleasing *)error +- (BOOL)_acquireAuthorizationWithError:(NSError *__autoreleasing *)error { // No need to continue if we already acquired an authorization reference if (_auth != NULL) { @@ -91,12 +93,12 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // -[NSFileManager attributesOfItemAtPath:error:] won't follow symbolic links -- (BOOL)itemExistsAtURL:(NSURL *)fileURL +- (BOOL)_itemExistsAtURL:(NSURL *)fileURL { return [_fileManager attributesOfItemAtPath:fileURL.path error:NULL] != nil; } -- (BOOL)itemExistsAtURL:(NSURL *)fileURL isDirectory:(BOOL *)isDirectory +- (BOOL)_itemExistsAtURL:(NSURL *)fileURL isDirectory:(BOOL *)isDirectory { NSDictionary *attributes = [_fileManager attributesOfItemAtPath:fileURL.path error:NULL]; if (attributes == nil) { @@ -111,7 +113,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } // Wrapper around getxattr() -- (ssize_t)getXAttr:(NSString *)nameString fromFile:(NSString *)file options:(int)options +- (ssize_t)_getXAttr:(NSString *)nameString fromFile:(NSString *)file options:(int)options { char path[PATH_MAX] = {0}; if (![file getFileSystemRepresentation:path maxLength:sizeof(path)]) { @@ -129,7 +131,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } // Wrapper around removexattr() -- (int)removeXAttr:(NSString *)name fromFile:(NSString *)file options:(int)options +- (int)_removeXAttr:(NSString *)name fromFile:(NSString *)file options:(int)options { char path[PATH_MAX] = {0}; if (![file getFileSystemRepresentation:path maxLength:sizeof(path)]) { @@ -148,7 +150,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza #define XATTR_UTILITY_PATH "/usr/bin/xattr" // Recursively remove an xattr at a specified root URL with authentication -- (BOOL)removeXAttrWithAuthentication:(NSString *)name fromRootURL:(NSURL *)rootURL error:(NSError *__autoreleasing *)error +- (BOOL)_removeXAttrWithAuthentication:(NSString *)name fromRootURL:(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)]) { @@ -174,7 +176,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return NO; } - if (![self acquireAuthorizationWithError:error]) { + if (![self _acquireAuthorizationWithError:error]) { return NO; } @@ -188,11 +190,9 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return success; } -#define APPLE_QUARANTINE_IDENTIFIER @"com.apple.quarantine" - -- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL allowingAuthentication:(BOOL)allowsAuthentication withQuarantineRetrieval:(BOOL (^)(NSURL *))quarantineRetrieval quarantineRemoval:(BOOL (^)(NSURL *, NSError * __autoreleasing *))quarantineRemoval isAccessError:(BOOL (^)(NSError *))isAccessError error:(NSError * __autoreleasing *)error +- (BOOL)_releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL allowingAuthentication:(BOOL)allowsAuthentication withQuarantineRetrieval:(BOOL (^)(NSURL *))quarantineRetrieval quarantineRemoval:(BOOL (^)(NSURL *, NSError * __autoreleasing *))quarantineRemoval isAccessError:(BOOL (^)(NSError *))isAccessError error:(NSError * __autoreleasing *)error { - if (![self itemExistsAtURL:rootURL]) { + if (![self _itemExistsAtURL:rootURL]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove quarantine because %@ does not exist.", rootURL.path.lastPathComponent] }]; } @@ -209,7 +209,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza removedQuarantine = YES; } else { if (allowsAuthentication && isAccessError(removalError)) { - removedQuarantine = [self removeXAttrWithAuthentication:APPLE_QUARANTINE_IDENTIFIER fromRootURL:rootURL error:error]; + removedQuarantine = [self _removeXAttrWithAuthentication:SUAppleQuarantineIdentifier fromRootURL:rootURL error:error]; attemptedAuthentication = YES; } else { if (success != NULL) { @@ -267,30 +267,6 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // If |root| is not a directory, then it alone is removed from the quarantine. // Symbolic links, including |root| if it is a symbolic link, will not be // traversed. -- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL allowingAuthentication:(BOOL)allowsAuthentication error:(NSError * __autoreleasing *)error -{ -#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000 /* MAC_OS_X_VERSION_10_10 */ - if (!&NSURLQuarantinePropertiesKey) { - return [self releaseItemUsingOldMethodFromQuarantineAtRootURL:rootURL allowingAuthentication:allowsAuthentication error:error]; - } -#endif - - return - [self - releaseItemFromQuarantineAtRootURL:rootURL - allowingAuthentication:allowsAuthentication - withQuarantineRetrieval:^BOOL(NSURL *fileURL) { - id resourceValue = nil; - return ([fileURL getResourceValue:&resourceValue forKey:NSURLQuarantinePropertiesKey error:NULL] && resourceValue != nil); - } - quarantineRemoval:^BOOL(NSURL *fileURL, NSError *__autoreleasing *removalError) { - return [fileURL setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:removalError]; - } - isAccessError:^BOOL(NSError *removalError) { - return NS_HAS_PERMISSION_ERROR(removalError); - } - error:error]; -} // Ordinarily, the quarantine is managed by calling LSSetItemAttribute // to set the kLSItemQuarantineProperties attribute to a dictionary specifying @@ -301,19 +277,23 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // "com.apple.quarantine", on affected files. Removing this attribute is // sufficient to remove files from the quarantine. -- (BOOL)releaseItemUsingOldMethodFromQuarantineAtRootURL:(NSURL *)rootURL allowingAuthentication:(BOOL)allowsAuthentication error:(NSError *__autoreleasing *)error +// This works be removing the quarantine extended attribute for every file we come across. +// We used to have code similar to the method below that used -[NSURL getResourceValue:forKey:error:] and -[NSURL setResourceValue:forKey:error:] +// However, those methods *really suck* - you can't rely on the return value from getting the resource value and if you set the resource value +// when the key isn't present, errors are spewed out to the console +- (BOOL)_releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL allowingAuthentication:(BOOL)allowsAuthentication error:(NSError *__autoreleasing *)error { static const int removeXAttrOptions = XATTR_NOFOLLOW; return [self - releaseItemFromQuarantineAtRootURL:rootURL + _releaseItemFromQuarantineAtRootURL:rootURL allowingAuthentication:allowsAuthentication withQuarantineRetrieval:^BOOL(NSURL *fileURL) { - return ([self getXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:fileURL.path options:removeXAttrOptions] >= 0); + return ([self _getXAttr:SUAppleQuarantineIdentifier fromFile:fileURL.path options:removeXAttrOptions] >= 0); } quarantineRemoval:^BOOL(NSURL *fileURL, NSError * __autoreleasing *removalError) { - BOOL removedQuarantine = ([self removeXAttr:APPLE_QUARANTINE_IDENTIFIER fromFile:fileURL.path options:removeXAttrOptions] == 0); + BOOL removedQuarantine = ([self _removeXAttr:SUAppleQuarantineIdentifier fromFile:fileURL.path options:removeXAttrOptions] == 0); if (!removedQuarantine && removalError != NULL) { *removalError = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove file quarantine on %@.", fileURL.lastPathComponent] }]; } @@ -327,24 +307,24 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza - (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError * __autoreleasing *)error { - return [self releaseItemFromQuarantineAtRootURL:rootURL allowingAuthentication:YES error:error]; + return [self _releaseItemFromQuarantineAtRootURL:rootURL allowingAuthentication:YES error:error]; } - (BOOL)releaseItemFromQuarantineWithoutAuthenticationAtRootURL:(NSURL *)rootURL error:(NSError * __autoreleasing *)error { - return [self releaseItemFromQuarantineAtRootURL:rootURL allowingAuthentication:NO error:error]; + return [self _releaseItemFromQuarantineAtRootURL:rootURL allowingAuthentication:NO error:error]; } - (BOOL)moveItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError *__autoreleasing *)error { - if (![self itemExistsAtURL:sourceURL]) { + if (![self _itemExistsAtURL:sourceURL]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source file to move (%@) does not exist.", sourceURL.path.lastPathComponent] }]; } return NO; } - if ([self itemExistsAtURL:destinationURL]) { + if ([self _itemExistsAtURL:destinationURL]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination file to move (%@) already exists.", destinationURL.path.lastPathComponent] }]; } @@ -363,7 +343,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return NO; } - if (![self acquireAuthorizationWithError:error]) { + if (![self _acquireAuthorizationWithError:error]) { return NO; } @@ -394,16 +374,43 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return YES; } +- (BOOL)_changeOwnerAndGroupOfItemAtURL:(NSURL *)targetURL ownerID:(NSNumber *)ownerID groupID:(NSNumber *)groupID needsAuth:(BOOL *)needsAuth error:(NSError * __autoreleasing *)error +{ + char path[PATH_MAX] = {0}; + if (![targetURL.path getFileSystemRepresentation:path maxLength:sizeof(path)]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"File to change owner & group (%@) cannot be represented as a valid file name.", targetURL.path.lastPathComponent] }]; + } + return NO; + } + + if (chown(path, ownerID.unsignedIntValue, groupID.unsignedIntValue) != 0) { + 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; + } + } + + return YES; +} + - (BOOL)changeOwnerAndGroupOfItemAtRootURL:(NSURL *)targetURL toMatchURL:(NSURL *)matchURL error:(NSError * __autoreleasing *)error { - if (![self itemExistsAtURL:targetURL]) { + BOOL isTargetADirectory = NO; + if (![self _itemExistsAtURL:targetURL isDirectory:&isTargetADirectory]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to change owner & group IDs because %@ does not exist.", targetURL.path.lastPathComponent] }]; } return NO; } - if (![self itemExistsAtURL:matchURL]) { + if (![self _itemExistsAtURL:matchURL]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to match owner & group IDs because %@ does not exist.", matchURL.path.lastPathComponent] }]; } @@ -452,27 +459,22 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return YES; } - NSDirectoryEnumerator *directoryEnumerator = [_fileManager enumeratorAtURL:targetURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil]; BOOL needsAuth = NO; - for (NSURL *url in directoryEnumerator) { - 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 change owner & group (%@) cannot be represented as a valid file name.", url.path.lastPathComponent] }]; - } - return NO; - } - - if (chown(path, ownerID.unsignedIntValue, groupID.unsignedIntValue) != 0) { - if (errno == EPERM) { - needsAuth = YES; - break; - } 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.", url.path.lastPathComponent, ownerID.unsignedIntValue, groupID.unsignedIntValue] }]; - } + + if (![self _changeOwnerAndGroupOfItemAtURL:targetURL ownerID:ownerID groupID:groupID needsAuth:&needsAuth 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]) { return NO; } + + if (needsAuth) { + break; + } } } @@ -497,7 +499,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return NO; } - if (![self acquireAuthorizationWithError:error]) { + if (![self _acquireAuthorizationWithError:error]) { return NO; } @@ -512,9 +514,9 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // Creates a directory at the item pointed by url // An item cannot already exist at the url, but the parent must be a directory that exists -- (BOOL)makeDirectoryAtURL:(NSURL *)url error:(NSError * __autoreleasing *)error +- (BOOL)_makeDirectoryAtURL:(NSURL *)url error:(NSError * __autoreleasing *)error { - if ([self itemExistsAtURL:url]) { + if ([self _itemExistsAtURL:url]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create directory because file %@ already exists.", url.path.lastPathComponent] }]; } @@ -523,7 +525,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza NSURL *parentURL = [url URLByDeletingLastPathComponent]; BOOL isParentADirectory = NO; - if (![self itemExistsAtURL:parentURL isDirectory:&isParentADirectory] || !isParentADirectory) { + if (![self _itemExistsAtURL:parentURL isDirectory:&isParentADirectory] || !isParentADirectory) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create directory because parent directory %@ does not exist.", parentURL.path.lastPathComponent] }]; } @@ -550,7 +552,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return NO; } - if (![self acquireAuthorizationWithError:error]) { + if (![self _acquireAuthorizationWithError:error]) { return NO; } @@ -576,16 +578,16 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza NSURL *desiredURL = [directoryURL URLByAppendingPathComponent:preferredName]; NSUInteger tagIndex = 1; - while ([self itemExistsAtURL:desiredURL] && tagIndex <= 9999) { + while ([self _itemExistsAtURL:desiredURL] && tagIndex <= 9999) { desiredURL = [directoryURL URLByAppendingPathComponent:[preferredName stringByAppendingFormat:@" (%lu)", (unsigned long)++tagIndex]]; } - return [self makeDirectoryAtURL:desiredURL error:error] ? desiredURL : nil; + return [self _makeDirectoryAtURL:desiredURL error:error] ? desiredURL : nil; } - (BOOL)removeItemAtURL:(NSURL *)url error:(NSError * __autoreleasing *)error { - if (![self itemExistsAtURL:url]) { + if (![self _itemExistsAtURL:url]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove file %@ because it does not exist.", url.path.lastPathComponent] }]; } @@ -604,7 +606,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return NO; } - if (![self acquireAuthorizationWithError:error]) { + if (![self _acquireAuthorizationWithError:error]) { return NO; } @@ -625,7 +627,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza - (BOOL)moveItemAtURLToTrash:(NSURL *)url error:(NSError *__autoreleasing *)error { - if (![self itemExistsAtURL:url]) { + if (![self _itemExistsAtURL:url]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to move %@ to the trash because the file does not exist.", url.path.lastPathComponent] }]; } diff --git a/Tests/SUFileManagerTest.swift b/Tests/SUFileManagerTest.swift new file mode 100644 index 00000000..20722abe --- /dev/null +++ b/Tests/SUFileManagerTest.swift @@ -0,0 +1,229 @@ +// +// SUFileManagerTest.swift +// Sparkle +// +// Created by Mayur Pawashe on 9/26/15. +// Copyright © 2015 Sparkle Project. All rights reserved. +// + +import XCTest + +class SUFileManagerTest: XCTestCase +{ + func makeTempFiles(testBlock: (SUFileManager, NSURL, NSURL, NSURL, NSURL) -> Void) + { + let fileManager = SUFileManager() + + let tempDirectoryURL = try! fileManager.makeTemporaryDirectoryWithPreferredName("Sparkle Unit Test Data", appropriateForDirectoryURL: NSURL(fileURLWithPath: NSHomeDirectory())) + + defer { + try! fileManager.removeItemAtURL(tempDirectoryURL) + } + + let ordinaryFileURL = tempDirectoryURL.URLByAppendingPathComponent("a file written by sparkles unit tests") + try! "foo".dataUsingEncoding(NSUTF8StringEncoding)!.writeToURL(ordinaryFileURL, options: .DataWritingAtomic) + + let directoryURL = tempDirectoryURL.URLByAppendingPathComponent("a directory written by sparkles unit tests") + try! NSFileManager.defaultManager().createDirectoryAtURL(directoryURL, withIntermediateDirectories: false, attributes: nil) + + let fileInDirectoryURL = directoryURL.URLByAppendingPathComponent("a file inside a directory written by sparkles unit tests") + try! "bar baz".dataUsingEncoding(NSUTF8StringEncoding)!.writeToURL(fileInDirectoryURL, options: .DataWritingAtomic) + + testBlock(fileManager, tempDirectoryURL, ordinaryFileURL, directoryURL, fileInDirectoryURL) + } + + func testMoveFiles() + { + makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL in + XCTAssertNil(try? fileManager.moveItemAtURL(ordinaryFileURL, toURL: directoryURL)) + XCTAssertNil(try? fileManager.moveItemAtURL(rootURL.URLByAppendingPathComponent("does not exist"), toURL: directoryURL)) + + let newFileURL = (ordinaryFileURL.URLByDeletingLastPathComponent?.URLByAppendingPathComponent("new file"))! + try! fileManager.moveItemAtURL(ordinaryFileURL, toURL: newFileURL) + XCTAssertFalse(fileManager._itemExistsAtURL(ordinaryFileURL)) + XCTAssertTrue(fileManager._itemExistsAtURL(newFileURL)) + + let newDirectoryURL = (ordinaryFileURL.URLByDeletingLastPathComponent?.URLByAppendingPathComponent("new directory"))! + try! fileManager.moveItemAtURL(directoryURL, toURL: newDirectoryURL) + XCTAssertFalse(fileManager._itemExistsAtURL(directoryURL)) + XCTAssertTrue(fileManager._itemExistsAtURL(newDirectoryURL)) + XCTAssertFalse(fileManager._itemExistsAtURL(fileInDirectoryURL)) + XCTAssertTrue(fileManager._itemExistsAtURL(newDirectoryURL.URLByAppendingPathComponent(fileInDirectoryURL.lastPathComponent!))) + } + } + + func testMoveFilesToTrash() + { + makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL in + XCTAssertNil(try? fileManager.moveItemAtURLToTrash(rootURL.URLByAppendingPathComponent("does not exist"))) + + let trashURL = try! NSFileManager.defaultManager().URLForDirectory(.TrashDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: false) + + try! fileManager.moveItemAtURLToTrash(ordinaryFileURL) + XCTAssertFalse(fileManager._itemExistsAtURL(ordinaryFileURL)) + + let ordinaryFileTrashURL = trashURL.URLByAppendingPathComponent(ordinaryFileURL.lastPathComponent!) + XCTAssertTrue(fileManager._itemExistsAtURL(ordinaryFileTrashURL)) + try! fileManager.removeItemAtURL(ordinaryFileTrashURL) + + try! fileManager.moveItemAtURLToTrash(directoryURL) + XCTAssertFalse(fileManager._itemExistsAtURL(directoryURL)) + XCTAssertFalse(fileManager._itemExistsAtURL(fileInDirectoryURL)) + + let directoryTrashURL = trashURL.URLByAppendingPathComponent(directoryURL.lastPathComponent!) + XCTAssertTrue(fileManager._itemExistsAtURL(directoryTrashURL)) + XCTAssertTrue(fileManager._itemExistsAtURL(directoryTrashURL.URLByAppendingPathComponent(fileInDirectoryURL.lastPathComponent!))) + + try! fileManager.removeItemAtURL(directoryTrashURL) + } + } + + func testRemoveFiles() + { + makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL in + XCTAssertNil(try? fileManager.removeItemAtURL(rootURL.URLByAppendingPathComponent("does not exist"))) + + try! fileManager.removeItemAtURL(ordinaryFileURL) + XCTAssertFalse(fileManager._itemExistsAtURL(ordinaryFileURL)) + + try! fileManager.removeItemAtURL(directoryURL) + XCTAssertFalse(fileManager._itemExistsAtURL(directoryURL)) + XCTAssertFalse(fileManager._itemExistsAtURL(fileInDirectoryURL)) + } + } + + func testReleaseFilesFromQuarantine() + { + makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL in + try! fileManager.releaseItemFromQuarantineWithoutAuthenticationAtRootURL(ordinaryFileURL) + try! fileManager.releaseItemFromQuarantineWithoutAuthenticationAtRootURL(directoryURL) + + let quarantineData = "does not really matter what is here".cStringUsingEncoding(NSUTF8StringEncoding)! + let quarantineDataLength = Int(strlen(quarantineData)) + + XCTAssertEqual(0, setxattr(ordinaryFileURL.path!, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE)) + XCTAssertGreaterThan(getxattr(ordinaryFileURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0) + + try! fileManager.releaseItemFromQuarantineWithoutAuthenticationAtRootURL(ordinaryFileURL) + XCTAssertEqual(-1, getxattr(ordinaryFileURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW)) + + XCTAssertEqual(0, setxattr(directoryURL.path!, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE)) + XCTAssertGreaterThan(getxattr(directoryURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0) + + XCTAssertEqual(0, setxattr(fileInDirectoryURL.path!, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE)) + XCTAssertGreaterThan(getxattr(fileInDirectoryURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0) + + try! fileManager.releaseItemFromQuarantineWithoutAuthenticationAtRootURL(directoryURL) + + XCTAssertEqual(-1, getxattr(directoryURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW)) + XCTAssertEqual(-1, getxattr(fileInDirectoryURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW)) + } + } + + func groupIDAtPath(path: String) -> gid_t + { + let attributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(path) + let groupID = attributes[NSFileGroupOwnerAccountID] as! NSNumber + return groupID.unsignedIntValue + } + + // Only the super user can alter user IDs, so changing user IDs is not tested here + // Instead we try to change the group ID - we just have to be a member of that group + func testAlterFilesGroupID() + { + makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL in + XCTAssertNil(try? fileManager.changeOwnerAndGroupOfItemAtRootURL(ordinaryFileURL, toMatchURL: rootURL.URLByAppendingPathComponent("does not exist"))) + + XCTAssertNil(try? fileManager.changeOwnerAndGroupOfItemAtRootURL(rootURL.URLByAppendingPathComponent("does not exist"), toMatchURL: ordinaryFileURL)) + + let everyoneGroup = getgrnam("everyone") + let everyoneGroupID = everyoneGroup.memory.gr_gid + + let staffGroup = getgrnam("staff") + let staffGroupID = staffGroup.memory.gr_gid + + XCTAssertNotEqual(staffGroupID, everyoneGroupID) + + XCTAssertEqual(staffGroupID, self.groupIDAtPath(ordinaryFileURL.path!)) + XCTAssertEqual(staffGroupID, self.groupIDAtPath(directoryURL.path!)) + XCTAssertEqual(staffGroupID, self.groupIDAtPath(fileInDirectoryURL.path!)) + + try! fileManager.changeOwnerAndGroupOfItemAtRootURL(fileInDirectoryURL, toMatchURL: ordinaryFileURL) + try! fileManager.changeOwnerAndGroupOfItemAtRootURL(ordinaryFileURL, toMatchURL: ordinaryFileURL) + + XCTAssertEqual(staffGroupID, self.groupIDAtPath(ordinaryFileURL.path!)) + XCTAssertEqual(staffGroupID, self.groupIDAtPath(directoryURL.path!)) + + XCTAssertEqual(0, chown(ordinaryFileURL.path!, getuid(), everyoneGroupID)) + XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(ordinaryFileURL.path!)) + + try! fileManager.changeOwnerAndGroupOfItemAtRootURL(fileInDirectoryURL, toMatchURL: ordinaryFileURL) + XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(fileInDirectoryURL.path!)) + + try! fileManager.changeOwnerAndGroupOfItemAtRootURL(fileInDirectoryURL, toMatchURL: directoryURL) + XCTAssertEqual(staffGroupID, self.groupIDAtPath(fileInDirectoryURL.path!)) + + try! fileManager.changeOwnerAndGroupOfItemAtRootURL(directoryURL, toMatchURL: ordinaryFileURL) + XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(directoryURL.path!)) + XCTAssertEqual(everyoneGroupID, self.groupIDAtPath(fileInDirectoryURL.path!)) + } + } + + func testFileExists() + { + makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL in + XCTAssertTrue(fileManager._itemExistsAtURL(ordinaryFileURL)) + XCTAssertTrue(fileManager._itemExistsAtURL(directoryURL)) + XCTAssertFalse(fileManager._itemExistsAtURL(rootURL.URLByAppendingPathComponent("does not exist"))) + + var isOrdinaryFileDirectory: ObjCBool = false + XCTAssertTrue(fileManager._itemExistsAtURL(ordinaryFileURL, isDirectory: &isOrdinaryFileDirectory) && !isOrdinaryFileDirectory) + + var isDirectoryADirectory: ObjCBool = false + XCTAssertTrue(fileManager._itemExistsAtURL(directoryURL, isDirectory: &isDirectoryADirectory) && isDirectoryADirectory) + + XCTAssertFalse(fileManager._itemExistsAtURL(rootURL.URLByAppendingPathComponent("does not exist"), isDirectory: nil)) + + let validSymlinkURL = rootURL.URLByAppendingPathComponent("symlink test") + try! NSFileManager.defaultManager().createSymbolicLinkAtURL(validSymlinkURL, withDestinationURL: directoryURL) + + XCTAssertTrue(fileManager._itemExistsAtURL(validSymlinkURL)) + + var validSymlinkIsADirectory: ObjCBool = false + XCTAssertTrue(fileManager._itemExistsAtURL(validSymlinkURL, isDirectory: &validSymlinkIsADirectory) && !validSymlinkIsADirectory) + + let invalidSymlinkURL = rootURL.URLByAppendingPathComponent("symlink test 2") + try! NSFileManager.defaultManager().createSymbolicLinkAtURL(invalidSymlinkURL, withDestinationURL: rootURL.URLByAppendingPathComponent("does not exist")) + + // Symlink should still exist even if it doesn't point to a file that exists + XCTAssertTrue(fileManager._itemExistsAtURL(invalidSymlinkURL)) + + var invalidSymlinkIsADirectory: ObjCBool = false + XCTAssertTrue(fileManager._itemExistsAtURL(invalidSymlinkURL, isDirectory: &invalidSymlinkIsADirectory) && !invalidSymlinkIsADirectory) + } + } + + func testMakeDirectory() + { + makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL in + XCTAssertNil(try? fileManager._makeDirectoryAtURL(ordinaryFileURL)) + XCTAssertNil(try? fileManager._makeDirectoryAtURL(directoryURL)) + + XCTAssertNil(try? fileManager._makeDirectoryAtURL(rootURL.URLByAppendingPathComponent("this should").URLByAppendingPathComponent("be a failure"))) + + let newDirectoryURL = rootURL.URLByAppendingPathComponent("new test directory") + XCTAssertFalse(fileManager._itemExistsAtURL(newDirectoryURL)) + try! fileManager._makeDirectoryAtURL(newDirectoryURL) + + var isDirectory: ObjCBool = false + XCTAssertTrue(fileManager._itemExistsAtURL(newDirectoryURL, isDirectory: &isDirectory)) + } + } + + // This alone shouldn't prompt a password dialog and should always succeed + func testAcquireAuthorization() + { + let fileManager = SUFileManager() + try! fileManager._acquireAuthorization() + } +} diff --git a/Tests/Sparkle Unit Tests-Bridging-Header.h b/Tests/Sparkle Unit Tests-Bridging-Header.h index f5d76dcd..7f7cc44e 100644 --- a/Tests/Sparkle Unit Tests-Bridging-Header.h +++ b/Tests/Sparkle Unit Tests-Bridging-Header.h @@ -5,3 +5,17 @@ #import "SUUnarchiver.h" #import "SUPipedUnarchiver.h" #import "SUBinaryDeltaCommon.h" +#import "SUFileManager.h" + +extern NSString *SUAppleQuarantineIdentifier; + +@interface SUFileManager (Private) + +- (BOOL)_acquireAuthorizationWithError:(NSError *__autoreleasing *)error; + +- (BOOL)_itemExistsAtURL:(NSURL *)fileURL; +- (BOOL)_itemExistsAtURL:(NSURL *)fileURL isDirectory:(BOOL *)isDirectory; + +- (BOOL)_makeDirectoryAtURL:(NSURL *)url error:(NSError * __autoreleasing *)error; + +@end From 03655cf8b24fa2c3914999acf899e91f06485921 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 26 Sep 2015 15:11:23 -0400 Subject: [PATCH 22/87] Resolve nullability warnings --- Sparkle/SUFileManager.m | 33 +++++++++++++++++++++++++-------- Sparkle/SUPlainInstaller.m | 26 +++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 122c8b56..506b149f 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -95,12 +95,21 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza - (BOOL)_itemExistsAtURL:(NSURL *)fileURL { - return [_fileManager attributesOfItemAtPath:fileURL.path error:NULL] != nil; + NSString *path = fileURL.path; + if (path == nil) { + return NO; + } + return [_fileManager attributesOfItemAtPath:path error:NULL] != nil; } - (BOOL)_itemExistsAtURL:(NSURL *)fileURL isDirectory:(BOOL *)isDirectory { - NSDictionary *attributes = [_fileManager attributesOfItemAtPath:fileURL.path error:NULL]; + NSString *path = fileURL.path; + if (path == nil) { + return NO; + } + + NSDictionary *attributes = [_fileManager attributesOfItemAtPath:path error:NULL]; if (attributes == nil) { return NO; } @@ -240,7 +249,8 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // Only recurse if it's actually a directory. Don't recurse into a // root-level symbolic link. - NSDictionary *rootAttributes = [_fileManager attributesOfItemAtPath:rootURL.path error:nil]; + NSString *rootURLPath = rootURL.path; + NSDictionary *rootAttributes = [_fileManager attributesOfItemAtPath:rootURLPath error:nil]; NSString *rootType = rootAttributes[NSFileType]; if ([rootType isEqualToString:NSFileTypeDirectory]) { @@ -418,7 +428,8 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } NSError *matchFileAttributesError = nil; - NSDictionary *matchFileAttributes = [_fileManager attributesOfItemAtPath:matchURL.path error:&matchFileAttributesError]; + NSString *matchURLPath = matchURL.path; + NSDictionary *matchFileAttributes = [_fileManager attributesOfItemAtPath:matchURLPath error:&matchFileAttributesError]; if (matchFileAttributes == nil) { if (error != NULL) { *error = matchFileAttributesError; @@ -427,7 +438,8 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } NSError *targetFileAttributesError = nil; - NSDictionary *targetFileAttributes = [_fileManager attributesOfItemAtPath:targetURL.path error:&targetFileAttributesError]; + NSString *targetURLPath = targetURL.path; + NSDictionary *targetFileAttributes = [_fileManager attributesOfItemAtPath:targetURLPath error:&targetFileAttributesError]; if (targetFileAttributes == nil) { if (error != NULL) { *error = targetFileAttributesError; @@ -453,7 +465,10 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return NO; } - if ([ownerID isEqualToNumber:targetFileAttributes[NSFileOwnerAccountID]] && [groupID isEqualToNumber:targetFileAttributes[NSFileGroupOwnerAccountID]]) { + NSNumber *targetOwnerID = targetFileAttributes[NSFileOwnerAccountID]; + NSNumber *targetGroupID = targetFileAttributes[NSFileGroupOwnerAccountID]; + + if ((targetOwnerID != nil && [ownerID isEqualToNumber:targetOwnerID]) && (targetGroupID != nil && [groupID isEqualToNumber:targetGroupID])) { // Assume they're the same even if we don't check every file recursively // Speeds up the common case return YES; @@ -666,7 +681,8 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return NO; } - NSURL *tempItemURL = [tempDirectory URLByAppendingPathComponent:url.lastPathComponent]; + NSString *urlLastPathComponent = url.lastPathComponent; + NSURL *tempItemURL = [tempDirectory URLByAppendingPathComponent:urlLastPathComponent]; if (![self moveItemAtURL:url toURL:tempItemURL error:error]) { // If we can't move the item at url, just remove it completely; chances are it's not going to be missed [self removeItemAtURL:url error:NULL]; @@ -685,7 +701,8 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza BOOL success = NO; #if __MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8 if (!canUseNewTrashAPI) { - success = [[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:tempItemURL.URLByDeletingLastPathComponent.path destination:@"" files:@[tempItemURL.lastPathComponent] tag:NULL]; + NSString *tempParentPath = tempItemURL.URLByDeletingLastPathComponent.path; + success = [[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:tempParentPath destination:@"" files:@[tempItemURL.lastPathComponent] tag:NULL]; if (!success && error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to move file %@ into the trash.", tempItemURL.lastPathComponent] }]; } diff --git a/Sparkle/SUPlainInstaller.m b/Sparkle/SUPlainInstaller.m index b70be520..6a9e9307 100644 --- a/Sparkle/SUPlainInstaller.m +++ b/Sparkle/SUPlainInstaller.m @@ -18,7 +18,7 @@ // Returns the bundle version from the specified host that is appropriate to use as a filename, or nil if we're unable to retrieve one + (NSString *)bundleVersionAppropriateForFilenameFromHost:(SUHost *)host { - NSString *bundleVersion = [host objectForInfoDictionaryKey:(NSString *)kCFBundleVersionKey]; + NSString *bundleVersion = [host objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]; NSString *trimmedVersion = @""; if (bundleVersion != nil) { @@ -33,6 +33,15 @@ + (BOOL)performInstallationToURL:(NSURL *)installationURL fromUpdateAtURL:(NSURL *)newURL withHost:(SUHost *)host error:(NSError * __autoreleasing *)error { + if (installationURL == nil || newURL == nil) { + // this really shouldn't happen but just in case + SULog(@"Failed to perform installation because either installation URL (%@) or new URL (%@) is nil", installationURL, newURL); + if (error != NULL) { + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to perform installation because the paths to install at and from are not valid" }]; + } + return NO; + } + SUFileManager *fileManager = [[SUFileManager alloc] init]; // Create a temporary directory for our new app that resides on our destination's volume @@ -43,7 +52,8 @@ } // Move the new app to our temporary directory - NSURL *newTempURL = [tempNewDirectoryURL URLByAppendingPathComponent:newURL.lastPathComponent]; + NSString *newURLLastPathComponent = newURL.lastPathComponent; + NSURL *newTempURL = [tempNewDirectoryURL URLByAppendingPathComponent:newURLLastPathComponent]; if (![fileManager moveItemAtURL:newURL toURL:newTempURL error:error]) { SULog(@"Failed to move the new app from %@ to its temp directory at %@", newURL.path, newTempURL.path); [fileManager removeItemAtURL:tempNewDirectoryURL error:NULL]; @@ -61,6 +71,15 @@ } NSURL *oldURL = [NSURL fileURLWithPath:host.bundlePath]; + if (oldURL == nil) { + // this really shouldn't happen but just in case + SULog(@"Failed to construct URL from bundle path: %@", host.bundlePath); + if (error != NULL) { + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey: @"Failed to perform installation because a path could not be constructed for the old installation" }]; + } + return NO; + } + if (![fileManager changeOwnerAndGroupOfItemAtRootURL:newTempURL toMatchURL:oldURL error:error]) { // But this is big enough of a deal to fail SULog(@"Failed to change owner and group of new app at %@ to match old app at %@", newTempURL.path, oldURL.path); @@ -78,7 +97,8 @@ oldDestinationName = oldURL.lastPathComponent.stringByDeletingPathExtension; } - NSString *oldDestinationNameWithPathExtension = [oldDestinationName stringByAppendingPathExtension:oldURL.pathExtension]; + NSString *oldURLExtension = oldURL.pathExtension; + NSString *oldDestinationNameWithPathExtension = [oldDestinationName stringByAppendingPathExtension:oldURLExtension]; // Create a temporary directory for our old app that resides on its volume NSURL *tempOldDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:oldDestinationName appropriateForDirectoryURL:oldURL.URLByDeletingLastPathComponent error:error]; From 9822b4d2a13f3bf7d33be624c3bb1b66fca56a37 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 26 Sep 2015 15:21:33 -0400 Subject: [PATCH 23/87] Fix typo --- Sparkle/SUFileManager.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 506b149f..cbf74c82 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -287,7 +287,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // "com.apple.quarantine", on affected files. Removing this attribute is // sufficient to remove files from the quarantine. -// This works be removing the quarantine extended attribute for every file we come across. +// This works by removing the quarantine extended attribute for every file we come across. // We used to have code similar to the method below that used -[NSURL getResourceValue:forKey:error:] and -[NSURL setResourceValue:forKey:error:] // However, those methods *really suck* - you can't rely on the return value from getting the resource value and if you set the resource value // when the key isn't present, errors are spewed out to the console From 6079739534895659dda4d9391ed85e62ef7bf252 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 26 Sep 2015 20:56:44 -0400 Subject: [PATCH 24/87] Disallow automatic updates when user can't write to the bundle The automatic updates checkbox is also hidden in this scenario, and we also update the layout constraints if the releasenotes are still visible --- Sparkle/SUHost.h | 1 + Sparkle/SUHost.m | 11 +++++++++++ Sparkle/SUUpdateAlert.m | 16 +++++++++++----- Sparkle/SUUpdater.m | 4 ++-- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/Sparkle/SUHost.h b/Sparkle/SUHost.h index 3bf0a8e5..732eae28 100644 --- a/Sparkle/SUHost.h +++ b/Sparkle/SUHost.h @@ -28,6 +28,7 @@ typedef struct { - (instancetype)initWithBundle:(NSBundle *)aBundle; @property (readonly, copy) NSString *bundlePath; +@property (readonly) BOOL allowsAutomaticUpdates; @property (readonly, copy) NSString *appCachePath; @property (readonly, copy) NSString *installationPath; @property (readonly, copy) NSString *name; diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index 6f9e7da1..549a7bbe 100644 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -62,6 +62,17 @@ return [self.bundle bundlePath]; } +- (BOOL)allowsAutomaticUpdates +{ + // Can we automatically update in the background without bugging the user (e.g, with a administrator password prompt)? + BOOL isWritableAtBundle = [[NSFileManager defaultManager] isWritableFileAtPath:self.bundlePath]; + + // Does the developer want us to disable automatic updates? + NSNumber *developerAllowsAutomaticUpdates = [self objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey]; + + return isWritableAtBundle && (developerAllowsAutomaticUpdates == nil || developerAllowsAutomaticUpdates.boolValue); +} + - (NSString *)appCachePath { NSArray *cachePaths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); diff --git a/Sparkle/SUUpdateAlert.m b/Sparkle/SUUpdateAlert.m index 1ab5eed2..42565b00 100644 --- a/Sparkle/SUUpdateAlert.m +++ b/Sparkle/SUUpdateAlert.m @@ -171,11 +171,7 @@ - (BOOL)allowsAutomaticUpdates { - BOOL allowAutoUpdates = YES; // Defaults to YES. - if ([self.host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey]) - allowAutoUpdates = [self.host boolForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey]; - - return allowAutoUpdates; + return self.host.allowsAutomaticUpdates; } - (void)windowDidLoad @@ -202,6 +198,16 @@ [self.releaseNotesContainerView removeFromSuperview]; } + + // When we show release notes, it looks ugly if the install buttons are not closer to the release notes view + // However when we don't show release notes, it looks ugly if the install buttons are too close to the description field. Shrugs. + if (showReleaseNotes && ![self allowsAutomaticUpdates]) { + NSLayoutConstraint *skipButtonToReleaseNotesContainerConstraint = [NSLayoutConstraint constraintWithItem:self.skipButton attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.releaseNotesContainerView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:12.0]; + + [self.window.contentView addConstraint:skipButtonToReleaseNotesContainerConstraint]; + + [self.automaticallyInstallUpdatesButton removeFromSuperview]; + } [self.window center]; } diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index 73ebafea..7a824f3c 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -435,8 +435,8 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults - (BOOL)automaticallyDownloadsUpdates { - // If the SUAllowsAutomaticUpdatesKey exists and is set to NO, return NO. - if ([self.host objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] && [self.host boolForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey] == NO) { + // If the host doesn't allow automatic updates, don't ever let them happen + if (!self.host.allowsAutomaticUpdates) { return NO; } From a7ff41b3ceabead3697351840f1b4c2b21ae7fa3 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 26 Sep 2015 21:10:09 -0400 Subject: [PATCH 25/87] If the developer disables automatic updating, don't check writability --- Sparkle/SUHost.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index 549a7bbe..6ce40fbb 100644 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -64,13 +64,14 @@ - (BOOL)allowsAutomaticUpdates { - // Can we automatically update in the background without bugging the user (e.g, with a administrator password prompt)? - BOOL isWritableAtBundle = [[NSFileManager defaultManager] isWritableFileAtPath:self.bundlePath]; - // Does the developer want us to disable automatic updates? NSNumber *developerAllowsAutomaticUpdates = [self objectForInfoDictionaryKey:SUAllowsAutomaticUpdatesKey]; + if (developerAllowsAutomaticUpdates != nil && !developerAllowsAutomaticUpdates.boolValue) { + return NO; + } - return isWritableAtBundle && (developerAllowsAutomaticUpdates == nil || developerAllowsAutomaticUpdates.boolValue); + // Can we automatically update in the background without bugging the user (e.g, with a administrator password prompt)? + return [[NSFileManager defaultManager] isWritableFileAtPath:self.bundlePath]; } - (NSString *)appCachePath From cc354cf8cfd72f4d0884385dd37c32d1875219ca Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 26 Sep 2015 23:37:18 -0400 Subject: [PATCH 26/87] Fix releasenotes container not being right-aligned with its box This fixes an issue where the vertical border of the release notes view would sometimes not be visible. Instead of making the widths of the views equal, we use the trailing property. This is consistent with leading and bottom being used elsewhere --- Sparkle/en.lproj/SUUpdateAlert.xib | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Sparkle/en.lproj/SUUpdateAlert.xib b/Sparkle/en.lproj/SUUpdateAlert.xib index 1451769a..65f653e2 100644 --- a/Sparkle/en.lproj/SUUpdateAlert.xib +++ b/Sparkle/en.lproj/SUUpdateAlert.xib @@ -1,10 +1,10 @@ - + - - + + @@ -26,8 +26,8 @@ - - + + @@ -118,7 +118,7 @@ - + @@ -138,7 +138,7 @@ - + @@ -239,7 +239,7 @@ DQ - + From 6af2fbfb6ef635daf30eac34fb61736a0a1f14c1 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 27 Sep 2015 10:53:22 -0400 Subject: [PATCH 27/87] Update modification & access time for new update If we don't do this, Finder may not report the correct file size for the new update. The system also may not register the new app in its database if we don't do this. We may have been able to get away with not doing this before because we used to perform a copy to install the update. However, now updates in some cases can be done with only move operations. This should also be an alternative way of addressing issue #508 --- Sparkle/SUFileManager.h | 13 ++++++++++ Sparkle/SUFileManager.m | 48 +++++++++++++++++++++++++++++++++++ Sparkle/SUPlainInstaller.m | 7 ++++- Tests/SUFileManagerTest.swift | 21 +++++++++++++++ 4 files changed, 88 insertions(+), 1 deletion(-) diff --git a/Sparkle/SUFileManager.h b/Sparkle/SUFileManager.h index f5cba54a..1a362808 100644 --- a/Sparkle/SUFileManager.h +++ b/Sparkle/SUFileManager.h @@ -79,6 +79,19 @@ */ - (BOOL)changeOwnerAndGroupOfItemAtRootURL:(NSURL *)targetURL toMatchURL:(NSURL *)matchURL error:(NSError **)error; +/** + * Updates the modification and access time of an item at a specified target URL to the current time + * @param targetURL A URL pointing to the target item whose modification and access time to update. The item at this URL must exist. + * @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. + * @return YES if the target item's modification and access times have been updated, otherwise NO along with a populated error object + * + * This method updates the modification and access time of an item to the current time, ideal for letting the system know we installed a new file or + * application. + * + * This is not an atomic operation. + */ +- (BOOL)updateModificationAndAccessTimeOfItemAtURL:(NSURL *)targetURL error:(NSError **)error; + /** * Releases Apple's quarantine extended attribute from the item at the specified root URL * @param rootURL A URL pointing to the item to release from Apple's quarantine. This will be applied recursively if the item is a directory. The item at this URL must exist. diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index cbf74c82..f2739f40 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -10,6 +10,7 @@ #include #include +#include #pragma clang diagnostic push // This is a private constant but it's referenced from our unit tests @@ -527,6 +528,53 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return success; } +// /usr/bin/touch can be used to update an application, as described in: +// https://developer.apple.com/library/mac/documentation/Carbon/Conceptual/LaunchServicesConcepts/LSCConcepts/LSCConcepts.html +// 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 +- (BOOL)updateModificationAndAccessTimeOfItemAtURL:(NSURL *)targetURL error:(NSError * __autoreleasing *)error +{ + if (![self _itemExistsAtURL:targetURL]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to update modification & access time because %@ does not exist.", targetURL.path.lastPathComponent] }]; + } + return NO; + } + + char path[PATH_MAX] = {0}; + if (![targetURL.path getFileSystemRepresentation:path maxLength:sizeof(path)]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"File to update modification & access time (%@) cannot be represented as a valid file name.", targetURL.path.lastPathComponent] }]; + } + return NO; + } + + if (utimes(path, NULL) == 0) { + return YES; + } + + if (errno != EACCES) { + 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; + } + + if (![self _acquireAuthorizationWithError:error]) { + return NO; + } + + BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, "/usr/bin/touch", kAuthorizationFlagDefaults, (char *[]){ path, NULL }); + if (!success && error != NULL) { + NSString *errorMessage = [NSString stringWithFormat:@"Failed to update modification & access time on %@ with authentication.", targetURL.path.lastPathComponent]; + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }]; + } + + return success; +} + // Creates a directory at the item pointed by url // An item cannot already exist at the url, but the parent must be a directory that exists - (BOOL)_makeDirectoryAtURL:(NSURL *)url error:(NSError * __autoreleasing *)error diff --git a/Sparkle/SUPlainInstaller.m b/Sparkle/SUPlainInstaller.m index 6a9e9307..a8a90a1f 100644 --- a/Sparkle/SUPlainInstaller.m +++ b/Sparkle/SUPlainInstaller.m @@ -60,7 +60,7 @@ return NO; } - // Release our new app from quarantine and fix its owner and group IDs while it's at our temporary destination + // Release our new app from quarantine, fix its owner and group IDs, and update its modification time while it's at our temporary destination // We must leave moving the app to its destination as the final step in installing it, so that // it's not possible our new app can be left in an incomplete state at the final destination @@ -87,6 +87,11 @@ return NO; } + if (![fileManager updateModificationAndAccessTimeOfItemAtURL:newTempURL error:error]) { + // Not a fatal error, but a pretty unfortunate one + SULog(@"Failed to update modification and access time of new app at %@", newTempURL.path); + } + // Decide on a destination name we should use for the older app when we move it around the file system NSString *oldDestinationName = nil; if (SPARKLE_APPEND_VERSION_NUMBER) { diff --git a/Tests/SUFileManagerTest.swift b/Tests/SUFileManagerTest.swift index 20722abe..76e66882 100644 --- a/Tests/SUFileManagerTest.swift +++ b/Tests/SUFileManagerTest.swift @@ -169,6 +169,27 @@ class SUFileManagerTest: XCTestCase } } + func testUpdateFileModificationTime() + { + makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL in + XCTAssertNil(try? fileManager.updateModificationAndAccessTimeOfItemAtURL(rootURL.URLByAppendingPathComponent("does not exist"))) + + let oldOrdinaryFileAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(ordinaryFileURL.path!) + let oldDirectoryAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(directoryURL.path!) + + sleep(1); // wait for clock to advance + + try! fileManager.updateModificationAndAccessTimeOfItemAtURL(ordinaryFileURL) + try! fileManager.updateModificationAndAccessTimeOfItemAtURL(directoryURL) + + let newOrdinaryFileAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(ordinaryFileURL.path!) + XCTAssertGreaterThan((newOrdinaryFileAttributes[NSFileModificationDate] as! NSDate).timeIntervalSinceDate(oldOrdinaryFileAttributes[NSFileModificationDate] as! NSDate), 0) + + let newDirectoryAttributes = try! NSFileManager.defaultManager().attributesOfItemAtPath(directoryURL.path!) + XCTAssertGreaterThan((newDirectoryAttributes[NSFileModificationDate] as! NSDate).timeIntervalSinceDate(oldDirectoryAttributes[NSFileModificationDate] as! NSDate), 0) + } + } + func testFileExists() { makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL in From 2bc0b2a2b39439f6c7f47846194d6090e20e5f0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Sun, 27 Sep 2015 15:51:10 +0100 Subject: [PATCH 28/87] Updated changelog --- CHANGELOG | 52 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index d84ebd49..d86f1615 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,25 +1,43 @@ + +# 1.12.0 + +* Rewrote file operations for updating an app (Zorg) + - Ensuring atomic move operations, robust error handling. + - Faster. + - Using modern APIs where possible (no FSPathMakeRef, FSGetCatalogInfo, FSFindFolder, etc.) + - Strong documentation, easier to read code. +* Deprecated serving over http without DSA (Zorg) +* Disallowed automatic updates when user can't write to the bundle (Zorg) +* Improved Autoupdate application (Zorg) + * Do all the installation work after the runloop is set up + * TerminationListener only does termination listening now + * Handle cases where host path is not installation path and host path is not desired executable path +* Removed extensions from shell scripts (Jake Petroules) +* Rewritten test app so it works again, and from a local web server (Zorg) +* Set LD_RUNPATH_SEARCH_PATHS in Podspec. (Jake Petroules) +* Don't install automatic updates if the system might shut off (Zorg) +* Don't show Autoupdate dock icon if we shouldn't show UI (Zorg) +* Updated layout constraints when removing release notes (Zorg) +* Improved BinaryDelta error handling & logging (Zorg) +* Refactored quarantine removal (Zorg) +* Fixed German localization (1024jp) +* Updated zh_CN translation (LIU Dongyuan / 柳东原) +* Updated Mac models list until July 2015 (Gabriel Ulici) +* Updated Polish translation (Kornel Lesiński) +* Updated Xcode project languages for which we have translations (Jake Petroules) +* Use NSByteCountFormatter if available (Jake Petroules) +* Declared protocols on SUUpdateAlert for the 10.11 SDK (Daniel Jalkut) +* Silenced warning about casting away const-ness and -Wassign-enum (Daniel Jalkut) +* Added script to generate a report comparing the Sparkle.strings files (Kevin Wojniak) +* Check for empty strings (as well as nil) in SUHost's -name method (Karl Moskowski) +* Don't follow symlinks for checking file existence (Zorg) +* Unit tests in Swift (Zorg, Jake Petroules) + # 1.11.0 * Big improvements to code signing and DSA verification - Sparkle now checks not only whether an update is correctly signed, but also whether the updated version will be able to verify future updates. Updates now must either use DSA keys correctly, or not try to use them at all. Same goes for Apple Code Signing. - Rely on code signing and the DSA key in the new app instead of appcast. If the new app has a public DSA key, then the appcast item must have a DSA signature for the app, even if the app is code signed. (Zorg) -* Deprecated serving over http without DSA (Zorg) -* Removed extensions from shell scripts (Jake Petroules) -* Improved Autoupdate application (Zorg) - * Do all the installation work after the runloop is set up - * TerminationListener only does termination listening now - * Handle cases where host path is not installation path and host path is not desired executable path -* Set LD_RUNPATH_SEARCH_PATHS in Podspec. (Jake Petroules) -* Updated layout constraints when removing release notes (Zorg) -* Fix German localization (1024jp) -* Updated zh_CN translation (LIU Dongyuan / 柳东原) -* Updated Mac models list until July 2015 (Gabriel Ulici) -* Updated Xcode project languages for which we have translations (Jake Petroules) -* Use NSByteCountFormatter if available (Jake Petroules) -* Declared protocols on SUUpdateAlert for the 10.11 SDK (Daniel Jalkut) -* Silenced warning about casting away const-ness and -Wassign-enum (Daniel Jalkut) -* Rewritten test app so it works again, and from a local web server (Zorg) -* Added script to generate a report comparing the Sparkle.strings files (Kevin Wojniak) * More verbose error message when DSA keys don't match (Kornel Lesiński) * Added delegate methods for pre-download and immediately post-failed-download (Isaac Greenspan) * Fix Lucida Grande is always used for release notes (LIU Dongyuan / 柳东原) From 6d833143fefe2202f7d4fb6c467b85eab26756ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Sun, 27 Sep 2015 16:09:33 +0100 Subject: [PATCH 29/87] Xcode 7.1 config upgrade marker --- Sparkle.xcodeproj/project.pbxproj | 72 +++++++++---------- .../xcschemes/Distribution.xcscheme | 2 +- .../xcshareddata/xcschemes/Sparkle.xcscheme | 2 +- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 25b05069..189859cb 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -162,7 +162,7 @@ 61F83F720DBFE140006FDD30 /* SUBasicUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */; }; 61F83F740DBFE141006FDD30 /* SUBasicUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61F83F6F0DBFE137006FDD30 /* SUBasicUpdateDriver.h */; settings = {ATTRIBUTES = (); }; }; 61FA52880E2D9EA400EF58AD /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* Sparkle.framework */; settings = {ATTRIBUTES = (Required, ); }; }; - 7210C7681B9A9A1500EB90AC /* SUUnarchiverTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */; settings = {ASSET_TAGS = (); }; }; + 7210C7681B9A9A1500EB90AC /* SUUnarchiverTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */; }; 721CF1A71AD7643600D9AC09 /* bsdiff.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */; settings = {COMPILER_FLAGS = "-w"; }; }; 721CF1A81AD7644100D9AC09 /* bspatch.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */; settings = {COMPILER_FLAGS = "-w"; }; }; 721CF1A91AD7644C00D9AC09 /* sais.c in Sources */ = {isa = PBXBuildFile; fileRef = 7223E7611AD1AEFF008E3161 /* sais.c */; settings = {COMPILER_FLAGS = "-w"; }; }; @@ -173,13 +173,13 @@ 7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */; }; 7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; 7275F9C31B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; - 72A4A2401BB6567D00E7820D /* SUFileManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72A4A23F1BB6567D00E7820D /* SUFileManagerTest.swift */; settings = {ASSET_TAGS = (); }; }; + 72A4A2401BB6567D00E7820D /* SUFileManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72A4A23F1BB6567D00E7820D /* SUFileManagerTest.swift */; }; 72A4A2411BB656FA00E7820D /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; - 72AC6B261B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B251B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz */; settings = {ASSET_TAGS = (); }; }; - 72AC6B281B9AAD6700F62325 /* SparkleTestCodeSignApp.tar in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B271B9AAD6700F62325 /* SparkleTestCodeSignApp.tar */; settings = {ASSET_TAGS = (); }; }; - 72AC6B2A1B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B291B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 */; settings = {ASSET_TAGS = (); }; }; - 72AC6B2C1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B2B1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz */; settings = {ASSET_TAGS = (); }; }; - 72AC6B2E1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B2D1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg */; settings = {ASSET_TAGS = (); }; }; + 72AC6B261B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B251B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz */; }; + 72AC6B281B9AAD6700F62325 /* SparkleTestCodeSignApp.tar in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B271B9AAD6700F62325 /* SparkleTestCodeSignApp.tar */; }; + 72AC6B2A1B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B291B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 */; }; + 72AC6B2C1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B2B1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz */; }; + 72AC6B2E1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg in Resources */ = {isa = PBXBuildFile; fileRef = 72AC6B2D1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg */; }; 72D4DAA11AD7632900B211E2 /* SUBinaryDeltaCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */; }; 72E45CF31B640CDD005C701A /* SUTestApplicationDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 72E45CF21B640CDD005C701A /* SUTestApplicationDelegate.m */; }; 72E45CF71B640DAE005C701A /* SUUpdateSettingsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 72E45CF51B640DAE005C701A /* SUUpdateSettingsWindowController.m */; }; @@ -782,10 +782,10 @@ isa = PBXGroup; children = ( 14732BC21960F3FF00593899 /* bin */, - 147D6D9E1B66DC3C006607AB /* CheckLocalizations.swift */, 14732BBA1960EF7100593899 /* CHANGELOG */, 61C268090E2DB5D000175E6C /* LICENSE */, 14732BC11960F3B200593899 /* Makefile */, + 147D6D9E1B66DC3C006607AB /* CheckLocalizations.swift */, 1420DF4F196247F900203BB0 /* Images.xcassets */, 14732BBC1960EFB500593899 /* README.markdown */, 14732BB91960EEEE00593899 /* SampleAppcast.xml */, @@ -822,12 +822,12 @@ isa = PBXGroup; children = ( 14958C6B19AEBC530061B14F /* signed-test-file.txt */, - F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */, - 72AC6B271B9AAD6700F62325 /* SparkleTestCodeSignApp.tar */, - 72AC6B251B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz */, - 72AC6B291B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 */, - 72AC6B2B1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz */, 72AC6B2D1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg */, + 72AC6B271B9AAD6700F62325 /* SparkleTestCodeSignApp.tar */, + 72AC6B291B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 */, + 72AC6B251B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz */, + 72AC6B2B1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz */, + F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */, 14958C6C19AEBC610061B14F /* test-pubkey.pem */, 5AF6C74E1AEA46D10014A3AB /* test.sparkle_guided.pkg */, ); @@ -878,16 +878,16 @@ isa = PBXGroup; children = ( 14958C7019AEBE350061B14F /* Resources */, + 72AFC6121B9A944200F6B565 /* Sparkle Unit Tests-Bridging-Header.h */, 612279DA0DB5470200AB99EA /* SparkleTests-Info.plist */, 142E0E0819A83AAC00E4312B /* SUBinaryDeltaTest.m */, F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */, 5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */, + 72A4A23F1BB6567D00E7820D /* SUFileManagerTest.swift */, 5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */, + 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */, 14950074195FDF5900BC5B5B /* SUUpdaterTest.m */, 61227A150DB548B800AB99EA /* SUVersionComparisonTest.m */, - 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */, - 72A4A23F1BB6567D00E7820D /* SUFileManagerTest.swift */, - 72AFC6121B9A944200F6B565 /* Sparkle Unit Tests-Bridging-Header.h */, ); path = Tests; sourceTree = ""; @@ -929,6 +929,8 @@ 618FA6DB0DB485440026945C /* Installation */ = { isa = PBXGroup; children = ( + 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */, + 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */, 767B61AA1972D488004E0C3C /* SUGuidedPackageInstaller.h */, 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */, 618FA4FF0DAE88B40026945C /* SUInstaller.h */, @@ -937,8 +939,6 @@ 618FA5210DAE8E8A0026945C /* SUPackageInstaller.m */, 618FA5030DAE8AB80026945C /* SUPlainInstaller.h */, 618FA5040DAE8AB80026945C /* SUPlainInstaller.m */, - 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */, - 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */, ); name = Installation; sourceTree = ""; @@ -967,13 +967,13 @@ 72E45DDC1B65C3BD005C701A /* sign_update */, 61B5F92A09C4CFD800B25A18 /* InfoPlist.strings */, 61B5F92409C4CFC900B25A18 /* main.m */, + 61B5F92C09C4CFD800B25A18 /* MainMenu.xib */, + 72E45CFB1B641961005C701A /* sparkletestcast.xml */, 72E45CF11B640CDD005C701A /* SUTestApplicationDelegate.h */, 72E45CF21B640CDD005C701A /* SUTestApplicationDelegate.m */, 72E45CF41B640DAE005C701A /* SUUpdateSettingsWindowController.h */, 72E45CF51B640DAE005C701A /* SUUpdateSettingsWindowController.m */, 72E45CF61B640DAE005C701A /* SUUpdateSettingsWindowController.xib */, - 61B5F92C09C4CFD800B25A18 /* MainMenu.xib */, - 72E45CFB1B641961005C701A /* sparkletestcast.xml */, 72E45CFD1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem */, 14732BBF1960F0AC00593899 /* test_app_only_dsa_pub.pem */, 61B5F90409C4CEE200B25A18 /* TestApplication-Info.plist */, @@ -1080,10 +1080,10 @@ 61299A2F09CA2DAB00B7442F /* SUDSAVerifier.h in Headers */, 55E6F33319EC9F6C00005E76 /* SUErrors.h in Headers */, 14652F8419A978C200959E44 /* SUExport.h in Headers */, + 7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */, 767B61AC1972D488004E0C3C /* SUGuidedPackageInstaller.h in Headers */, 61EF67590E25C5B400F754E0 /* SUHost.h in Headers */, 618FA5010DAE88B40026945C /* SUInstaller.h in Headers */, - 7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */, 55C14F06136EF6DB00649790 /* SULog.h in Headers */, 618FA5220DAE8E8A0026945C /* SUPackageInstaller.h in Headers */, 6102FE460E077FCE00F85D09 /* SUPipedUnarchiver.h in Headers */, @@ -1251,7 +1251,7 @@ attributes = { CLASSPREFIX = SU; LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0710; ORGANIZATIONNAME = "Sparkle Project"; TargetAttributes = { 612279D80DB5470200AB99EA = { @@ -1329,13 +1329,13 @@ buildActionMask = 2147483647; files = ( 14958C6E19AEBC950061B14F /* signed-test-file.txt in Resources */, - F8761EB31ADC50EB000C9034 /* SparkleTestCodeSignApp.zip in Resources */, - 72AC6B2C1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz in Resources */, - 72AC6B261B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz in Resources */, 72AC6B2E1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg in Resources */, - 14958C6F19AEBC980061B14F /* test-pubkey.pem in Resources */, 72AC6B281B9AAD6700F62325 /* SparkleTestCodeSignApp.tar in Resources */, 72AC6B2A1B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 in Resources */, + 72AC6B261B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz in Resources */, + 72AC6B2C1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz in Resources */, + F8761EB31ADC50EB000C9034 /* SparkleTestCodeSignApp.zip in Resources */, + 14958C6F19AEBC980061B14F /* test-pubkey.pem in Resources */, 5AF6C74F1AEA46D10014A3AB /* test.sparkle_guided.pkg in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1357,11 +1357,11 @@ 1420DF50196247F900203BB0 /* Images.xcassets in Resources */, 61B5F92E09C4CFD800B25A18 /* InfoPlist.strings in Resources */, 61B5F92F09C4CFD800B25A18 /* MainMenu.xib in Resources */, - 72E45CFC1B641961005C701A /* sparkletestcast.xml in Resources */, - 14732BC01960F2C200593899 /* test_app_only_dsa_pub.pem in Resources */, - 72E45CF81B640DAE005C701A /* SUUpdateSettingsWindowController.xib in Resources */, 72E45DDD1B65C3BD005C701A /* sign_update in Resources */, + 72E45CFC1B641961005C701A /* sparkletestcast.xml in Resources */, + 72E45CF81B640DAE005C701A /* SUUpdateSettingsWindowController.xib in Resources */, 72E45CFE1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem in Resources */, + 14732BC01960F2C200593899 /* test_app_only_dsa_pub.pem in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1487,18 +1487,18 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 72A4A2411BB656FA00E7820D /* SUFileManager.m in Sources */, 721CF1A71AD7643600D9AC09 /* bsdiff.c in Sources */, 721CF1A81AD7644100D9AC09 /* bspatch.c in Sources */, 721CF1A91AD7644C00D9AC09 /* sais.c in Sources */, 72D4DAA11AD7632900B211E2 /* SUBinaryDeltaCreate.m in Sources */, 142E0E0919A83AAC00E4312B /* SUBinaryDeltaTest.m in Sources */, F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */, - 7210C7681B9A9A1500EB90AC /* SUUnarchiverTest.swift in Sources */, 5AF9DC3C1981DBEE001EA135 /* SUDSAVerifierTest.m in Sources */, + 72A4A2411BB656FA00E7820D /* SUFileManager.m in Sources */, + 72A4A2401BB6567D00E7820D /* SUFileManagerTest.swift in Sources */, 5AF6C7541AEA49840014A3AB /* SUInstallerTest.m in Sources */, 14652F8219A9746000959E44 /* SULog.m in Sources */, - 72A4A2401BB6567D00E7820D /* SUFileManagerTest.swift in Sources */, + 7210C7681B9A9A1500EB90AC /* SUUnarchiverTest.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -1530,6 +1530,7 @@ 61299A6009CA6EB100B7442F /* SUConstants.m in Sources */, 6102FE4B0E07803800F85D09 /* SUDiskImageUnarchiver.m in Sources */, 61299A3009CA2DAB00B7442F /* SUDSAVerifier.m in Sources */, + 7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */, 767B61AD1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */, 61EF67560E25B58D00F754E0 /* SUHost.m in Sources */, 618FA5020DAE88B40026945C /* SUInstaller.m in Sources */, @@ -1540,7 +1541,6 @@ 6101347C0DD2541A0049ACDF /* SUProbingUpdateDriver.m in Sources */, 61B93C0A0DD112FF00DCD2F8 /* SUScheduledUpdateDriver.m in Sources */, 61A225A50D1C4AC000430CCD /* SUStandardVersionComparator.m in Sources */, - 7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */, 6196CFFA09C72149000DC222 /* SUStatusController.m in Sources */, 61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */, 61B93A3D0DD02D7000DCD2F8 /* SUUIBasedUpdateDriver.m in Sources */, @@ -1731,13 +1731,16 @@ isa = PBXVariantGroup; children = ( 6149E6EA1601ABAC008A351E /* ar */, + 147D6DA71B66EC1C006607AB /* ca */, 615409C4103BBC4000125AF1 /* cs */, 61131A050F846CE600E97AF6 /* da */, 619B17200E1E9D0800E72754 /* de */, 555CF29A196C52330000B31E /* el */, 61AAE8230A321A7F00D8810D /* en */, 61AAE84F0A321AF700D8810D /* es */, + 147D6DA91B66EC22006607AB /* fi */, 61AAE8590A321B0400D8810D /* fr */, + 147D6DAA1B66EC25006607AB /* he */, 613151B20FB4946A000DCD59 /* is */, 61F614540E24A12D009F47E7 /* it */, 611A904610240DF700CC659E /* ja */, @@ -1757,9 +1760,6 @@ 0263187214FEBB31005EBF43 /* uk */, 61131A090F846D0A00E97AF6 /* zh_CN */, 61131A0A0F846D1100E97AF6 /* zh_TW */, - 147D6DA71B66EC1C006607AB /* ca */, - 147D6DA91B66EC22006607AB /* fi */, - 147D6DAA1B66EC25006607AB /* he */, ); name = Sparkle.strings; sourceTree = ""; diff --git a/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme b/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme index 7a051ea2..0ac6a3dc 100644 --- a/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme +++ b/Sparkle.xcodeproj/xcshareddata/xcschemes/Distribution.xcscheme @@ -1,6 +1,6 @@ Date: Sun, 27 Sep 2015 12:24:47 -0700 Subject: [PATCH 30/87] Avoid converting URLs to paths to check for existence --- TestApplication/SUTestApplicationDelegate.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestApplication/SUTestApplicationDelegate.m b/TestApplication/SUTestApplicationDelegate.m index 09e98c71..d62353c6 100644 --- a/TestApplication/SUTestApplicationDelegate.m +++ b/TestApplication/SUTestApplicationDelegate.m @@ -53,7 +53,7 @@ static NSString * const UPDATED_VERSION = @"2.0"; // Create a directory that'll be used for our web server listing NSURL *serverDirectoryURL = [cacheDirectoryURL URLByAppendingPathComponent:bundleIdentifier]; - if ([fileManager fileExistsAtPath:serverDirectoryURL.path]) { + if ([serverDirectoryURL checkResourceIsReachableAndReturnError:nil]) { NSError *removeServerDirectoryError = nil; if (![fileManager removeItemAtURL:serverDirectoryURL error:&removeServerDirectoryError]) { @@ -81,7 +81,7 @@ static NSString * const UPDATED_VERSION = @"2.0"; // Update bundle's version keys to latest version NSURL *infoURL = [[destinationBundleURL URLByAppendingPathComponent:@"Contents"] URLByAppendingPathComponent:@"Info.plist"]; - BOOL infoFileExists = [fileManager fileExistsAtPath:infoURL.path]; + BOOL infoFileExists = [infoURL checkResourceIsReachableAndReturnError:nil]; assert(infoFileExists); NSMutableDictionary *infoDictionary = [[NSMutableDictionary alloc] initWithContentsOfURL:infoURL]; From 079666643dfbef582c9818a390815d030552d006 Mon Sep 17 00:00:00 2001 From: Kevin Wojniak Date: Sun, 27 Sep 2015 12:31:45 -0700 Subject: [PATCH 31/87] Set the task working directories instead of changing the process working directory --- TestApplication/SUTestApplicationDelegate.m | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/TestApplication/SUTestApplicationDelegate.m b/TestApplication/SUTestApplicationDelegate.m index d62353c6..481222d2 100644 --- a/TestApplication/SUTestApplicationDelegate.m +++ b/TestApplication/SUTestApplicationDelegate.m @@ -92,14 +92,15 @@ static NSString * const UPDATED_VERSION = @"2.0"; assert(wroteInfoFile); // Change current working directory so web server knows where to list files - BOOL changedCurrentWorkingDirectory = [fileManager changeCurrentDirectoryPath:serverDirectoryURL.path]; - assert(changedCurrentWorkingDirectory); + NSString *serverDirectoryPath = serverDirectoryURL.path; + assert(serverDirectoryPath != nil); // Create the archive for our update NSString *zipName = @"Sparkle_Test_App.zip"; NSTask *dittoTask = [[NSTask alloc] init]; dittoTask.launchPath = @"/usr/bin/ditto"; dittoTask.arguments = @[@"-c", @"-k", @"--sequesterRsrc", @"--keepParent", destinationBundleURL.lastPathComponent, zipName]; + dittoTask.currentDirectoryPath = serverDirectoryPath; [dittoTask launch]; [dittoTask waitUntilExit]; @@ -175,7 +176,13 @@ static NSString * const UPDATED_VERSION = @"2.0"; } // Finally start the server - self.serverTask = [NSTask launchedTaskWithLaunchPath:@"/usr/bin/python" arguments:@[@"-m", @"SimpleHTTPServer", @"1337"]]; + NSTask *serverTask = [[NSTask alloc] init]; + serverTask.launchPath = @"/usr/bin/python"; + assert([[NSFileManager defaultManager] fileExistsAtPath:serverTask.launchPath]); + serverTask.arguments = @[@"-m", @"SimpleHTTPServer", @"1337"]; + serverTask.currentDirectoryPath = serverDirectoryPath; + [serverTask launch]; + self.serverTask = serverTask; // Show the Settings window self.updateSettingsWindowController = [[SUUpdateSettingsWindowController alloc] init]; From 2ad01ad672c18e88f7289a7c21cc5fba26e20090 Mon Sep 17 00:00:00 2001 From: Kevin Wojniak Date: Sun, 27 Sep 2015 12:33:14 -0700 Subject: [PATCH 32/87] Reuse file manager variable --- TestApplication/SUTestApplicationDelegate.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestApplication/SUTestApplicationDelegate.m b/TestApplication/SUTestApplicationDelegate.m index 481222d2..b46a739a 100644 --- a/TestApplication/SUTestApplicationDelegate.m +++ b/TestApplication/SUTestApplicationDelegate.m @@ -106,7 +106,7 @@ static NSString * const UPDATED_VERSION = @"2.0"; assert(dittoTask.terminationStatus == 0); - [[NSFileManager defaultManager] removeItemAtURL:destinationBundleURL error:NULL]; + [fileManager removeItemAtURL:destinationBundleURL error:NULL]; // Don't ever do this at home, kids (seriously) // (that is, including the private key inside of your application) @@ -178,7 +178,7 @@ static NSString * const UPDATED_VERSION = @"2.0"; // Finally start the server NSTask *serverTask = [[NSTask alloc] init]; serverTask.launchPath = @"/usr/bin/python"; - assert([[NSFileManager defaultManager] fileExistsAtPath:serverTask.launchPath]); + assert([fileManager fileExistsAtPath:serverTask.launchPath]); serverTask.arguments = @[@"-m", @"SimpleHTTPServer", @"1337"]; serverTask.currentDirectoryPath = serverDirectoryPath; [serverTask launch]; From 2f41dec80569d1d67664e4e515798d0a3140ae62 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 27 Sep 2015 16:19:35 -0400 Subject: [PATCH 33/87] Log any installation error that may occur --- Sparkle/Autoupdate/Autoupdate.m | 1 + 1 file changed, 1 insertion(+) diff --git a/Sparkle/Autoupdate/Autoupdate.m b/Sparkle/Autoupdate/Autoupdate.m index b1c8c9f6..ddc60f6c 100644 --- a/Sparkle/Autoupdate/Autoupdate.m +++ b/Sparkle/Autoupdate/Autoupdate.m @@ -172,6 +172,7 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5; versionComparator:[SUStandardVersionComparator defaultComparator] completionHandler:^(NSError *error) { if (error) { + SULog(@"Installation Error: %@", error); if (self.shouldShowUI) { NSAlert *alert = [[NSAlert alloc] init]; alert.messageText = @""; From 5afdc4f20ee9686f377f8c308f6c7961e12af957 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Sun, 27 Sep 2015 15:41:12 -0700 Subject: [PATCH 34/87] Implement isOperatingSystemAtLeastVersion: --- Sparkle/SUHost.h | 1 + Sparkle/SUHost.m | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/Sparkle/SUHost.h b/Sparkle/SUHost.h index 732eae28..127f2d99 100644 --- a/Sparkle/SUHost.h +++ b/Sparkle/SUHost.h @@ -24,6 +24,7 @@ typedef struct { @property (strong, readonly) NSBundle *bundle; + (NSOperatingSystemVersion)operatingSystemVersion; ++ (BOOL)isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version; + (NSString *)systemVersionString; - (instancetype)initWithBundle:(NSBundle *)aBundle; diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index 6ce40fbb..aa95b3bd 100644 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -305,6 +305,18 @@ return [[NSProcessInfo processInfo] operatingSystemVersion]; } ++ (BOOL)isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version +{ + const NSOperatingSystemVersion systemVersion = self.operatingSystemVersion; + if (systemVersion.majorVersion == version.majorVersion) { + if (systemVersion.minorVersion == version.minorVersion) { + return systemVersion.patchVersion >= version.patchVersion; + } + return systemVersion.minorVersion >= version.minorVersion; + } + return systemVersion.majorVersion >= version.majorVersion; +} + + (NSString *)systemVersionString { NSOperatingSystemVersion version = self.operatingSystemVersion; From b943af3b595216c42888e11384168b60b3b2aa86 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Sun, 27 Sep 2015 15:42:51 -0700 Subject: [PATCH 35/87] Use proper version checking. --- Sparkle/SUFileManager.m | 7 ++++--- Sparkle/SUHost.m | 2 +- Sparkle/SUUIBasedUpdateDriver.m | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index f2739f40..d34333ea 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -7,6 +7,7 @@ // #import "SUFileManager.h" +#import "SUHost.h" #include #include @@ -699,8 +700,8 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza NSURL *trashURL = nil; BOOL canUseNewTrashAPI = YES; -#if __MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8 - canUseNewTrashAPI = [_fileManager respondsToSelector:@selector(trashItemAtURL:resultingItemURL:error:)]; +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1080 + canUseNewTrashAPI = [SUHost isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 8, 0}]; if (!canUseNewTrashAPI) { FSRef trashRef; if (FSFindFolder(kUserDomain, kTrashFolderType, kDontCreateFolder, &trashRef) == noErr) { @@ -747,7 +748,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // If we get here, we should be able to trash the item normally without authentication BOOL success = NO; -#if __MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8 +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1080 if (!canUseNewTrashAPI) { NSString *tempParentPath = tempItemURL.URLByDeletingLastPathComponent.path; success = [[NSWorkspace sharedWorkspace] performFileOperation:NSWorkspaceRecycleOperation source:tempParentPath destination:@"" files:@[tempItemURL.lastPathComponent] tag:NULL]; diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index aa95b3bd..57bd8f25 100644 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -286,7 +286,7 @@ + (NSOperatingSystemVersion)operatingSystemVersion { -#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1090 // Present in 10.9 despite NS_AVAILABLE's claims +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wselector" // Xcode 5.1.1: operatingSystemVersion is clearly declared, must warn due to a compiler bug? diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index 869dc0de..4e7f7ec8 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -128,7 +128,7 @@ - (NSString *)localizedStringFromByteCount:(long long)value { - if (SUHost.operatingSystemVersion.minorVersion < 8) { + if (![SUHost isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 8, 0}]) { if (value < 1000) { return [NSString stringWithFormat:@"%.0lf %@", value / 1.0, SULocalizedString(@"B", @"the unit for bytes")]; From 9ca70a515762f5a4ef6e8f76af8e59ef4b220915 Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Sun, 27 Sep 2015 16:16:37 -0700 Subject: [PATCH 36/87] Fix warnings. --- Sparkle/SUFileManager.m | 14 +++++++------- Tests/SUDSAVerifierTest.m | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index d34333ea..996214a6 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -178,9 +178,9 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } return NO; } - - const char *xattrName = [name cStringUsingEncoding:NSASCIIStringEncoding]; - if (xattrName == NULL) { + + char xattrName[PATH_MAX] = {0}; + if (![name getFileSystemRepresentation:xattrName maxLength:sizeof(xattrName)]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteInapplicableStringEncodingError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Extended attribute %@ is not a valid ASCII convertible string.", name] }]; } @@ -191,7 +191,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return NO; } - BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, XATTR_UTILITY_PATH, kAuthorizationFlagDefaults, (char *[]){ "-s", "-r", "-d", (char *)xattrName, path, NULL }); + BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, XATTR_UTILITY_PATH, kAuthorizationFlagDefaults, (char *[]){ "-s", "-r", "-d", xattrName, path, NULL }); if (!success && error != NULL) { NSString *errorMessage = [NSString stringWithFormat:@"Authenticated extended attribute deletion for %@ failed on %@.", name, rootURL.path.lastPathComponent]; @@ -508,8 +508,8 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } NSString *formattedUserAndGroupIDs = [NSString stringWithFormat:@"%u:%u", ownerID.unsignedIntValue, groupID.unsignedIntValue]; - const char *userAndGroup = [formattedUserAndGroupIDs cStringUsingEncoding:NSASCIIStringEncoding]; - if (userAndGroup == NULL) { + char userAndGroup[PATH_MAX] = {0}; + if (![formattedUserAndGroupIDs getFileSystemRepresentation:userAndGroup maxLength:sizeof(userAndGroup)]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFormattingError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Owner ID %u and Group ID %u could not be formatted.", ownerID.unsignedIntValue, groupID.unsignedIntValue] }]; } @@ -520,7 +520,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return NO; } - BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, (char *[]){ "-R", (char *)userAndGroup, targetPath, NULL }); + BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, (char *[]){ "-R", userAndGroup, targetPath, NULL }); if (!success && error != NULL) { NSString *errorMessage = [NSString stringWithFormat:@"Failed to change owner:group %@ on %@ with authentication.", formattedUserAndGroupIDs, targetURL.path.lastPathComponent]; *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }]; diff --git a/Tests/SUDSAVerifierTest.m b/Tests/SUDSAVerifierTest.m index f9c4b983..83f76e38 100644 --- a/Tests/SUDSAVerifierTest.m +++ b/Tests/SUDSAVerifierTest.m @@ -67,7 +67,7 @@ { SUDSAVerifier *v = [[SUDSAVerifier alloc] initWithPublicKeyData:pubKey]; - NSData *sig = [[NSData alloc] initWithBase64Encoding:sigString]; + NSData *sig = [[NSData alloc] initWithBase64EncodedString:sigString options:(NSDataBase64DecodingOptions)0]; return [v verifyFileAtPath:aFile signature:sig]; } From c61b5d99a2a9967ae944fc2902cc32d20ccebb12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesi=C5=84ski?= Date: Mon, 28 Sep 2015 10:46:27 +0100 Subject: [PATCH 37/87] Avoid conversion from NSString to char[] --- Sparkle/SUFileManager.m | 34 ++++------------------ Tests/Sparkle Unit Tests-Bridging-Header.h | 3 +- 2 files changed, 7 insertions(+), 30 deletions(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 996214a6..dd8b47b5 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -13,11 +13,7 @@ #include #include -#pragma clang diagnostic push -// This is a private constant but it's referenced from our unit tests -#pragma clang diagnostic ignored "-Wmissing-variable-declarations" -NSString *SUAppleQuarantineIdentifier = @"com.apple.quarantine"; -#pragma clang diagnostic pop +static char SUAppleQuarantineIdentifier[] = "com.apple.quarantine"; // Authorization code based on generous contribution from Allan Odgaard. Thanks, Allan! static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char *executablePath, AuthorizationFlags options, char *const *arguments) @@ -124,7 +120,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } // Wrapper around getxattr() -- (ssize_t)_getXAttr:(NSString *)nameString fromFile:(NSString *)file options:(int)options +- (ssize_t)_getXAttr:(const char *)name fromFile:(NSString *)file options:(int)options { char path[PATH_MAX] = {0}; if (![file getFileSystemRepresentation:path maxLength:sizeof(path)]) { @@ -132,17 +128,11 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return -1; } - const char *name = [nameString cStringUsingEncoding:NSASCIIStringEncoding]; - if (name == NULL) { - errno = 0; - return -1; - } - return getxattr(path, name, NULL, 0, 0, options); } // Wrapper around removexattr() -- (int)_removeXAttr:(NSString *)name fromFile:(NSString *)file options:(int)options +- (int)_removeXAttr:(const char *)attr fromFile:(NSString *)file options:(int)options { char path[PATH_MAX] = {0}; if (![file getFileSystemRepresentation:path maxLength:sizeof(path)]) { @@ -150,18 +140,12 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return -1; } - const char *attr = [name cStringUsingEncoding:NSASCIIStringEncoding]; - if (attr == NULL) { - errno = 0; - return -1; - } - return removexattr(path, attr, options); } #define XATTR_UTILITY_PATH "/usr/bin/xattr" // Recursively remove an xattr at a specified root URL with authentication -- (BOOL)_removeXAttrWithAuthentication:(NSString *)name fromRootURL:(NSURL *)rootURL error:(NSError *__autoreleasing *)error +- (BOOL)_removeXAttrWithAuthentication:(char *__nonnull)xattrName fromRootURL:(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)]) { @@ -178,14 +162,6 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza } return NO; } - - char xattrName[PATH_MAX] = {0}; - if (![name getFileSystemRepresentation:xattrName maxLength:sizeof(xattrName)]) { - if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteInapplicableStringEncodingError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Extended attribute %@ is not a valid ASCII convertible string.", name] }]; - } - return NO; - } if (![self _acquireAuthorizationWithError:error]) { return NO; @@ -194,7 +170,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, XATTR_UTILITY_PATH, kAuthorizationFlagDefaults, (char *[]){ "-s", "-r", "-d", xattrName, path, NULL }); if (!success && error != NULL) { - NSString *errorMessage = [NSString stringWithFormat:@"Authenticated extended attribute deletion for %@ failed on %@.", name, rootURL.path.lastPathComponent]; + NSString *errorMessage = [NSString stringWithFormat:@"Authenticated extended attribute deletion for %@ failed on %@.", [NSString stringWithUTF8String:xattrName], rootURL.path.lastPathComponent]; *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:errorMessage }]; } diff --git a/Tests/Sparkle Unit Tests-Bridging-Header.h b/Tests/Sparkle Unit Tests-Bridging-Header.h index 7f7cc44e..ab678027 100644 --- a/Tests/Sparkle Unit Tests-Bridging-Header.h +++ b/Tests/Sparkle Unit Tests-Bridging-Header.h @@ -7,7 +7,8 @@ #import "SUBinaryDeltaCommon.h" #import "SUFileManager.h" -extern NSString *SUAppleQuarantineIdentifier; +// Duplicated to avoid exporting a private symbol from SUFileManager +static const char *SUAppleQuarantineIdentifier = "com.apple.quarantine"; @interface SUFileManager (Private) From bac2463ff213b2ff299f8a55c905dacf3e70448b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesi=C5=84ski?= Date: Mon, 28 Sep 2015 10:54:30 +0100 Subject: [PATCH 38/87] Use a C formatting function for a C string --- Sparkle/SUFileManager.m | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index dd8b47b5..2d4e3ba4 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -483,13 +483,10 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return NO; } - NSString *formattedUserAndGroupIDs = [NSString stringWithFormat:@"%u:%u", ownerID.unsignedIntValue, groupID.unsignedIntValue]; - char userAndGroup[PATH_MAX] = {0}; - if (![formattedUserAndGroupIDs getFileSystemRepresentation:userAndGroup maxLength:sizeof(userAndGroup)]) { - if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFormattingError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Owner ID %u and Group ID %u could not be formatted.", ownerID.unsignedIntValue, groupID.unsignedIntValue] }]; - } - return NO; + char userAndGroup[100]; + int written = snprintf(userAndGroup, sizeof(userAndGroup), "%u:%u", ownerID.unsignedIntValue, groupID.unsignedIntValue); + if (written < 0 || written >= 100) { + return NO; // No custom error, because it's too unlikely to ever happen } if (![self _acquireAuthorizationWithError:error]) { @@ -498,7 +495,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, (char *[]){ "-R", userAndGroup, targetPath, NULL }); if (!success && error != NULL) { - NSString *errorMessage = [NSString stringWithFormat:@"Failed to change owner:group %@ on %@ with authentication.", formattedUserAndGroupIDs, targetURL.path.lastPathComponent]; + NSString *errorMessage = [NSString stringWithFormat:@"Failed to change owner:group %@ on %@ with authentication.", [NSString stringWithUTF8String:userAndGroup], targetURL.path.lastPathComponent]; *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }]; } From 165b772f8f993122295423715f7e2090833cd030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Tue, 29 Sep 2015 00:39:35 +0100 Subject: [PATCH 39/87] MaxCDN --- README.markdown | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index 5669da02..3e852779 100644 --- a/README.markdown +++ b/README.markdown @@ -1,4 +1,4 @@ -# Sparkle [![Build Status](https://travis-ci.org/sparkle-project/Sparkle.svg?branch=master)](https://travis-ci.org/sparkle-project/Sparkle) [![Coverage Status](https://coveralls.io/repos/sparkle-project/Sparkle/badge.svg?branch=master&service=github)](https://coveralls.io/github/sparkle-project/Sparkle?branch=master) +# Sparkle [![Build Status](https://travis-ci.org/sparkle-project/Sparkle.svg?branch=master)](https://travis-ci.org/sparkle-project/Sparkle) [![Coverage Status](https://coveralls.io/repos/sparkle-project/Sparkle/badge.svg?branch=master&service=github)](https://coveralls.io/github/sparkle-project/Sparkle?branch=master) sponsored by: bandwidth hog An easy-to-use software update framework for Cocoa developers. @@ -46,3 +46,8 @@ If you are adding a symbol to the public API you must decorate the declaration w `cd` to the root of the Sparkle source tree and run `make release`. Sparkle-*VERSION*.tar.bz2 will be created in a temporary directory and revealed in Finder after the build has completed. Alternatively, build the Distribution scheme in the Xcode UI. + +### Project Sponsor + +[Bandwidth Hog](https://www.bandwidthhog.com/?utm_source=sparkle-github&utm_medium=link&utm_campaign=readme-footer) is a service from MaxCDN +that allows you to push software updates to your customers for only 1¢ a gigabyte. Best part is there are no contracts, it is all Pay-as-you-Go. From 49e262e71821e62f11197f017442c1669398566c Mon Sep 17 00:00:00 2001 From: Kevin Wojniak Date: Sun, 4 Oct 2015 16:36:57 -0700 Subject: [PATCH 40/87] Fix readme headings --- README.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 3e852779..3c92a646 100644 --- a/README.markdown +++ b/README.markdown @@ -36,18 +36,18 @@ An easy-to-use software update framework for Cocoa developers. * Runtime: OS X 10.7 or greater * Build: Xcode 5 and 10.8 SDK or greater -### API +## API Sparkle is built with `-fvisibility=hidden -fvisibility-inlines-hidden` which means no symbols are exported by default. If you are adding a symbol to the public API you must decorate the declaration with the `SU_EXPORT` macro (grep the source code for examples). -### Building the distribution package +## Building the distribution package `cd` to the root of the Sparkle source tree and run `make release`. Sparkle-*VERSION*.tar.bz2 will be created in a temporary directory and revealed in Finder after the build has completed. Alternatively, build the Distribution scheme in the Xcode UI. -### Project Sponsor +## Project Sponsor [Bandwidth Hog](https://www.bandwidthhog.com/?utm_source=sparkle-github&utm_medium=link&utm_campaign=readme-footer) is a service from MaxCDN that allows you to push software updates to your customers for only 1¢ a gigabyte. Best part is there are no contracts, it is all Pay-as-you-Go. From 21e4cc42cc830f9a7d46492e6b98bc6d829ac749 Mon Sep 17 00:00:00 2001 From: Zorg Date: Wed, 7 Oct 2015 18:44:14 -0400 Subject: [PATCH 41/87] Fix segfault when patch path has insufficient write permissions --- Sparkle/SUBinaryDeltaCreate.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sparkle/SUBinaryDeltaCreate.m b/Sparkle/SUBinaryDeltaCreate.m index db790642..98a6f08b 100644 --- a/Sparkle/SUBinaryDeltaCreate.m +++ b/Sparkle/SUBinaryDeltaCreate.m @@ -439,6 +439,16 @@ BOOL createBinaryDelta(NSString *source, NSString *destination, NSString *patchF NSString *temporaryFile = temporaryPatchFile(patchFile); xar_t x = xar_open([temporaryFile fileSystemRepresentation], WRITE); + if (!x) { + if (verbose) { + fprintf(stderr, "\n"); + } + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteUnknownError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to write to %@", temporaryFile] }]; + } + return NO; + } + xar_opt_set(x, XAR_OPT_COMPRESSION, "bzip2"); xar_subdoc_t attributes = xar_subdoc_new(x, BINARY_DELTA_ATTRIBUTES_KEY); From a92c23bb267a039c74d8a037df9478a3cc614c4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ian=20Langworth=20=E2=98=A0?= Date: Fri, 18 Sep 2015 15:25:24 -0700 Subject: [PATCH 42/87] Add automatically install updates option --- Sparkle/SUUIBasedUpdateDriver.h | 2 ++ Sparkle/SUUIBasedUpdateDriver.m | 38 +++++++++++++++++++++++++++------ Sparkle/SUUpdater.h | 17 +++++++++++++++ Sparkle/SUUpdater.m | 11 ++++++++++ 4 files changed, 61 insertions(+), 7 deletions(-) diff --git a/Sparkle/SUUIBasedUpdateDriver.h b/Sparkle/SUUIBasedUpdateDriver.h index 65f37443..cf55f3b3 100644 --- a/Sparkle/SUUIBasedUpdateDriver.h +++ b/Sparkle/SUUIBasedUpdateDriver.h @@ -17,6 +17,8 @@ @interface SUUIBasedUpdateDriver : SUBasicUpdateDriver +@property (nonatomic, assign) BOOL automaticallyInstallUpdates; + - (void)showModalAlert:(NSAlert *)alert; - (IBAction)cancelDownload:(id)sender; - (void)installAndRestart:(id)sender; diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index 4e7f7ec8..7dac7751 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -41,8 +41,21 @@ @synthesize statusController; @synthesize updateAlert; +- (instancetype)initWithUpdater:(SUUpdater *)anUpdater +{ + if ((self = [super initWithUpdater:anUpdater])) { + self.automaticallyInstallUpdates = NO; + } + return self; +} + - (void)didFindValidUpdate { + if (self.automaticallyInstallUpdates) { + [self updateAlertFinishedWithChoice:SUInstallUpdateChoice]; + return; + } + self.updateAlert = [[SUUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host completionBlock:^(SUUpdateAlertChoice choice) { [self updateAlertFinishedWithChoice:choice]; }]; @@ -78,12 +91,14 @@ [[self.updater delegate] updaterDidNotFindUpdate:self.updater]; [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater]; - NSAlert *alert = [[NSAlert alloc] init]; - alert.messageText = SULocalizedString(@"You're up-to-date!", "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates."); - alert.informativeText = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [self.host name], [self.host displayVersion]]; - [alert addButtonWithTitle:SULocalizedString(@"OK", nil)]; - [self showModalAlert:alert]; - [self abortUpdate]; + if (!self.automaticallyInstallUpdates) { + NSAlert *alert = [[NSAlert alloc] init]; + alert.messageText = SULocalizedString(@"You're up-to-date!", "Status message shown when the user checks for updates but is already current or the feed doesn't contain any updates."); + alert.informativeText = [NSString stringWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [self.host name], [self.host displayVersion]]; + [alert addButtonWithTitle:SULocalizedString(@"OK", nil)]; + [self showModalAlert:alert]; + [self abortUpdate]; + } } - (void)applicationDidBecomeActive:(NSNotification *)__unused aNotification @@ -163,8 +178,12 @@ - (IBAction)cancelDownload:(id)__unused sender { - if (self.download) + if (self.download) { [self.download cancel]; + if ([[self.updater delegate] respondsToSelector:@selector(userDidCancelDownload:)]) { + [[self.updater delegate] userDidCancelDownload:self.updater]; + } + } [self abortUpdate]; } @@ -187,6 +206,11 @@ - (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua { + if (self.automaticallyInstallUpdates) { + [self installWithToolAndRelaunch:YES]; + return; + } + [self.statusController beginActionWithTitle:SULocalizedString(@"Ready to Install", nil) maxProgressValue:1.0 statusText:nil]; [self.statusController setProgressValue:1.0]; // Fill the bar. [self.statusController setButtonEnabled:YES]; diff --git a/Sparkle/SUUpdater.h b/Sparkle/SUUpdater.h index ce07a142..ed0072af 100644 --- a/Sparkle/SUUpdater.h +++ b/Sparkle/SUUpdater.h @@ -77,6 +77,16 @@ SU_EXPORT @interface SUUpdater : NSObject */ - (void)checkForUpdatesInBackground; +/*! + Checks for updates and, if available, immediately downloads and installs them. + A progress dialog is shown but the user will never be prompted to read the + release notes. + + You may want to respond to the userDidCancelDownload delegate method in case + the user clicks the "Cancel" button while the update is downloading. + */ +- (void)installUpdatesIfAvailable; + /*! Returns the date of last update check. @@ -228,6 +238,13 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey; */ - (void)updater:(SUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error; +/*! + Called when the user clicks the cancel button while and update is being downloaded. + + \param updater The SUUpdater instance. + */ +- (void)userDidCancelDownload:(SUUpdater *)updater; + /*! Called immediately before installing the specified update. diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index 7a824f3c..2e0390b3 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -333,6 +333,17 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults [self checkForUpdatesWithDriver:[[SUProbingUpdateDriver alloc] initWithUpdater:self]]; } +- (void)installUpdatesIfAvailable +{ + if (self.driver && [self.driver isInterruptible]) { + [self.driver abortUpdate]; + } + + SUUIBasedUpdateDriver *theUpdateDriver = [[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self]; + theUpdateDriver.automaticallyInstallUpdates = YES; + [self checkForUpdatesWithDriver:theUpdateDriver]; +} + - (void)checkForUpdatesWithDriver:(SUUpdateDriver *)d { if ([self updateInProgress]) { return; } From 7ccf706a1dc1bed042354182a4f40105525ca4c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Thu, 8 Oct 2015 23:24:45 +0100 Subject: [PATCH 43/87] Synthesize automaticallyInstallUpdates --- Sparkle/SUUIBasedUpdateDriver.h | 2 -- Sparkle/SUUpdateDriver.h | 1 + Sparkle/SUUpdateDriver.m | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sparkle/SUUIBasedUpdateDriver.h b/Sparkle/SUUIBasedUpdateDriver.h index cf55f3b3..65f37443 100644 --- a/Sparkle/SUUIBasedUpdateDriver.h +++ b/Sparkle/SUUIBasedUpdateDriver.h @@ -17,8 +17,6 @@ @interface SUUIBasedUpdateDriver : SUBasicUpdateDriver -@property (nonatomic, assign) BOOL automaticallyInstallUpdates; - - (void)showModalAlert:(NSAlert *)alert; - (IBAction)cancelDownload:(id)sender; - (void)installAndRestart:(id)sender; diff --git a/Sparkle/SUUpdateDriver.h b/Sparkle/SUUpdateDriver.h index 5575994d..12f93558 100644 --- a/Sparkle/SUUpdateDriver.h +++ b/Sparkle/SUUpdateDriver.h @@ -24,6 +24,7 @@ extern NSString *const SUUpdateDriverFinishedNotification; - (void)abortUpdate; @property (getter=isInterruptible, readonly) BOOL interruptible; @property (readonly) BOOL finished; +@property BOOL automaticallyInstallUpdates; @end diff --git a/Sparkle/SUUpdateDriver.m b/Sparkle/SUUpdateDriver.m index cee31648..6de580ca 100644 --- a/Sparkle/SUUpdateDriver.m +++ b/Sparkle/SUUpdateDriver.m @@ -26,6 +26,7 @@ NSString *const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished"; @synthesize interruptible; @synthesize finished; @synthesize appcastURL; +@synthesize automaticallyInstallUpdates; - (instancetype)initWithUpdater:(SUUpdater *)anUpdater { From d1a62bba89fc9d0567d10f827e8c0ce66c200696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ian=20Langworth=20=E2=98=A0?= Date: Thu, 8 Oct 2015 15:33:00 -0700 Subject: [PATCH 44/87] Fire didFindValidUpdate even if automatically installing updates --- Sparkle/SUUIBasedUpdateDriver.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index 7dac7751..11bbc044 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -51,6 +51,10 @@ - (void)didFindValidUpdate { + if ([[self.updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) { + [[self.updater delegate] updater:self.updater didFindValidUpdate:self.updateItem]; + } + if (self.automaticallyInstallUpdates) { [self updateAlertFinishedWithChoice:SUInstallUpdateChoice]; return; @@ -66,10 +70,6 @@ } [self.updateAlert setVersionDisplayer:versDisp]; - if ([[self.updater delegate] respondsToSelector:@selector(updater:didFindValidUpdate:)]) { - [[self.updater delegate] updater:self.updater didFindValidUpdate:self.updateItem]; - } - // If the app is a menubar app or the like, we need to focus it first and alter the // update prompt to behave like a normal window. Otherwise if the window were hidden // there may be no way for the application to be activated to make it visible again. From 17da7b5fb8b8566a6950ba4412f9780c6718be64 Mon Sep 17 00:00:00 2001 From: Zorg Date: Thu, 8 Oct 2015 22:49:03 -0400 Subject: [PATCH 45/87] Fix Test App crashing on systems earlier than 10.9 Passing a NSURL instance to a NSTask's arguments calls -[NSURL fileSystemRepresentation] which is only available on 10.9+ --- TestApplication/SUTestApplicationDelegate.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestApplication/SUTestApplicationDelegate.m b/TestApplication/SUTestApplicationDelegate.m index b46a739a..9296073f 100644 --- a/TestApplication/SUTestApplicationDelegate.m +++ b/TestApplication/SUTestApplicationDelegate.m @@ -120,7 +120,7 @@ static NSString * const UPDATED_VERSION = @"2.0"; signUpdateTask.launchPath = signUpdatePath; NSURL *archiveURL = [serverDirectoryURL URLByAppendingPathComponent:zipName]; - signUpdateTask.arguments = @[archiveURL, privateKeyPath]; + signUpdateTask.arguments = @[archiveURL.path, privateKeyPath]; NSPipe *outputPipe = [NSPipe pipe]; signUpdateTask.standardOutput = outputPipe; From 117716da9e5de25f0befef9ffd44a41ad3e32268 Mon Sep 17 00:00:00 2001 From: Kevin Wojniak Date: Thu, 8 Oct 2015 20:41:26 -0700 Subject: [PATCH 46/87] Replace use of Python with built-in web server See issue #637 --- Sparkle.xcodeproj/project.pbxproj | 6 + TestApplication/SUTestApplicationDelegate.m | 20 +- TestApplication/SUTestWebServer.h | 17 ++ TestApplication/SUTestWebServer.m | 247 ++++++++++++++++++++ 4 files changed, 280 insertions(+), 10 deletions(-) create mode 100644 TestApplication/SUTestWebServer.h create mode 100644 TestApplication/SUTestWebServer.m diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 189859cb..356297be 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -190,6 +190,7 @@ 767B61AC1972D488004E0C3C /* SUGuidedPackageInstaller.h in Headers */ = {isa = PBXBuildFile; fileRef = 767B61AA1972D488004E0C3C /* SUGuidedPackageInstaller.h */; }; 767B61AD1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; }; 767B61AE1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; }; + A5BF4F1D1BC7668B007A052A /* SUTestWebServer.m in Sources */ = {isa = PBXBuildFile; fileRef = A5BF4F1C1BC7668B007A052A /* SUTestWebServer.m */; settings = {ASSET_TAGS = (); }; }; F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */; }; F8761EB31ADC50EB000C9034 /* SparkleTestCodeSignApp.zip in Resources */ = {isa = PBXBuildFile; fileRef = F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */; }; F8761EB61ADC5E7A000C9034 /* SUCodeSigningVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B078CD15A5FB6100600039 /* SUCodeSigningVerifier.m */; }; @@ -590,6 +591,8 @@ 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUGuidedPackageInstaller.m; sourceTree = ""; }; 8DC2EF5A0486A6940098B216 /* Sparkle-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Sparkle-Info.plist"; sourceTree = ""; }; 8DC2EF5B0486A6940098B216 /* Sparkle.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Sparkle.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + A5BF4F1B1BC7668B007A052A /* SUTestWebServer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUTestWebServer.h; sourceTree = ""; }; + A5BF4F1C1BC7668B007A052A /* SUTestWebServer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUTestWebServer.m; sourceTree = ""; }; F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUCodeSigningVerifierTest.m; sourceTree = ""; }; F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */ = {isa = PBXFileReference; lastKnownFileType = archive.zip; path = SparkleTestCodeSignApp.zip; sourceTree = ""; }; FA1941CA0D94A70100DD942E /* ConfigFrameworkDebug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = ConfigFrameworkDebug.xcconfig; sourceTree = ""; }; @@ -973,6 +976,8 @@ 72E45CF21B640CDD005C701A /* SUTestApplicationDelegate.m */, 72E45CF41B640DAE005C701A /* SUUpdateSettingsWindowController.h */, 72E45CF51B640DAE005C701A /* SUUpdateSettingsWindowController.m */, + A5BF4F1B1BC7668B007A052A /* SUTestWebServer.h */, + A5BF4F1C1BC7668B007A052A /* SUTestWebServer.m */, 72E45CF61B640DAE005C701A /* SUUpdateSettingsWindowController.xib */, 72E45CFD1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem */, 14732BBF1960F0AC00593899 /* test_app_only_dsa_pub.pem */, @@ -1507,6 +1512,7 @@ buildActionMask = 2147483647; files = ( 61B5F93009C4CFDC00B25A18 /* main.m in Sources */, + A5BF4F1D1BC7668B007A052A /* SUTestWebServer.m in Sources */, 72E45CF31B640CDD005C701A /* SUTestApplicationDelegate.m in Sources */, 72E45CF71B640DAE005C701A /* SUUpdateSettingsWindowController.m in Sources */, ); diff --git a/TestApplication/SUTestApplicationDelegate.m b/TestApplication/SUTestApplicationDelegate.m index b46a739a..13ae0d80 100644 --- a/TestApplication/SUTestApplicationDelegate.m +++ b/TestApplication/SUTestApplicationDelegate.m @@ -8,18 +8,19 @@ #import "SUTestApplicationDelegate.h" #import "SUUpdateSettingsWindowController.h" +#import "SUTestWebServer.h" @interface SUTestApplicationDelegate () @property (nonatomic) SUUpdateSettingsWindowController *updateSettingsWindowController; -@property (nonatomic) NSTask *serverTask; +@property (nonatomic) SUTestWebServer *webServer; @end @implementation SUTestApplicationDelegate @synthesize updateSettingsWindowController = _updateSettingsWindowController; -@synthesize serverTask = _serverTask; +@synthesize webServer = _webServer; static NSString * const UPDATED_VERSION = @"2.0"; @@ -176,13 +177,12 @@ static NSString * const UPDATED_VERSION = @"2.0"; } // Finally start the server - NSTask *serverTask = [[NSTask alloc] init]; - serverTask.launchPath = @"/usr/bin/python"; - assert([fileManager fileExistsAtPath:serverTask.launchPath]); - serverTask.arguments = @[@"-m", @"SimpleHTTPServer", @"1337"]; - serverTask.currentDirectoryPath = serverDirectoryPath; - [serverTask launch]; - self.serverTask = serverTask; + SUTestWebServer *webServer = [[SUTestWebServer alloc] initWithPort:1337 workingDirectory:serverDirectoryPath]; + if (!webServer) { + NSLog(@"Failed to create the web server"); + assert(NO); + } + self.webServer = webServer; // Show the Settings window self.updateSettingsWindowController = [[SUUpdateSettingsWindowController alloc] init]; @@ -191,7 +191,7 @@ static NSString * const UPDATED_VERSION = @"2.0"; - (void)applicationWillTerminate:(NSNotification * __unused)notification { - [self.serverTask terminate]; + [self.webServer close]; } @end diff --git a/TestApplication/SUTestWebServer.h b/TestApplication/SUTestWebServer.h new file mode 100644 index 00000000..2c61c565 --- /dev/null +++ b/TestApplication/SUTestWebServer.h @@ -0,0 +1,17 @@ +// +// SUTestWebServer.h +// Sparkle +// +// Created by Kevin Wojniak on 10/8/15. +// Copyright © 2015 Sparkle Project. All rights reserved. +// + +#import + +@interface SUTestWebServer : NSObject + +- (instancetype)initWithPort:(int)port workingDirectory:(NSString*)workingDirectory; + +- (void)close; + +@end diff --git a/TestApplication/SUTestWebServer.m b/TestApplication/SUTestWebServer.m new file mode 100644 index 00000000..f3cd6189 --- /dev/null +++ b/TestApplication/SUTestWebServer.m @@ -0,0 +1,247 @@ +// +// SUTestWebServer.m +// Sparkle +// +// Created by Kevin Wojniak on 10/8/15. +// Copyright © 2015 Sparkle Project. All rights reserved. +// + +#import "SUTestWebServer.h" +#import +#import + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" + +@class SUTestWebServerConnection; + +@protocol SUTestWebServerConnectionDelegate +@required +- (void)connectionDidClose:(SUTestWebServerConnection*)sender; +@end + +@interface SUTestWebServerConnection : NSObject + +@end + +@implementation SUTestWebServerConnection { + NSString *_workingDirectory; + id _delegate; + NSInputStream *_inputStream; + NSOutputStream *_outputStream; + NSData *_dataToWrite; + NSInteger _numBytesToWrite; +} + +- (instancetype)initWithNativeHandle:(CFSocketNativeHandle)handle workingDirectory:(NSString*)workingDirectory delegate:(id)delegate { + self = [super init]; + assert(self != nil); + + _workingDirectory = workingDirectory; + _delegate = delegate; + + CFReadStreamRef readStream = NULL; + CFWriteStreamRef writeStream = NULL; + CFStreamCreatePairWithSocket(NULL, handle, &readStream, &writeStream); + assert(readStream != NULL); + assert(writeStream != NULL); + + _inputStream = (__bridge NSInputStream*)readStream; + assert(_inputStream != nil); + _inputStream.delegate = self; + + _outputStream = (__bridge NSOutputStream*)writeStream; + assert(_outputStream != nil); + _outputStream.delegate = self; + + [_inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [_outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [_inputStream open]; + [_outputStream open]; + + return self; +} + +- (void)close { + if (!_inputStream) { + assert(_outputStream == nil); + return; + } + [_inputStream close]; + [_outputStream close]; + [_inputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [_outputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + _inputStream = nil; + _outputStream = nil; + [_delegate connectionDidClose:self]; +} + +- (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode { + if (eventCode == NSStreamEventEndEncountered) { + [self close]; + return; + } + if (aStream == _inputStream && eventCode == NSStreamEventHasBytesAvailable) { + uint8_t buffer[8096]; + const NSInteger numBytes = [_inputStream read:buffer maxLength:sizeof(buffer)]; + if (numBytes > 0) { + NSString *request = [[NSString alloc] initWithBytes:buffer length:(NSUInteger)numBytes encoding:NSUTF8StringEncoding]; + NSArray *lines = [request componentsSeparatedByString:@"\r\n"]; + NSString *requestLine = lines.count >= 3 ? lines[0] : nil; + NSArray *parts = requestLine ? [requestLine componentsSeparatedByString:@" "] : nil; + // Only process GET requests for existing files + if ([parts[0] isEqualToString:@"GET"]) { + // Use NSURL to strip out query parameters + NSString *path = [NSURL URLWithString:parts[1] relativeToURL:nil].path; + NSString *filePath = [_workingDirectory stringByAppendingString:path]; + BOOL isDir = NO; + if (![[NSFileManager defaultManager] fileExistsAtPath:filePath isDirectory:&isDir] || isDir) { + NSLog(@"%@ - 404", requestLine); + [self write404]; + } else { + NSLog(@"%@ - 200", requestLine); + [self write:[NSData dataWithContentsOfFile:filePath] status:YES]; + } + } else { + NSLog(@"%@ - 404", requestLine); + [self write404]; + } + } + } else if (aStream == _outputStream && eventCode == NSStreamEventHasSpaceAvailable && _dataToWrite) { + [self checkIfCanWriteNow]; + } +} + +- (void)write404 { + NSString *body = @"404 Not Found

Not Found

"; + [self write:[body dataUsingEncoding:NSUTF8StringEncoding] status:NO]; +} + +- (void)write:(NSData*)body status:(BOOL)status { + NSString *state = status ? @"200 OK" : @"404 Not Found"; + NSString *header = [NSString stringWithFormat:@"HTTP/1.0 %@\r\nContent-Length: %lu\r\n\r\n", state, body.length]; + NSMutableData *response = [[header dataUsingEncoding:NSUTF8StringEncoding] mutableCopy]; + [response appendData:body]; + [self queueWrite:response]; +} + +- (void)queueWrite:(NSData*)data { + assert(_dataToWrite == nil); + assert(data != nil); + assert(data.length > 0); + _dataToWrite = data; + _numBytesToWrite = (NSInteger)data.length; + [self checkIfCanWriteNow]; +} + +- (void)checkIfCanWriteNow { + assert(_dataToWrite != nil); + if (_numBytesToWrite == 0) { + // nothing more to write, we're done. + _dataToWrite = 0; + _numBytesToWrite = -1; + } else if (_outputStream.hasSpaceAvailable) { + [self writeNow]; + } + // otherwise wait for space available event +} + +- (void)writeNow { + assert(_outputStream != nil); + assert(_outputStream.hasSpaceAvailable); + assert(_dataToWrite != nil); + const uint8_t *bytesOffset = (const uint8_t*)_dataToWrite.bytes + ((NSInteger)_dataToWrite.length - _numBytesToWrite); + const NSInteger bytesWritten = [_outputStream write:bytesOffset maxLength:(NSUInteger)_numBytesToWrite]; + if (bytesWritten > 0) { + _numBytesToWrite -= bytesWritten; + assert(_numBytesToWrite >= 0); + // wait for next space available event to write more + } else { + NSLog(@"Error: bytes written = %ld (%@)", bytesWritten, [NSString stringWithUTF8String:strerror(errno)]); + } +} + +@end + +@interface SUTestWebServer () { + NSMutableArray *_connections; + NSString* _workingDirectory; + CFSocketRef _socket; +} + +- (void)accept:(CFSocketNativeHandle)address; + +@end + +static void connectCallback(CFSocketRef __unused s, CFSocketCallBackType type, CFDataRef __unused address, const void *data, void *info) { + if (type == kCFSocketAcceptCallBack) { + SUTestWebServer *server = (__bridge SUTestWebServer*)info; + [server accept:*(const CFSocketNativeHandle*)data]; + } +} + +@implementation SUTestWebServer + +- (instancetype)initWithPort:(int)port workingDirectory:(NSString*)workingDirectory { + self = [super init]; + assert(self != nil); + + CFSocketContext ctx; + memset(&ctx, 0, sizeof(ctx)); + ctx.info = (__bridge void*)self; + _socket = CFSocketCreate(NULL, 0, 0, 0, kCFSocketAcceptCallBack, connectCallback, &ctx); + assert(_socket != NULL); + + struct sockaddr_in address; + memset(&address, 0, sizeof(address)); + address.sin_len = sizeof(address); + address.sin_family = AF_INET; + address.sin_port = htons(port); + address.sin_addr.s_addr = INADDR_ANY; + + // will fail if port is in use. + CFSocketError socketErr = CFSocketSetAddress(_socket, (CFDataRef)[NSData dataWithBytes:&address length:sizeof(address)]); + if (socketErr != kCFSocketSuccess) { + NSLog(@"Socket error: %@", [NSString stringWithUTF8String:strerror(errno)]); + return nil; + } + + _connections = [[NSMutableArray alloc] init]; + _workingDirectory = workingDirectory; + + CFRunLoopSourceRef source = CFSocketCreateRunLoopSource(NULL, _socket, 0); + assert(source != NULL); + CFRunLoopAddSource(CFRunLoopGetCurrent(), source, kCFRunLoopDefaultMode); + CFRelease(source); + + return self; +} + +- (void)connectionDidClose:(SUTestWebServerConnection *)sender { + assert(_connections != nil); + assert([_connections containsObject:sender]); + [_connections removeObject:sender]; +} + +- (void)accept:(CFSocketNativeHandle)address { + SUTestWebServerConnection *conn = [[SUTestWebServerConnection alloc] initWithNativeHandle:address workingDirectory:_workingDirectory delegate:self]; + assert(conn != nil); + if (conn) { + [_connections addObject:conn]; + } +} + +- (void)close { + for (SUTestWebServerConnection *conn in _connections) { + [conn close]; + } + if (_socket) { + CFSocketInvalidate(_socket); + CFRelease(_socket); + _socket = NULL; + } +} + +@end + +#pragma clang diagnostic pop From ff342f1e5b908cc14abc567c75243503466defd1 Mon Sep 17 00:00:00 2001 From: Kevin Wojniak Date: Fri, 9 Oct 2015 09:22:20 -0700 Subject: [PATCH 47/87] Use nil instead of 0. Fix pointer style. --- TestApplication/SUTestWebServer.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/TestApplication/SUTestWebServer.m b/TestApplication/SUTestWebServer.m index f3cd6189..ac08a930 100644 --- a/TestApplication/SUTestWebServer.m +++ b/TestApplication/SUTestWebServer.m @@ -138,7 +138,7 @@ assert(_dataToWrite != nil); if (_numBytesToWrite == 0) { // nothing more to write, we're done. - _dataToWrite = 0; + _dataToWrite = nil; _numBytesToWrite = -1; } else if (_outputStream.hasSpaceAvailable) { [self writeNow]; @@ -165,7 +165,7 @@ @interface SUTestWebServer () { NSMutableArray *_connections; - NSString* _workingDirectory; + NSString *_workingDirectory; CFSocketRef _socket; } From 948eccb1694d27fb62801e668ad90a02186ae0e8 Mon Sep 17 00:00:00 2001 From: Kevin Wojniak Date: Fri, 9 Oct 2015 09:37:25 -0700 Subject: [PATCH 48/87] Use properties to avoid having to disable warning for entire file --- TestApplication/SUTestWebServer.m | 114 +++++++++++++++++------------- 1 file changed, 65 insertions(+), 49 deletions(-) diff --git a/TestApplication/SUTestWebServer.m b/TestApplication/SUTestWebServer.m index ac08a930..d8093272 100644 --- a/TestApplication/SUTestWebServer.m +++ b/TestApplication/SUTestWebServer.m @@ -10,9 +10,6 @@ #import #import -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdirect-ivar-access" - @class SUTestWebServerConnection; @protocol SUTestWebServerConnectionDelegate @@ -22,16 +19,23 @@ @interface SUTestWebServerConnection : NSObject +@property (nonatomic) NSString* workingDirectory; +@property (nonatomic, weak) id delegate; +@property (nonatomic) NSInputStream *inputStream; +@property (nonatomic) NSOutputStream *outputStream; +@property (nonatomic) NSData *dataToWrite; +@property (nonatomic) NSInteger numBytesToWrite; + @end -@implementation SUTestWebServerConnection { - NSString *_workingDirectory; - id _delegate; - NSInputStream *_inputStream; - NSOutputStream *_outputStream; - NSData *_dataToWrite; - NSInteger _numBytesToWrite; -} +@implementation SUTestWebServerConnection + +@synthesize workingDirectory = _workingDirectory; +@synthesize delegate = _delegate; +@synthesize inputStream = _inputStream; +@synthesize outputStream = _outputStream; +@synthesize dataToWrite = _dataToWrite; +@synthesize numBytesToWrite = _numBytesToWrite; - (instancetype)initWithNativeHandle:(CFSocketNativeHandle)handle workingDirectory:(NSString*)workingDirectory delegate:(id)delegate { self = [super init]; @@ -63,17 +67,19 @@ } - (void)close { - if (!_inputStream) { - assert(_outputStream == nil); + NSInputStream *inputStream = self.inputStream; + NSOutputStream *outputStream = self.outputStream; + if (inputStream == nil) { + assert(outputStream == nil); return; } - [_inputStream close]; - [_outputStream close]; - [_inputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; - [_outputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; - _inputStream = nil; - _outputStream = nil; - [_delegate connectionDidClose:self]; + [inputStream close]; + [outputStream close]; + [inputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + [outputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; + self.inputStream = nil; + self.outputStream = nil; + [self.delegate connectionDidClose:self]; } - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode { @@ -81,9 +87,9 @@ [self close]; return; } - if (aStream == _inputStream && eventCode == NSStreamEventHasBytesAvailable) { + if (aStream == self.inputStream && eventCode == NSStreamEventHasBytesAvailable) { uint8_t buffer[8096]; - const NSInteger numBytes = [_inputStream read:buffer maxLength:sizeof(buffer)]; + const NSInteger numBytes = [self.inputStream read:buffer maxLength:sizeof(buffer)]; if (numBytes > 0) { NSString *request = [[NSString alloc] initWithBytes:buffer length:(NSUInteger)numBytes encoding:NSUTF8StringEncoding]; NSArray *lines = [request componentsSeparatedByString:@"\r\n"]; @@ -93,7 +99,7 @@ if ([parts[0] isEqualToString:@"GET"]) { // Use NSURL to strip out query parameters NSString *path = [NSURL URLWithString:parts[1] relativeToURL:nil].path; - NSString *filePath = [_workingDirectory stringByAppendingString:path]; + NSString *filePath = [self.workingDirectory stringByAppendingString:path]; BOOL isDir = NO; if (![[NSFileManager defaultManager] fileExistsAtPath:filePath isDirectory:&isDir] || isDir) { NSLog(@"%@ - 404", requestLine); @@ -107,7 +113,7 @@ [self write404]; } } - } else if (aStream == _outputStream && eventCode == NSStreamEventHasSpaceAvailable && _dataToWrite) { + } else if (aStream == self.outputStream && eventCode == NSStreamEventHasSpaceAvailable && self.dataToWrite != nil) { [self checkIfCanWriteNow]; } } @@ -126,35 +132,36 @@ } - (void)queueWrite:(NSData*)data { - assert(_dataToWrite == nil); + assert(self.dataToWrite == nil); assert(data != nil); assert(data.length > 0); - _dataToWrite = data; - _numBytesToWrite = (NSInteger)data.length; + self.dataToWrite = data; + self.numBytesToWrite = (NSInteger)data.length; [self checkIfCanWriteNow]; } - (void)checkIfCanWriteNow { - assert(_dataToWrite != nil); - if (_numBytesToWrite == 0) { + assert(self.dataToWrite != nil); + if (self.numBytesToWrite == 0) { // nothing more to write, we're done. - _dataToWrite = nil; - _numBytesToWrite = -1; - } else if (_outputStream.hasSpaceAvailable) { + self.dataToWrite = nil; + self.numBytesToWrite = -1; + } else if (self.outputStream.hasSpaceAvailable) { [self writeNow]; } // otherwise wait for space available event } - (void)writeNow { - assert(_outputStream != nil); - assert(_outputStream.hasSpaceAvailable); - assert(_dataToWrite != nil); - const uint8_t *bytesOffset = (const uint8_t*)_dataToWrite.bytes + ((NSInteger)_dataToWrite.length - _numBytesToWrite); - const NSInteger bytesWritten = [_outputStream write:bytesOffset maxLength:(NSUInteger)_numBytesToWrite]; + assert(self.outputStream != nil); + assert(self.outputStream.hasSpaceAvailable); + assert(self.dataToWrite != nil); + NSData *dataToWrite = self.dataToWrite; + const uint8_t *bytesOffset = (const uint8_t*)dataToWrite.bytes + ((NSInteger)dataToWrite.length - self.numBytesToWrite); + const NSInteger bytesWritten = [self.outputStream write:bytesOffset maxLength:(NSUInteger)self.numBytesToWrite]; if (bytesWritten > 0) { - _numBytesToWrite -= bytesWritten; - assert(_numBytesToWrite >= 0); + self.numBytesToWrite = self.numBytesToWrite - bytesWritten; + assert(self.numBytesToWrite >= 0); // wait for next space available event to write more } else { NSLog(@"Error: bytes written = %ld (%@)", bytesWritten, [NSString stringWithUTF8String:strerror(errno)]); @@ -164,24 +171,31 @@ @end @interface SUTestWebServer () { - NSMutableArray *_connections; - NSString *_workingDirectory; CFSocketRef _socket; } +@property (nonatomic) NSMutableArray *connections; +@property (nonatomic) NSString *workingDirectory; + - (void)accept:(CFSocketNativeHandle)address; @end static void connectCallback(CFSocketRef __unused s, CFSocketCallBackType type, CFDataRef __unused address, const void *data, void *info) { if (type == kCFSocketAcceptCallBack) { + assert(data != NULL); + assert(info != NULL); SUTestWebServer *server = (__bridge SUTestWebServer*)info; + assert(server != nil); [server accept:*(const CFSocketNativeHandle*)data]; } } @implementation SUTestWebServer +@synthesize connections = _connections; +@synthesize workingDirectory = _workingDirectory; + - (instancetype)initWithPort:(int)port workingDirectory:(NSString*)workingDirectory { self = [super init]; assert(self != nil); @@ -218,30 +232,32 @@ static void connectCallback(CFSocketRef __unused s, CFSocketCallBackType type, C } - (void)connectionDidClose:(SUTestWebServerConnection *)sender { - assert(_connections != nil); - assert([_connections containsObject:sender]); - [_connections removeObject:sender]; + assert(self.connections != nil); + assert([self.connections containsObject:sender]); + [self.connections removeObject:sender]; } - (void)accept:(CFSocketNativeHandle)address { - SUTestWebServerConnection *conn = [[SUTestWebServerConnection alloc] initWithNativeHandle:address workingDirectory:_workingDirectory delegate:self]; + SUTestWebServerConnection *conn = [[SUTestWebServerConnection alloc] initWithNativeHandle:address workingDirectory:self.workingDirectory delegate:self]; assert(conn != nil); if (conn) { - [_connections addObject:conn]; + assert(self.connections != nil); + [self.connections addObject:conn]; } } - (void)close { - for (SUTestWebServerConnection *conn in _connections) { + for (SUTestWebServerConnection *conn in self.connections) { [conn close]; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdirect-ivar-access" if (_socket) { CFSocketInvalidate(_socket); CFRelease(_socket); _socket = NULL; } +#pragma clang diagnostic pop } @end - -#pragma clang diagnostic pop From 9b74309eb588191ebde44bce1b8583badf0f5dc4 Mon Sep 17 00:00:00 2001 From: Zorg Date: Fri, 9 Oct 2015 17:49:46 -0400 Subject: [PATCH 49/87] Make allowsAuthorization apply to all of SUFileManager's methods --- Sparkle/SUBasicUpdateDriver.m | 2 +- Sparkle/SUFileManager.h | 17 +++++++++++------ Sparkle/SUFileManager.m | 28 +++++++++++++--------------- Sparkle/SUPlainInstaller.m | 2 +- Tests/SUFileManagerTest.swift | 18 ++++++++++++------ 5 files changed, 38 insertions(+), 29 deletions(-) diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 4e19024f..1a01436f 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -461,7 +461,7 @@ // We probably don't need to release the quarantine, but we'll do it just in case it's necessary. // Perhaps in a sandboxed environment this matters more. Note that this may not be a fatal error. NSError *quarantineError = nil; - if (![[[SUFileManager alloc] init] releaseItemFromQuarantineWithoutAuthenticationAtRootURL:[NSURL fileURLWithPath:targetPath] error:&quarantineError]) { + if (![[[SUFileManager alloc] initAllowingAuthorization:NO] releaseItemFromQuarantineAtRootURL:[NSURL fileURLWithPath:targetPath] error:&quarantineError]) { SULog(@"Failed to release quarantine on %@ with error %@", targetPath, quarantineError); } self.relaunchPath = targetPath; diff --git a/Sparkle/SUFileManager.h b/Sparkle/SUFileManager.h index 1a362808..5a390d89 100644 --- a/Sparkle/SUFileManager.h +++ b/Sparkle/SUFileManager.h @@ -9,12 +9,22 @@ #import /** - * A class used for performing file operations that may also perform authentication if permission is denied when trying to + * A class used for performing file operations that may also perform authentication if allowed and if permission is denied when trying to * perform them normally as the running user. All operations on this class may be used on thread other than the main thread. * This class provides basic file operations and stays away from including much application-level logic. */ @interface SUFileManager : NSObject +/** + * Initializes a file manager + * @param allowsAuthorization Specifies whether operations invoked on this instance are allowed to acquire authorization in order + * to perform file operations when read or write access is denied + * @return A new file manager instance + * + * This method just initializes the file manager. It doesn't acquire authorization immediately if allowsAuthorization is YES + */ +- (id)initAllowingAuthorization:(BOOL)allowsAuthorization; + /** * 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 uncommon case this name is used, the temporary directory will be created inside the directory pointed by appropriateURL @@ -110,9 +120,4 @@ */ - (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError **)error; -/** - * Behaves as -releaseItemFromQuarantineAtRootURL:error: does, except without the capability of authenticating when permission is denied - */ -- (BOOL)releaseItemFromQuarantineWithoutAuthenticationAtRootURL:(NSURL *)rootURL error:(NSError **)error; - @end diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 2d4e3ba4..db25a782 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -52,13 +52,15 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza { AuthorizationRef _auth; NSFileManager *_fileManager; + BOOL _allowsAuthorization; } -- (id)init +- (id)initAllowingAuthorization:(BOOL)allowsAuthorization { self = [super init]; if (self != nil) { _fileManager = [[NSFileManager alloc] init]; + _allowsAuthorization = allowsAuthorization; } return self; } @@ -71,6 +73,13 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return YES; } + if (!_allowsAuthorization) { + 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; + } + OSStatus status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &_auth); if (status != errAuthorizationSuccess) { if (error != NULL) { @@ -177,7 +186,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return success; } -- (BOOL)_releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL allowingAuthentication:(BOOL)allowsAuthentication 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 isAccessError:(BOOL (^)(NSError *))isAccessError error:(NSError * __autoreleasing *)error { if (![self _itemExistsAtURL:rootURL]) { if (error != NULL) { @@ -195,7 +204,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza if (quarantineRemoval(fileURL, &removalError)) { removedQuarantine = YES; } else { - if (allowsAuthentication && isAccessError(removalError)) { + if (isAccessError(removalError)) { removedQuarantine = [self _removeXAttrWithAuthentication:SUAppleQuarantineIdentifier fromRootURL:rootURL error:error]; attemptedAuthentication = YES; } else { @@ -269,14 +278,13 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza // We used to have code similar to the method below that used -[NSURL getResourceValue:forKey:error:] and -[NSURL setResourceValue:forKey:error:] // However, those methods *really suck* - you can't rely on the return value from getting the resource value and if you set the resource value // when the key isn't present, errors are spewed out to the console -- (BOOL)_releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL allowingAuthentication:(BOOL)allowsAuthentication error:(NSError *__autoreleasing *)error +- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError *__autoreleasing *)error { static const int removeXAttrOptions = XATTR_NOFOLLOW; return [self _releaseItemFromQuarantineAtRootURL:rootURL - allowingAuthentication:allowsAuthentication withQuarantineRetrieval:^BOOL(NSURL *fileURL) { return ([self _getXAttr:SUAppleQuarantineIdentifier fromFile:fileURL.path options:removeXAttrOptions] >= 0); } @@ -293,16 +301,6 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza error:error]; } -- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError * __autoreleasing *)error -{ - return [self _releaseItemFromQuarantineAtRootURL:rootURL allowingAuthentication:YES error:error]; -} - -- (BOOL)releaseItemFromQuarantineWithoutAuthenticationAtRootURL:(NSURL *)rootURL error:(NSError * __autoreleasing *)error -{ - return [self _releaseItemFromQuarantineAtRootURL:rootURL allowingAuthentication:NO error:error]; -} - - (BOOL)moveItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError *__autoreleasing *)error { if (![self _itemExistsAtURL:sourceURL]) { diff --git a/Sparkle/SUPlainInstaller.m b/Sparkle/SUPlainInstaller.m index a8a90a1f..e6a922b7 100644 --- a/Sparkle/SUPlainInstaller.m +++ b/Sparkle/SUPlainInstaller.m @@ -42,7 +42,7 @@ return NO; } - SUFileManager *fileManager = [[SUFileManager alloc] init]; + SUFileManager *fileManager = [[SUFileManager alloc] initAllowingAuthorization:YES]; // Create a temporary directory for our new app that resides on our destination's volume NSURL *tempNewDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:[installationURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingString:@" (Incomplete Update)"] appropriateForDirectoryURL:installationURL.URLByDeletingLastPathComponent error:error]; diff --git a/Tests/SUFileManagerTest.swift b/Tests/SUFileManagerTest.swift index 76e66882..ecc38bd0 100644 --- a/Tests/SUFileManagerTest.swift +++ b/Tests/SUFileManagerTest.swift @@ -12,7 +12,7 @@ class SUFileManagerTest: XCTestCase { func makeTempFiles(testBlock: (SUFileManager, NSURL, NSURL, NSURL, NSURL) -> Void) { - let fileManager = SUFileManager() + let fileManager = SUFileManager(allowingAuthorization: false) let tempDirectoryURL = try! fileManager.makeTemporaryDirectoryWithPreferredName("Sparkle Unit Test Data", appropriateForDirectoryURL: NSURL(fileURLWithPath: NSHomeDirectory())) @@ -95,8 +95,8 @@ class SUFileManagerTest: XCTestCase func testReleaseFilesFromQuarantine() { makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL in - try! fileManager.releaseItemFromQuarantineWithoutAuthenticationAtRootURL(ordinaryFileURL) - try! fileManager.releaseItemFromQuarantineWithoutAuthenticationAtRootURL(directoryURL) + try! fileManager.releaseItemFromQuarantineAtRootURL(ordinaryFileURL) + try! fileManager.releaseItemFromQuarantineAtRootURL(directoryURL) let quarantineData = "does not really matter what is here".cStringUsingEncoding(NSUTF8StringEncoding)! let quarantineDataLength = Int(strlen(quarantineData)) @@ -104,7 +104,7 @@ class SUFileManagerTest: XCTestCase XCTAssertEqual(0, setxattr(ordinaryFileURL.path!, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE)) XCTAssertGreaterThan(getxattr(ordinaryFileURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0) - try! fileManager.releaseItemFromQuarantineWithoutAuthenticationAtRootURL(ordinaryFileURL) + try! fileManager.releaseItemFromQuarantineAtRootURL(ordinaryFileURL) XCTAssertEqual(-1, getxattr(ordinaryFileURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW)) XCTAssertEqual(0, setxattr(directoryURL.path!, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE)) @@ -113,7 +113,7 @@ class SUFileManagerTest: XCTestCase XCTAssertEqual(0, setxattr(fileInDirectoryURL.path!, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE)) XCTAssertGreaterThan(getxattr(fileInDirectoryURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0) - try! fileManager.releaseItemFromQuarantineWithoutAuthenticationAtRootURL(directoryURL) + try! fileManager.releaseItemFromQuarantineAtRootURL(directoryURL) XCTAssertEqual(-1, getxattr(directoryURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW)) XCTAssertEqual(-1, getxattr(fileInDirectoryURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW)) @@ -244,7 +244,13 @@ class SUFileManagerTest: XCTestCase // This alone shouldn't prompt a password dialog and should always succeed func testAcquireAuthorization() { - let fileManager = SUFileManager() + let fileManager = SUFileManager(allowingAuthorization: true) try! fileManager._acquireAuthorization() } + + func testAcquireBadAuthorization() + { + let fileManager = SUFileManager(allowingAuthorization: false) + XCTAssertNil(try? fileManager._acquireAuthorization()) + } } From ee72ec3dab88b09dd9281d5d63245c876c0a2c01 Mon Sep 17 00:00:00 2001 From: Zorg Date: Fri, 9 Oct 2015 23:58:23 -0400 Subject: [PATCH 50/87] Fix issues with copying files from different mounted drives The move operation now does an explict copy & remove. We also copy items using FSCopyObjectSync due to issues existing in copyfile (and NSFileManager). Both of these fix bugs in some cases where items cannot be moved from one network drive to another. In my testing before this patch, I was unable to get the test application to launch and was unable to move the old installation to the trash. --- Sparkle/SUBasicUpdateDriver.m | 9 +- Sparkle/SUFileManager.h | 11 ++ Sparkle/SUFileManager.m | 154 ++++++++++++++++++++ TestApplication/SUTestApplicationDelegate.m | 11 +- Tests/SUFileManagerTest.swift | 20 +++ 5 files changed, 197 insertions(+), 8 deletions(-) diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 1a01436f..2b52ea8a 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -452,16 +452,19 @@ if (relaunchPathToCopy != nil) { NSString *targetPath = [self.host.appCachePath stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]]; - NSFileManager *fileManager = [[NSFileManager alloc] init]; + SUFileManager *fileManager = [[SUFileManager alloc] initAllowingAuthorization:NO]; NSError *error = nil; + NSURL *relaunchURLToCopy = [NSURL fileURLWithPath:relaunchPathToCopy]; + NSURL *targetURL = [NSURL fileURLWithPath:targetPath]; + // We only need to run our copy of the app by spawning a task // Since we are copying the app to a directory that is write-accessible, we don't need to muck with owner/group IDs - if ([self preparePathForRelaunchTool:targetPath error:&error] && [fileManager copyItemAtPath:relaunchPathToCopy toPath:targetPath error:&error]) { + if ([self preparePathForRelaunchTool:targetPath error:&error] && [fileManager copyItemAtURL:relaunchURLToCopy toURL:targetURL error:&error]) { // We probably don't need to release the quarantine, but we'll do it just in case it's necessary. // Perhaps in a sandboxed environment this matters more. Note that this may not be a fatal error. NSError *quarantineError = nil; - if (![[[SUFileManager alloc] initAllowingAuthorization:NO] releaseItemFromQuarantineAtRootURL:[NSURL fileURLWithPath:targetPath] error:&quarantineError]) { + if (![fileManager releaseItemFromQuarantineAtRootURL:targetURL error:&quarantineError]) { SULog(@"Failed to release quarantine on %@ with error %@", targetPath, quarantineError); } self.relaunchPath = targetPath; diff --git a/Sparkle/SUFileManager.h b/Sparkle/SUFileManager.h index 5a390d89..7dde8cab 100644 --- a/Sparkle/SUFileManager.h +++ b/Sparkle/SUFileManager.h @@ -49,6 +49,17 @@ */ - (BOOL)moveItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError **)error; +/** + * Copies an item from a source to a destination + * @param sourceURL A URL pointing to the item to move. The item at this URL must exist. + * @param destinationURL A URL pointing to the destination the item will be moved at. An item must not already exist at this URL. + * @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. + * @return YES if the item was copied successfully, otherwise NO along with a populated error object + * + * This is not an atomic operation. + */ +- (BOOL)copyItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError **)error; + /** * Moves an item at a specified URL to the running user's trash directory * @param url A URL pointing to the item to move to the trash. The item at this URL must exist. diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index db25a782..3a57f827 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -301,6 +301,145 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza error:error]; } +/* + * Copies an item from one location to another + * This intentionally does *not* use copyfile() or any API that uses it such as NSFileManager's copy item method + * This is because copyfile() fails to copy symbolic links from one network mount to another, which will affect copying apps + * This failure has been reproduced on 10.11.0 and a VM running 10.8, so the issue has existed for a while. + * For more info, see the bug report at http://openradar.appspot.com/radar?id=4925873463492608 + */ +- (BOOL)copyItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError * __autoreleasing *)error +{ + if (![self _itemExistsAtURL:sourceURL]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source file to copy (%@) does not exist.", sourceURL.lastPathComponent] }]; + } + return NO; + } + + if ([self _itemExistsAtURL:destinationURL]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination file to copy to (%@) already exists.", destinationURL.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:@"File to copy (%@) cannot be represented as a valid file name.", sourceURL.lastPathComponent] }]; + } + return NO; + } + + FSRef sourceRef; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + OSStatus makeSourceResult = FSPathMakeRefWithOptions((const UInt8 *)sourcePath, kFSPathMakeRefDoNotFollowLeafSymlink, &sourceRef, NULL); +#pragma clang diagnostic pop + if (makeSourceResult != noErr) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:makeSourceResult userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create file system reference for source %@.", sourceURL.lastPathComponent] }]; + } + return NO; + } + + char destinationParentPath[PATH_MAX] = {0}; + if (![destinationURL.URLByDeletingLastPathComponent.path getFileSystemRepresentation:destinationParentPath maxLength:sizeof(destinationParentPath)]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination parent directory to copy file into (%@) cannot be represented as a valid file name.", destinationURL.URLByDeletingLastPathComponent.lastPathComponent] }]; + } + return NO; + } + + FSRef destinationParentRef; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + OSStatus makeDestinationParentResult = FSPathMakeRefWithOptions((const UInt8 *)destinationParentPath, kFSPathMakeRefDoNotFollowLeafSymlink, &destinationParentRef, NULL); +#pragma clang diagnostic pop + if (makeDestinationParentResult != noErr) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:makeDestinationParentResult userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to create file system reference for parent directory %@.", destinationURL.URLByDeletingLastPathComponent.lastPathComponent] }]; + } + return NO; + } + +#pragma clang diagnostic push +#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; + } + + if (copyResult != permErr) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:copyResult userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to copy file (%@)", sourceURL.lastPathComponent] }]; + } + return NO; + } + + if (![self _acquireAuthorizationWithError:error]) { + 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; + } + + if (!AuthorizationExecuteWithPrivilegesAndWait(_auth, "/bin/cp", kAuthorizationFlagDefaults, (char *[]){ "-Rf", sourcePath, destinationPath, NULL })) { + if (error != NULL) { + NSString *errorMessage = [NSString stringWithFormat:@"Failed to perform authenticated file copy for %@.", sourceURL.lastPathComponent]; + *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:errorMessage }]; + } + return NO; + } + + return YES; +} + +/* + * Retrieves the volume ID that a particular url resides on + * The url must point to a file that exists + * There is no cocoa equivalent for obtaining the volume ID + * Although NSURLVolumeURLForRemountingKey exists as a resource key for NSURL, + * that will not return a URL if the mount is not re-mountable and I otherwise don't trust the API + */ +- (BOOL)_getVolumeID:(FSVolumeRefNum *)volumeID ofItemAtURL:(NSURL *)url +{ + char path[PATH_MAX] = {0}; + if (![url.path getFileSystemRepresentation:path maxLength:sizeof(path)]) { + return NO; + } + + FSRef pathRef; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + if (FSPathMakeRefWithOptions((const UInt8*)path, kFSPathMakeRefDoNotFollowLeafSymlink, &pathRef, NULL) != noErr) { +#pragma clang diagnostic pop + return NO; + } + + FSCatalogInfo catalogInfo; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + OSErr catalogError = FSGetCatalogInfo(&pathRef, kFSCatInfoVolume, &catalogInfo, NULL, NULL, NULL); +#pragma clang diagnostic pop + if (catalogError != noErr) { + return NO; + } + + if (volumeID != NULL) { + *volumeID = catalogInfo.volume; + } + + return YES; +} + - (BOOL)moveItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError *__autoreleasing *)error { if (![self _itemExistsAtURL:sourceURL]) { @@ -317,6 +456,21 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return NO; } + // If the source and destination are on different volumes, we should not do a move; + // from my experience a move may fail when moving particular files from + // one network mount to another one. This is possibly related to the fact that + // moving a file will try to preserve ownership but copying won't + + FSVolumeRefNum sourceVolume = 0; + BOOL foundSourceVolume = [self _getVolumeID:&sourceVolume ofItemAtURL:sourceURL]; + + FSVolumeRefNum destinationVolume = 0; + BOOL foundDestinationVolume = [self _getVolumeID:&destinationVolume ofItemAtURL:destinationURL.URLByDeletingLastPathComponent]; + + 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; diff --git a/TestApplication/SUTestApplicationDelegate.m b/TestApplication/SUTestApplicationDelegate.m index 9296073f..a4c83e16 100644 --- a/TestApplication/SUTestApplicationDelegate.m +++ b/TestApplication/SUTestApplicationDelegate.m @@ -8,6 +8,7 @@ #import "SUTestApplicationDelegate.h" #import "SUUpdateSettingsWindowController.h" +#import "SUFileManager.h" @interface SUTestApplicationDelegate () @@ -37,11 +38,11 @@ static NSString * const UPDATED_VERSION = @"2.0"; [[NSApplication sharedApplication] terminate:nil]; } - NSFileManager *fileManager = [NSFileManager defaultManager]; + SUFileManager *fileManager = [[SUFileManager alloc] initAllowingAuthorization:NO]; // Locate user's cache directory NSError *cacheError = nil; - NSURL *cacheDirectoryURL = [fileManager URLForDirectory:NSCachesDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:&cacheError]; + NSURL *cacheDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSCachesDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:&cacheError]; if (cacheDirectoryURL == nil) { NSLog(@"Failed to locate cache directory with error: %@", cacheError); @@ -62,7 +63,7 @@ static NSString * const UPDATED_VERSION = @"2.0"; } NSError *createDirectoryError = nil; - if (![fileManager createDirectoryAtURL:serverDirectoryURL withIntermediateDirectories:YES attributes:nil error:&createDirectoryError]) { + if (![[NSFileManager defaultManager] createDirectoryAtURL:serverDirectoryURL withIntermediateDirectories:YES attributes:nil error:&createDirectoryError]) { NSLog(@"Failed creating directory at %@ with error %@", serverDirectoryURL.path, createDirectoryError); assert(NO); } @@ -137,7 +138,7 @@ static NSString * const UPDATED_VERSION = @"2.0"; // Obtain the file attributes to get the file size of our update later NSError *fileAttributesError = nil; - NSDictionary *archiveFileAttributes = [fileManager attributesOfItemAtPath:archiveURL.path error:&fileAttributesError]; + NSDictionary *archiveFileAttributes = [[NSFileManager defaultManager] attributesOfItemAtPath:archiveURL.path error:&fileAttributesError]; if (archiveFileAttributes == nil) { NSLog(@"Failed to retrieve file attributes from archive with error %@", fileAttributesError); assert(NO); @@ -178,7 +179,7 @@ static NSString * const UPDATED_VERSION = @"2.0"; // Finally start the server NSTask *serverTask = [[NSTask alloc] init]; serverTask.launchPath = @"/usr/bin/python"; - assert([fileManager fileExistsAtPath:serverTask.launchPath]); + assert([[NSFileManager defaultManager] fileExistsAtPath:serverTask.launchPath]); serverTask.arguments = @[@"-m", @"SimpleHTTPServer", @"1337"]; serverTask.currentDirectoryPath = serverDirectoryPath; [serverTask launch]; diff --git a/Tests/SUFileManagerTest.swift b/Tests/SUFileManagerTest.swift index ecc38bd0..75553278 100644 --- a/Tests/SUFileManagerTest.swift +++ b/Tests/SUFileManagerTest.swift @@ -77,6 +77,26 @@ class SUFileManagerTest: XCTestCase try! fileManager.removeItemAtURL(directoryTrashURL) } } + + func testCopyFiles() + { + makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL in + XCTAssertNil(try? fileManager.copyItemAtURL(ordinaryFileURL, toURL: directoryURL)) + XCTAssertNil(try? fileManager.copyItemAtURL(rootURL.URLByAppendingPathComponent("does not exist"), toURL: directoryURL)) + + let newFileURL = (ordinaryFileURL.URLByDeletingLastPathComponent?.URLByAppendingPathComponent("new file"))! + try! fileManager.copyItemAtURL(ordinaryFileURL, toURL: newFileURL) + XCTAssertTrue(fileManager._itemExistsAtURL(ordinaryFileURL)) + XCTAssertTrue(fileManager._itemExistsAtURL(newFileURL)) + + let newDirectoryURL = (ordinaryFileURL.URLByDeletingLastPathComponent?.URLByAppendingPathComponent("new directory"))! + try! fileManager.copyItemAtURL(directoryURL, toURL: newDirectoryURL) + XCTAssertTrue(fileManager._itemExistsAtURL(directoryURL)) + XCTAssertTrue(fileManager._itemExistsAtURL(newDirectoryURL)) + XCTAssertTrue(fileManager._itemExistsAtURL(fileInDirectoryURL)) + XCTAssertTrue(fileManager._itemExistsAtURL(newDirectoryURL.URLByAppendingPathComponent(fileInDirectoryURL.lastPathComponent!))) + } + } func testRemoveFiles() { From 6818d1f180b23b4d9fbe74e7b533e94ff67d0515 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 10 Oct 2015 00:12:58 -0400 Subject: [PATCH 51/87] Verify existence of destination parent directory for moving/copying --- Sparkle/SUFileManager.m | 18 ++++++++++++++++-- Tests/SUFileManagerTest.swift | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 3a57f827..cbbb8121 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -317,6 +317,13 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return NO; } + if (![self _itemExistsAtURL:destinationURL.URLByDeletingLastPathComponent]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination parent directory to copy into (%@) does not exist.", destinationURL.URLByDeletingLastPathComponent.lastPathComponent] }]; + } + return NO; + } + if ([self _itemExistsAtURL:destinationURL]) { if (error != NULL) { *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination file to copy to (%@) already exists.", destinationURL.lastPathComponent] }]; @@ -444,14 +451,21 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza { if (![self _itemExistsAtURL:sourceURL]) { if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source file to move (%@) does not exist.", sourceURL.path.lastPathComponent] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Source file to move (%@) does not exist.", sourceURL.lastPathComponent] }]; + } + return NO; + } + + if (![self _itemExistsAtURL:destinationURL.URLByDeletingLastPathComponent]) { + if (error != NULL) { + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination parent directory to move into (%@) does not exist.", destinationURL.URLByDeletingLastPathComponent.lastPathComponent] }]; } return NO; } if ([self _itemExistsAtURL:destinationURL]) { if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination file to move (%@) already exists.", destinationURL.path.lastPathComponent] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination file to move (%@) already exists.", destinationURL.lastPathComponent] }]; } return NO; } diff --git a/Tests/SUFileManagerTest.swift b/Tests/SUFileManagerTest.swift index 75553278..260ff2f1 100644 --- a/Tests/SUFileManagerTest.swift +++ b/Tests/SUFileManagerTest.swift @@ -36,6 +36,7 @@ class SUFileManagerTest: XCTestCase { makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL in XCTAssertNil(try? fileManager.moveItemAtURL(ordinaryFileURL, toURL: directoryURL)) + XCTAssertNil(try? fileManager.moveItemAtURL(ordinaryFileURL, toURL: directoryURL.URLByAppendingPathComponent("foo").URLByAppendingPathComponent("bar"))) XCTAssertNil(try? fileManager.moveItemAtURL(rootURL.URLByAppendingPathComponent("does not exist"), toURL: directoryURL)) let newFileURL = (ordinaryFileURL.URLByDeletingLastPathComponent?.URLByAppendingPathComponent("new file"))! @@ -82,6 +83,7 @@ class SUFileManagerTest: XCTestCase { makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL in XCTAssertNil(try? fileManager.copyItemAtURL(ordinaryFileURL, toURL: directoryURL)) + XCTAssertNil(try? fileManager.copyItemAtURL(ordinaryFileURL, toURL: directoryURL.URLByAppendingPathComponent("foo").URLByAppendingPathComponent("bar"))) XCTAssertNil(try? fileManager.copyItemAtURL(rootURL.URLByAppendingPathComponent("does not exist"), toURL: directoryURL)) let newFileURL = (ordinaryFileURL.URLByDeletingLastPathComponent?.URLByAppendingPathComponent("new file"))! From 9d06f5bc4d54f9ccb0af238a306759a7549c56ff Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 10 Oct 2015 00:28:12 -0400 Subject: [PATCH 52/87] Meant to use NSFileNoSuchFileError here --- Sparkle/SUFileManager.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index cbbb8121..243e0f5b 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -319,7 +319,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza if (![self _itemExistsAtURL:destinationURL.URLByDeletingLastPathComponent]) { if (error != NULL) { - *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileWriteFileExistsError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination parent directory to copy into (%@) does not exist.", destinationURL.URLByDeletingLastPathComponent.lastPathComponent] }]; + *error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Destination parent directory to copy into (%@) does not exist.", destinationURL.URLByDeletingLastPathComponent.lastPathComponent] }]; } return NO; } From 3c957096c64de93c93c9c49e7ebd3bbe254ee2a8 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 10 Oct 2015 17:42:27 -0400 Subject: [PATCH 53/87] Use class constructor instead of an init method for SUFileManager I think it's more natural this way --- Sparkle/SUBasicUpdateDriver.m | 2 +- Sparkle/SUFileManager.h | 6 +++--- Sparkle/SUFileManager.m | 8 +++++++- Sparkle/SUPlainInstaller.m | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 2b52ea8a..173ce204 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -452,7 +452,7 @@ if (relaunchPathToCopy != nil) { NSString *targetPath = [self.host.appCachePath stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]]; - SUFileManager *fileManager = [[SUFileManager alloc] initAllowingAuthorization:NO]; + SUFileManager *fileManager = [SUFileManager fileManagerAllowingAuthorization:NO]; NSError *error = nil; NSURL *relaunchURLToCopy = [NSURL fileURLWithPath:relaunchPathToCopy]; diff --git a/Sparkle/SUFileManager.h b/Sparkle/SUFileManager.h index 7dde8cab..f6897ced 100644 --- a/Sparkle/SUFileManager.h +++ b/Sparkle/SUFileManager.h @@ -16,14 +16,14 @@ @interface SUFileManager : NSObject /** - * Initializes a file manager + * Creates a file manager that allows or disallows authorizing for file operations * @param allowsAuthorization Specifies whether operations invoked on this instance are allowed to acquire authorization in order * to perform file operations when read or write access is denied * @return A new file manager instance * - * This method just initializes the file manager. It doesn't acquire authorization immediately if allowsAuthorization is YES + * This method just creates the file manager. It doesn't acquire authorization immediately if allowsAuthorization is YES */ -- (id)initAllowingAuthorization:(BOOL)allowsAuthorization; ++ (instancetype)fileManagerAllowingAuthorization:(BOOL)allowsAuthorization; /** * Creates a temporary directory on the same volume as a provided URL diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 243e0f5b..fa36a997 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -55,7 +55,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza BOOL _allowsAuthorization; } -- (id)initAllowingAuthorization:(BOOL)allowsAuthorization +- (instancetype)initAllowingAuthorization:(BOOL)allowsAuthorization { self = [super init]; if (self != nil) { @@ -65,6 +65,12 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza return self; } + ++ (instancetype)fileManagerAllowingAuthorization:(BOOL)allowsAuthorization +{ + return [[self alloc] initAllowingAuthorization:allowsAuthorization]; +} + // Acquires an authorization reference which is intended to be used for future authorized file operations - (BOOL)_acquireAuthorizationWithError:(NSError *__autoreleasing *)error { diff --git a/Sparkle/SUPlainInstaller.m b/Sparkle/SUPlainInstaller.m index e6a922b7..70a7ded9 100644 --- a/Sparkle/SUPlainInstaller.m +++ b/Sparkle/SUPlainInstaller.m @@ -42,7 +42,7 @@ return NO; } - SUFileManager *fileManager = [[SUFileManager alloc] initAllowingAuthorization:YES]; + SUFileManager *fileManager = [SUFileManager fileManagerAllowingAuthorization:YES]; // Create a temporary directory for our new app that resides on our destination's volume NSURL *tempNewDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:[installationURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingString:@" (Incomplete Update)"] appropriateForDirectoryURL:installationURL.URLByDeletingLastPathComponent error:error]; From ccf4f81ea03a6b719e8a3298e55e0ef3f37cd56d Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 10 Oct 2015 17:58:44 -0400 Subject: [PATCH 54/87] Use SUFileManager for copyTree in BinaryDelta Fixes app not being able to be patched because the original app was on a network mounted volume --- Sparkle.xcodeproj/project.pbxproj | 10 ++++++++++ Sparkle/SUBinaryDeltaCommon.m | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 189859cb..511aa939 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -170,6 +170,11 @@ 721CF1AB1AD764EB00D9AC09 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D06E8FB0FD68D61005AE3F6 /* libbz2.dylib */; }; 7223E7631AD1AEFF008E3161 /* sais.c in Sources */ = {isa = PBXBuildFile; fileRef = 7223E7611AD1AEFF008E3161 /* sais.c */; }; 7268AC631AD634C200C3E0C1 /* SUBinaryDeltaCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */; }; + 726F2CDE1BC9BE5B001971A4 /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; + 726F2CDF1BC9C093001971A4 /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; }; + 726F2CE01BC9C0EF001971A4 /* SUHost.m in Sources */ = {isa = PBXBuildFile; fileRef = 61EF67550E25B58D00F754E0 /* SUHost.m */; }; + 726F2CE11BC9C100001971A4 /* SULog.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C14F05136EF6DB00649790 /* SULog.m */; }; + 726F2CE21BC9C133001971A4 /* SUSystemProfiler.m in Sources */ = {isa = PBXBuildFile; fileRef = 61A2279B0D1CEE7600430CCD /* SUSystemProfiler.m */; }; 7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */; }; 7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; 7275F9C31B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; @@ -1473,6 +1478,11 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 726F2CE21BC9C133001971A4 /* SUSystemProfiler.m in Sources */, + 726F2CE11BC9C100001971A4 /* SULog.m in Sources */, + 726F2CE01BC9C0EF001971A4 /* SUHost.m in Sources */, + 726F2CDF1BC9C093001971A4 /* SUConstants.m in Sources */, + 726F2CDE1BC9BE5B001971A4 /* SUFileManager.m in Sources */, 5D06E8E90FD68CDB005AE3F6 /* bsdiff.c in Sources */, 14652F7E19A9728A00959E44 /* bspatch.c in Sources */, 7223E7631AD1AEFF008E3161 /* sais.c in Sources */, diff --git a/Sparkle/SUBinaryDeltaCommon.m b/Sparkle/SUBinaryDeltaCommon.m index 7395c0e6..be3966ce 100644 --- a/Sparkle/SUBinaryDeltaCommon.m +++ b/Sparkle/SUBinaryDeltaCommon.m @@ -7,6 +7,7 @@ // #include "SUBinaryDeltaCommon.h" +#import "SUFileManager.h" #include #include #include @@ -220,7 +221,7 @@ BOOL removeTree(NSString *path) BOOL copyTree(NSString *source, NSString *dest) { - return [[NSFileManager defaultManager] copyItemAtPath:source toPath:dest error:nil]; + return [[SUFileManager fileManagerAllowingAuthorization:NO] copyItemAtURL:[NSURL fileURLWithPath:source] toURL:[NSURL fileURLWithPath:dest] error:NULL]; } BOOL modifyPermissions(NSString *path, mode_t desiredPermissions) From c850146ef6b3d186aaa9914f191034a406039008 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 10 Oct 2015 18:10:24 -0400 Subject: [PATCH 55/87] Forgot to update SUFileManager constuctor in Test App --- TestApplication/SUTestApplicationDelegate.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestApplication/SUTestApplicationDelegate.m b/TestApplication/SUTestApplicationDelegate.m index a4c83e16..3c6cc82b 100644 --- a/TestApplication/SUTestApplicationDelegate.m +++ b/TestApplication/SUTestApplicationDelegate.m @@ -38,7 +38,7 @@ static NSString * const UPDATED_VERSION = @"2.0"; [[NSApplication sharedApplication] terminate:nil]; } - SUFileManager *fileManager = [[SUFileManager alloc] initAllowingAuthorization:NO]; + SUFileManager *fileManager = [SUFileManager fileManagerAllowingAuthorization:NO]; // Locate user's cache directory NSError *cacheError = nil; From 8a208ce520572bf5111d603c69812b16c2fd1028 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 10 Oct 2015 18:14:06 -0400 Subject: [PATCH 56/87] Move OS methods from SUHost to SUOperatingSystem This reduces the bloat that BinaryDelta and SUFileManager need to include --- Sparkle.xcodeproj/project.pbxproj | 22 ++++++++----- Sparkle/SUBasicUpdateDriver.m | 5 +-- Sparkle/SUFileManager.m | 4 +-- Sparkle/SUHost.h | 4 --- Sparkle/SUHost.m | 39 ----------------------- Sparkle/SUOperatingSystem.h | 16 ++++++++++ Sparkle/SUOperatingSystem.m | 51 +++++++++++++++++++++++++++++++ Sparkle/SUSystemProfiler.m | 3 +- Sparkle/SUUIBasedUpdateDriver.m | 3 +- 9 files changed, 90 insertions(+), 57 deletions(-) create mode 100644 Sparkle/SUOperatingSystem.h create mode 100644 Sparkle/SUOperatingSystem.m diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 511aa939..df84dc9f 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -171,10 +171,11 @@ 7223E7631AD1AEFF008E3161 /* sais.c in Sources */ = {isa = PBXBuildFile; fileRef = 7223E7611AD1AEFF008E3161 /* sais.c */; }; 7268AC631AD634C200C3E0C1 /* SUBinaryDeltaCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */; }; 726F2CDE1BC9BE5B001971A4 /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; - 726F2CDF1BC9C093001971A4 /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; }; - 726F2CE01BC9C0EF001971A4 /* SUHost.m in Sources */ = {isa = PBXBuildFile; fileRef = 61EF67550E25B58D00F754E0 /* SUHost.m */; }; - 726F2CE11BC9C100001971A4 /* SULog.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C14F05136EF6DB00649790 /* SULog.m */; }; - 726F2CE21BC9C133001971A4 /* SUSystemProfiler.m in Sources */ = {isa = PBXBuildFile; fileRef = 61A2279B0D1CEE7600430CCD /* SUSystemProfiler.m */; }; + 726F2CE51BC9C33D001971A4 /* SUOperatingSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 726F2CE31BC9C33D001971A4 /* SUOperatingSystem.h */; settings = {ASSET_TAGS = (); }; }; + 726F2CE61BC9C33D001971A4 /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; settings = {ASSET_TAGS = (); }; }; + 726F2CE71BC9C3E2001971A4 /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; }; + 726F2CE81BC9C48F001971A4 /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; }; + 726F2CE91BC9C499001971A4 /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; }; 7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */; }; 7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; 7275F9C31B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; @@ -574,6 +575,8 @@ 7223E7621AD1AEFF008E3161 /* sais.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sais.h; sourceTree = ""; }; 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBinaryDeltaCreate.m; sourceTree = ""; }; 7268AC641AD634E400C3E0C1 /* SUBinaryDeltaCreate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBinaryDeltaCreate.h; sourceTree = ""; }; + 726F2CE31BC9C33D001971A4 /* SUOperatingSystem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUOperatingSystem.h; sourceTree = ""; }; + 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUOperatingSystem.m; sourceTree = ""; }; 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUFileManager.h; sourceTree = ""; }; 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUFileManager.m; sourceTree = ""; }; 72A4A23F1BB6567D00E7820D /* SUFileManagerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUFileManagerTest.swift; sourceTree = ""; }; @@ -959,6 +962,8 @@ 14652F8319A9759F00959E44 /* SUExport.h */, 61EF67580E25C5B400F754E0 /* SUHost.h */, 61EF67550E25B58D00F754E0 /* SUHost.m */, + 726F2CE31BC9C33D001971A4 /* SUOperatingSystem.h */, + 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */, 55C14F04136EF6DB00649790 /* SULog.h */, 55C14F05136EF6DB00649790 /* SULog.m */, ); @@ -1090,6 +1095,7 @@ 61EF67590E25C5B400F754E0 /* SUHost.h in Headers */, 618FA5010DAE88B40026945C /* SUInstaller.h in Headers */, 55C14F06136EF6DB00649790 /* SULog.h in Headers */, + 726F2CE51BC9C33D001971A4 /* SUOperatingSystem.h in Headers */, 618FA5220DAE8E8A0026945C /* SUPackageInstaller.h in Headers */, 6102FE460E077FCE00F85D09 /* SUPipedUnarchiver.h in Headers */, 618FA5050DAE8AB80026945C /* SUPlainInstaller.h in Headers */, @@ -1457,6 +1463,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 726F2CE71BC9C3E2001971A4 /* SUOperatingSystem.m in Sources */, 55C14BD4136EEFCE00649790 /* Autoupdate.m in Sources */, F8761EB61ADC5E7A000C9034 /* SUCodeSigningVerifier.m in Sources */, 55C14F00136EF6B700649790 /* SUConstants.m in Sources */, @@ -1478,10 +1485,8 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 726F2CE21BC9C133001971A4 /* SUSystemProfiler.m in Sources */, - 726F2CE11BC9C100001971A4 /* SULog.m in Sources */, - 726F2CE01BC9C0EF001971A4 /* SUHost.m in Sources */, - 726F2CDF1BC9C093001971A4 /* SUConstants.m in Sources */, + 726F2CE91BC9C499001971A4 /* SUOperatingSystem.m in Sources */, + 726F2CE81BC9C48F001971A4 /* SUConstants.m in Sources */, 726F2CDE1BC9BE5B001971A4 /* SUFileManager.m in Sources */, 5D06E8E90FD68CDB005AE3F6 /* bsdiff.c in Sources */, 14652F7E19A9728A00959E44 /* bspatch.c in Sources */, @@ -1550,6 +1555,7 @@ 618FA5060DAE8AB80026945C /* SUPlainInstaller.m in Sources */, 6101347C0DD2541A0049ACDF /* SUProbingUpdateDriver.m in Sources */, 61B93C0A0DD112FF00DCD2F8 /* SUScheduledUpdateDriver.m in Sources */, + 726F2CE61BC9C33D001971A4 /* SUOperatingSystem.m in Sources */, 61A225A50D1C4AC000430CCD /* SUStandardVersionComparator.m in Sources */, 6196CFFA09C72149000DC222 /* SUStatusController.m in Sources */, 61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */, diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 173ce204..bbda2e3a 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -9,6 +9,7 @@ #import "SUBasicUpdateDriver.h" #import "SUHost.h" +#import "SUOperatingSystem.h" #import "SUDSAVerifier.h" #import "SUInstaller.h" #import "SUStandardVersionComparator.h" @@ -96,10 +97,10 @@ // Check minimum and maximum System Version if ([ui minimumSystemVersion] != nil && ![[ui minimumSystemVersion] isEqualToString:@""]) { - minimumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui minimumSystemVersion] toVersion:[SUHost systemVersionString]] != NSOrderedDescending; + minimumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui minimumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedDescending; } if ([ui maximumSystemVersion] != nil && ![[ui maximumSystemVersion] isEqualToString:@""]) { - maximumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui maximumSystemVersion] toVersion:[SUHost systemVersionString]] != NSOrderedAscending; + maximumVersionOK = [[SUStandardVersionComparator defaultComparator] compareVersion:[ui maximumSystemVersion] toVersion:[SUOperatingSystem systemVersionString]] != NSOrderedAscending; } return minimumVersionOK && maximumVersionOK; diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index fa36a997..3cdf5f65 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -7,7 +7,7 @@ // #import "SUFileManager.h" -#import "SUHost.h" +#import "SUOperatingSystem.h" #include #include @@ -846,7 +846,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza NSURL *trashURL = nil; BOOL canUseNewTrashAPI = YES; #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1080 - canUseNewTrashAPI = [SUHost isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 8, 0}]; + canUseNewTrashAPI = [SUOperatingSystem isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 8, 0}]; if (!canUseNewTrashAPI) { FSRef trashRef; if (FSFindFolder(kUserDomain, kTrashFolderType, kDontCreateFolder, &trashRef) == noErr) { diff --git a/Sparkle/SUHost.h b/Sparkle/SUHost.h index 127f2d99..5f73f955 100644 --- a/Sparkle/SUHost.h +++ b/Sparkle/SUHost.h @@ -23,10 +23,6 @@ typedef struct { @property (strong, readonly) NSBundle *bundle; -+ (NSOperatingSystemVersion)operatingSystemVersion; -+ (BOOL)isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version; -+ (NSString *)systemVersionString; - - (instancetype)initWithBundle:(NSBundle *)aBundle; @property (readonly, copy) NSString *bundlePath; @property (readonly) BOOL allowsAutomaticUpdates; diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m index 57bd8f25..c49ba368 100644 --- a/Sparkle/SUHost.m +++ b/Sparkle/SUHost.m @@ -284,43 +284,4 @@ return [self objectForUserDefaultsKey:key] ? [self boolForUserDefaultsKey:key] : [self boolForInfoDictionaryKey:key]; } -+ (NSOperatingSystemVersion)operatingSystemVersion -{ -#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000 -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wselector" - // Xcode 5.1.1: operatingSystemVersion is clearly declared, must warn due to a compiler bug? - if (![NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) -#pragma clang diagnostic pop - { - NSOperatingSystemVersion version = { 0, 0, 0 }; - NSURL *coreServices = [[NSFileManager defaultManager] URLForDirectory:NSCoreServiceDirectory inDomain:NSSystemDomainMask appropriateForURL:nil create:NO error:nil]; - NSArray *components = [[NSDictionary dictionaryWithContentsOfURL:[coreServices URLByAppendingPathComponent:@"SystemVersion.plist"]][@"ProductVersion"] componentsSeparatedByString:@"."]; - version.majorVersion = components.count > 0 ? [components[0] integerValue] : 0; - version.minorVersion = components.count > 1 ? [components[1] integerValue] : 0; - version.patchVersion = components.count > 2 ? [components[2] integerValue] : 0; - return version; - } -#endif - return [[NSProcessInfo processInfo] operatingSystemVersion]; -} - -+ (BOOL)isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version -{ - const NSOperatingSystemVersion systemVersion = self.operatingSystemVersion; - if (systemVersion.majorVersion == version.majorVersion) { - if (systemVersion.minorVersion == version.minorVersion) { - return systemVersion.patchVersion >= version.patchVersion; - } - return systemVersion.minorVersion >= version.minorVersion; - } - return systemVersion.majorVersion >= version.majorVersion; -} - -+ (NSString *)systemVersionString -{ - NSOperatingSystemVersion version = self.operatingSystemVersion; - return [NSString stringWithFormat:@"%ld.%ld.%ld", (long)version.majorVersion, (long)version.minorVersion, (long)version.patchVersion]; -} - @end diff --git a/Sparkle/SUOperatingSystem.h b/Sparkle/SUOperatingSystem.h new file mode 100644 index 00000000..bd65275f --- /dev/null +++ b/Sparkle/SUOperatingSystem.h @@ -0,0 +1,16 @@ +// +// SUOperatingSystem.h +// Sparkle +// +// Copyright © 2015 Sparkle Project. All rights reserved. +// + +#import + +@interface SUOperatingSystem : NSObject + ++ (NSOperatingSystemVersion)operatingSystemVersion; ++ (BOOL)isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version; ++ (NSString *)systemVersionString; + +@end diff --git a/Sparkle/SUOperatingSystem.m b/Sparkle/SUOperatingSystem.m new file mode 100644 index 00000000..85c18ebc --- /dev/null +++ b/Sparkle/SUOperatingSystem.m @@ -0,0 +1,51 @@ +// +// SUOperatingSystem.m +// Sparkle +// +// Copyright © 2015 Sparkle Project. All rights reserved. +// + +#import "SUOperatingSystem.h" + +@implementation SUOperatingSystem + ++ (NSOperatingSystemVersion)operatingSystemVersion +{ +#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000 +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wselector" + // Xcode 5.1.1: operatingSystemVersion is clearly declared, must warn due to a compiler bug? + if (![NSProcessInfo instancesRespondToSelector:@selector(operatingSystemVersion)]) +#pragma clang diagnostic pop + { + NSOperatingSystemVersion version = { 0, 0, 0 }; + NSURL *coreServices = [[NSFileManager defaultManager] URLForDirectory:NSCoreServiceDirectory inDomain:NSSystemDomainMask appropriateForURL:nil create:NO error:nil]; + NSArray *components = [[NSDictionary dictionaryWithContentsOfURL:[coreServices URLByAppendingPathComponent:@"SystemVersion.plist"]][@"ProductVersion"] componentsSeparatedByString:@"."]; + version.majorVersion = components.count > 0 ? [components[0] integerValue] : 0; + version.minorVersion = components.count > 1 ? [components[1] integerValue] : 0; + version.patchVersion = components.count > 2 ? [components[2] integerValue] : 0; + return version; + } +#endif + return [[NSProcessInfo processInfo] operatingSystemVersion]; +} + ++ (BOOL)isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion)version +{ + const NSOperatingSystemVersion systemVersion = self.operatingSystemVersion; + if (systemVersion.majorVersion == version.majorVersion) { + if (systemVersion.minorVersion == version.minorVersion) { + return systemVersion.patchVersion >= version.patchVersion; + } + return systemVersion.minorVersion >= version.minorVersion; + } + return systemVersion.majorVersion >= version.majorVersion; +} + ++ (NSString *)systemVersionString +{ + NSOperatingSystemVersion version = self.operatingSystemVersion; + return [NSString stringWithFormat:@"%ld.%ld.%ld", (long)version.majorVersion, (long)version.minorVersion, (long)version.patchVersion]; +} + +@end diff --git a/Sparkle/SUSystemProfiler.m b/Sparkle/SUSystemProfiler.m index 26bbfe9a..1a155e83 100644 --- a/Sparkle/SUSystemProfiler.m +++ b/Sparkle/SUSystemProfiler.m @@ -11,6 +11,7 @@ #import "SUSystemProfiler.h" #import "SUHost.h" +#import "SUOperatingSystem.h" #include static NSString *const SUSystemProfilerApplicationNameKey = @"appName"; @@ -53,7 +54,7 @@ static NSString *const SUSystemProfilerPreferredLanguageKey = @"lang"; size_t length = sizeof(value); // OS version - NSString *currentSystemVersion = [SUHost systemVersionString]; + NSString *currentSystemVersion = [SUOperatingSystem systemVersionString]; if (currentSystemVersion != nil) { [profileArray addObject:[NSDictionary dictionaryWithObjects:@[SUSystemProfilerOperatingSystemVersionKey, @"OS Version", currentSystemVersion, currentSystemVersion] forKeys:profileDictKeys]]; } diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index 11bbc044..261e84c5 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -11,6 +11,7 @@ #import "SUUpdateAlert.h" #import "SUUpdater_Private.h" #import "SUHost.h" +#import "SUOperatingSystem.h" #import "SUStatusController.h" #import "SUConstants.h" @@ -143,7 +144,7 @@ - (NSString *)localizedStringFromByteCount:(long long)value { - if (![SUHost isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 8, 0}]) { + if (![SUOperatingSystem isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){10, 8, 0}]) { if (value < 1000) { return [NSString stringWithFormat:@"%.0lf %@", value / 1.0, SULocalizedString(@"B", @"the unit for bytes")]; From 9f1884f100ae5f9694eae66f31208c33f314435d Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 10 Oct 2015 18:23:45 -0400 Subject: [PATCH 57/87] Add compile sources to Test App to fix building issues --- Sparkle.xcodeproj/project.pbxproj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index df84dc9f..1f43d726 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -176,6 +176,9 @@ 726F2CE71BC9C3E2001971A4 /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; }; 726F2CE81BC9C48F001971A4 /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; }; 726F2CE91BC9C499001971A4 /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; }; + 726F2CEA1BC9C708001971A4 /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; + 726F2CEB1BC9C733001971A4 /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; }; + 726F2CEC1BC9C74F001971A4 /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; }; 7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */; }; 7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; 7275F9C31B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; @@ -1521,6 +1524,9 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 726F2CEC1BC9C74F001971A4 /* SUOperatingSystem.m in Sources */, + 726F2CEB1BC9C733001971A4 /* SUConstants.m in Sources */, + 726F2CEA1BC9C708001971A4 /* SUFileManager.m in Sources */, 61B5F93009C4CFDC00B25A18 /* main.m in Sources */, 72E45CF31B640CDD005C701A /* SUTestApplicationDelegate.m in Sources */, 72E45CF71B640DAE005C701A /* SUUpdateSettingsWindowController.m in Sources */, From 9cf74373925df293b5af34518814982836821324 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 17 Oct 2015 14:47:16 -0400 Subject: [PATCH 58/87] Update explanation of why copyfile() is insufficient --- Sparkle/SUFileManager.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sparkle/SUFileManager.m b/Sparkle/SUFileManager.m index 3cdf5f65..bb989240 100644 --- a/Sparkle/SUFileManager.m +++ b/Sparkle/SUFileManager.m @@ -310,9 +310,10 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza /* * Copies an item from one location to another * This intentionally does *not* use copyfile() or any API that uses it such as NSFileManager's copy item method - * This is because copyfile() fails to copy symbolic links from one network mount to another, which will affect copying apps - * This failure has been reproduced on 10.11.0 and a VM running 10.8, so the issue has existed for a while. - * For more info, see the bug report at http://openradar.appspot.com/radar?id=4925873463492608 + * This is because copyfile() can fail to copy symbolic links from one network mount to another, which will affect copying apps + * This failure occurs because the system may think symbolic links on a SMB mount are zero bytes in size + * For more info, see bug reports at http://openradar.appspot.com/radar?id=4925873463492608 + * and http://openradar.appspot.com/radar?id=5024037222744064 */ - (BOOL)copyItemAtURL:(NSURL *)sourceURL toURL:(NSURL *)destinationURL error:(NSError * __autoreleasing *)error { From ff7966d96a22b6f0cd33a3af52495bad8e2679a2 Mon Sep 17 00:00:00 2001 From: Oz Solomon Date: Tue, 20 Oct 2015 17:44:30 -0400 Subject: [PATCH 59/87] Fix: sparkleBundle not calculated correctly when SUUpdater is subclassed by a class in a different bundle. --- Sparkle/SUUpdater.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index 2e0390b3..7ab7271a 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -83,7 +83,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults self = [super init]; if (bundle == nil) bundle = [NSBundle mainBundle]; - self.sparkleBundle = [NSBundle bundleForClass:[self class]]; + self.sparkleBundle = [NSBundle bundleForClass:[SUUpdater class]]; if (!self.sparkleBundle) { SULog(@"Error: SUUpdater can't find Sparkle.framework it belongs to"); return nil; From 292ba01dbfd2165f68cb8452f1be848820c75225 Mon Sep 17 00:00:00 2001 From: Oz Solomon Date: Tue, 20 Oct 2015 18:34:35 -0400 Subject: [PATCH 60/87] Removed invalid deployment target version --- Sparkle/el.lproj/SUAutomaticUpdateAlert.xib | 2 +- Sparkle/el.lproj/SUUpdatePermissionPrompt.xib | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Sparkle/el.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/el.lproj/SUAutomaticUpdateAlert.xib index 634566a2..04d090f1 100644 --- a/Sparkle/el.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/el.lproj/SUAutomaticUpdateAlert.xib @@ -1,7 +1,7 @@ - + diff --git a/Sparkle/el.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/el.lproj/SUUpdatePermissionPrompt.xib index 832b7112..3425cf4f 100644 --- a/Sparkle/el.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/el.lproj/SUUpdatePermissionPrompt.xib @@ -1,7 +1,7 @@ - + From 154aa1b0db8007f16fac6dcaf3a8e4c44215bfa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesi=C5=84ski?= Date: Thu, 22 Oct 2015 13:54:43 +0100 Subject: [PATCH 61/87] Subclassing fixes #661 --- Sparkle/SUSystemProfiler.m | 3 ++- Sparkle/SUUpdater.m | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Sparkle/SUSystemProfiler.m b/Sparkle/SUSystemProfiler.m index 26bbfe9a..41e42b0a 100644 --- a/Sparkle/SUSystemProfiler.m +++ b/Sparkle/SUSystemProfiler.m @@ -37,7 +37,8 @@ static NSString *const SUSystemProfilerPreferredLanguageKey = @"lang"; - (NSDictionary *)modelTranslationTable { - NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"SUModelTranslation" ofType:@"plist"]; + // Use explicit class to use the correct bundle even when subclassed + NSString *path = [[NSBundle bundleForClass:[SUSystemProfiler class]] pathForResource:@"SUModelTranslation" ofType:@"plist"]; return [[NSDictionary alloc] initWithContentsOfFile:path]; } diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index 7ab7271a..c3638d97 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -83,6 +83,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults self = [super init]; if (bundle == nil) bundle = [NSBundle mainBundle]; + // Use explicit class to use the correct bundle even when subclassed self.sparkleBundle = [NSBundle bundleForClass:[SUUpdater class]]; if (!self.sparkleBundle) { SULog(@"Error: SUUpdater can't find Sparkle.framework it belongs to"); From 35802dbb4d856931e3cdf73268ff527d1be09dd8 Mon Sep 17 00:00:00 2001 From: Gabriel Ulici Date: Sun, 25 Oct 2015 17:25:37 +0200 Subject: [PATCH 62/87] Updated the latest iMac - Late 2015 --- Resources/SUModelTranslation.plist | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Resources/SUModelTranslation.plist b/Resources/SUModelTranslation.plist index 35eb74c0..65ec17a5 100644 --- a/Resources/SUModelTranslation.plist +++ b/Resources/SUModelTranslation.plist @@ -47,7 +47,13 @@ iMac14,4 iMac (Core i5, 21.5 inch Mid 2014) iMac15,1 - iMac (Retina 5K Core i5 or i7, 27 inch 2014 or 2015) + iMac (Retina 5K Core i5 or i7, 27 inch Late 2014 or Mid 2015) + iMac16,1 + iMac (Core i5, 21,5 inch Late 2015) + iMac16,2 + iMac (Retina 4K Core i5 or i7, 21,5 inch Late 2015) + iMac17,1 + iMac (Retina 5K Core i5 or i7, 27 inch Late 2015) MacBook1,1 MacBook (Core Duo) MacBook2,1 From 97c1a222abb00918c1c69855b3df65003b061a49 Mon Sep 17 00:00:00 2001 From: Gabriel Ulici Date: Sun, 25 Oct 2015 20:08:53 +0200 Subject: [PATCH 63/87] corrected the comma --- Resources/SUModelTranslation.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/SUModelTranslation.plist b/Resources/SUModelTranslation.plist index 65ec17a5..1f75b248 100644 --- a/Resources/SUModelTranslation.plist +++ b/Resources/SUModelTranslation.plist @@ -51,7 +51,7 @@ iMac16,1 iMac (Core i5, 21,5 inch Late 2015) iMac16,2 - iMac (Retina 4K Core i5 or i7, 21,5 inch Late 2015) + iMac (Retina 4K Core i5 or i7, 21.5 inch Late 2015) iMac17,1 iMac (Retina 5K Core i5 or i7, 27 inch Late 2015) MacBook1,1 From 124d9a901f4b656fba4c53183f0b917ca52f87eb Mon Sep 17 00:00:00 2001 From: Felix Schulze Date: Tue, 27 Oct 2015 11:26:25 +0100 Subject: [PATCH 64/87] Fix framework imports Fixes #668 --- Sparkle/Sparkle.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Sparkle/Sparkle.h b/Sparkle/Sparkle.h index 7b482064..20ed6979 100644 --- a/Sparkle/Sparkle.h +++ b/Sparkle/Sparkle.h @@ -14,12 +14,12 @@ // This list should include the shared headers. It doesn't matter if some of them aren't shared (unless // there are name-space collisions) so we can list all of them to start with: -#import -#import -#import -#import -#import -#import -#import +#import "SUAppcast.h" +#import "SUAppcastItem.h" +#import "SUStandardVersionComparator.h" +#import "SUUpdater.h" +#import "SUVersionComparisonProtocol.h" +#import "SUVersionDisplayProtocol.h" +#import "SUErrors.h" #endif From 896a01cd409a3a65ee2fba20ca50c185148adc6b Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 8 Nov 2015 17:00:27 -0500 Subject: [PATCH 65/87] Remove compiled classes in the Test App that exist in the framework This removes run-time warnings that SUFileManager and SUOperatingSystem are defined in both the test app and the framework, and which one is used is undefined. --- Sparkle.xcodeproj/project.pbxproj | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 849a60fe..654ceaaa 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -171,14 +171,12 @@ 7223E7631AD1AEFF008E3161 /* sais.c in Sources */ = {isa = PBXBuildFile; fileRef = 7223E7611AD1AEFF008E3161 /* sais.c */; }; 7268AC631AD634C200C3E0C1 /* SUBinaryDeltaCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */; }; 726F2CDE1BC9BE5B001971A4 /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; - 726F2CE51BC9C33D001971A4 /* SUOperatingSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 726F2CE31BC9C33D001971A4 /* SUOperatingSystem.h */; settings = {ASSET_TAGS = (); }; }; - 726F2CE61BC9C33D001971A4 /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; settings = {ASSET_TAGS = (); }; }; + 726F2CE51BC9C33D001971A4 /* SUOperatingSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 726F2CE31BC9C33D001971A4 /* SUOperatingSystem.h */; }; + 726F2CE61BC9C33D001971A4 /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; }; 726F2CE71BC9C3E2001971A4 /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; }; 726F2CE81BC9C48F001971A4 /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; }; 726F2CE91BC9C499001971A4 /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; }; - 726F2CEA1BC9C708001971A4 /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; 726F2CEB1BC9C733001971A4 /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; }; - 726F2CEC1BC9C74F001971A4 /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; }; 7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 7275F9BF1B5F1F2900B1D19E /* SUFileManager.h */; }; 7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; 7275F9C31B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; @@ -199,7 +197,7 @@ 767B61AC1972D488004E0C3C /* SUGuidedPackageInstaller.h in Headers */ = {isa = PBXBuildFile; fileRef = 767B61AA1972D488004E0C3C /* SUGuidedPackageInstaller.h */; }; 767B61AD1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; }; 767B61AE1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; }; - A5BF4F1D1BC7668B007A052A /* SUTestWebServer.m in Sources */ = {isa = PBXBuildFile; fileRef = A5BF4F1C1BC7668B007A052A /* SUTestWebServer.m */; settings = {ASSET_TAGS = (); }; }; + A5BF4F1D1BC7668B007A052A /* SUTestWebServer.m in Sources */ = {isa = PBXBuildFile; fileRef = A5BF4F1C1BC7668B007A052A /* SUTestWebServer.m */; }; F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */; }; F8761EB31ADC50EB000C9034 /* SparkleTestCodeSignApp.zip in Resources */ = {isa = PBXBuildFile; fileRef = F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */; }; F8761EB61ADC5E7A000C9034 /* SUCodeSigningVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B078CD15A5FB6100600039 /* SUCodeSigningVerifier.m */; }; @@ -1529,9 +1527,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 726F2CEC1BC9C74F001971A4 /* SUOperatingSystem.m in Sources */, 726F2CEB1BC9C733001971A4 /* SUConstants.m in Sources */, - 726F2CEA1BC9C708001971A4 /* SUFileManager.m in Sources */, 61B5F93009C4CFDC00B25A18 /* main.m in Sources */, A5BF4F1D1BC7668B007A052A /* SUTestWebServer.m in Sources */, 72E45CF31B640CDD005C701A /* SUTestApplicationDelegate.m in Sources */, From 66a11b83f0e6654f2ffc7c3d3792eb49f1b72e62 Mon Sep 17 00:00:00 2001 From: Zorg Date: Thu, 24 Sep 2015 23:07:49 -0400 Subject: [PATCH 66/87] Don't install automatic updates if the system might shut off --- Sparkle/SUAutomaticUpdateDriver.m | 11 +++++++++++ Sparkle/SUErrors.h | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Sparkle/SUAutomaticUpdateDriver.m b/Sparkle/SUAutomaticUpdateDriver.m index 45b3d546..562f2d05 100644 --- a/Sparkle/SUAutomaticUpdateDriver.m +++ b/Sparkle/SUAutomaticUpdateDriver.m @@ -63,6 +63,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 - (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil]; + [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil]; // Sudden termination is available on 10.6+ NSProcessInfo *processInfo = [NSProcessInfo processInfo]; @@ -103,6 +104,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 if (self.willUpdateOnTermination) { [[NSNotificationCenter defaultCenter] removeObserver:self name:NSApplicationWillTerminateNotification object:nil]; + [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self name:NSWorkspaceWillPowerOffNotification object:nil]; + NSProcessInfo *processInfo = [NSProcessInfo processInfo]; [processInfo enableSuddenTermination]; @@ -151,6 +154,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 case SUInstallLaterChoice: self.postponingInstallation = YES; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil]; + [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil]; // We're already waiting on quit, just indicate that we're idle. self.interruptible = YES; break; @@ -172,6 +176,13 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 [super installWithToolAndRelaunch:relaunch displayingUserInterface:showUI]; } +- (void)systemWillPowerOff:(NSNotification *)__unused note +{ + [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSystemPowerOffError userInfo:@{ + NSLocalizedDescriptionKey: SULocalizedString(@"The update will not be installed because the user requested for the system to power off", nil) + }]]; +} + - (void)applicationWillTerminate:(NSNotification *)__unused note { [self installWithToolAndRelaunch:NO]; diff --git a/Sparkle/SUErrors.h b/Sparkle/SUErrors.h index e624bb05..d73aadba 100644 --- a/Sparkle/SUErrors.h +++ b/Sparkle/SUErrors.h @@ -38,7 +38,10 @@ typedef NS_ENUM(OSStatus, SUError) { SUMissingInstallerToolError = 4003, SURelaunchError = 4004, SUInstallationError = 4005, - SUDowngradeError = 4006 + SUDowngradeError = 4006, + + // System phase errors + SUSystemPowerOffError = 5000 }; #endif From 72618a0d3a497c148826c8da3e45e84674e85e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Mon, 9 Nov 2015 00:33:29 +0000 Subject: [PATCH 67/87] 1.11.1 --- CHANGELOG | 4 ++++ Configurations/ConfigCommon.xcconfig | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 97b5f3be..cd0be2ff 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +# 1.11.1 + +* Don't install automatic updates when system is about to shut down + # 1.11.0 * Big improvements to code signing and DSA verification diff --git a/Configurations/ConfigCommon.xcconfig b/Configurations/ConfigCommon.xcconfig index d9e78800..580edc56 100644 --- a/Configurations/ConfigCommon.xcconfig +++ b/Configurations/ConfigCommon.xcconfig @@ -16,7 +16,7 @@ SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0 SPARKLE_VERSION_MAJOR = 1 SPARKLE_VERSION_MINOR = 11 -SPARKLE_VERSION_PATCH = 0 +SPARKLE_VERSION_PATCH = 1 SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH) CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION) From 1388639079fbee10d4f90d917dc92bda1bc225a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Tue, 10 Nov 2015 10:30:37 +0000 Subject: [PATCH 68/87] Upgraded XIBs --- Sparkle/ar.lproj/SUAutomaticUpdateAlert.xib | 16 ++++++--- Sparkle/ar.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/ar.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/cs.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/cs.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/cs.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/da.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/da.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/da.lproj/SUUpdatePermissionPrompt.xib | 26 ++++++++++---- Sparkle/de.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/de.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/de.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/el.lproj/SUAutomaticUpdateAlert.xib | 16 ++++++--- Sparkle/el.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/el.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/en.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/en.lproj/SUUpdateAlert.xib | 32 +++++++++++------ Sparkle/en.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/es.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/es.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/es.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/fr.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/fr.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/fr.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/is.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/is.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/is.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/it.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/it.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/it.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/ja.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/ja.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/ja.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/ko.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/ko.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/ko.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/nb.lproj/SUAutomaticUpdateAlert.xib | 16 ++++++--- Sparkle/nb.lproj/SUUpdateAlert.xib | 34 ++++++++++++------- Sparkle/nb.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/nl.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/nl.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/nl.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/pl.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/pl.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/pl.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- .../pt_BR.lproj/SUAutomaticUpdateAlert.xib | 16 ++++++--- Sparkle/pt_BR.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ .../pt_BR.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- .../pt_PT.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/pt_PT.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ .../pt_PT.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/ro.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/ro.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/ro.lproj/SUUpdatePermissionPrompt.xib | 26 ++++++++++---- Sparkle/ru.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/ru.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/ru.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/sk.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/sk.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/sk.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/sl.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/sl.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/sl.lproj/SUUpdatePermissionPrompt.xib | 29 +++++++++++----- Sparkle/sv.lproj/SUAutomaticUpdateAlert.xib | 13 +++++-- Sparkle/sv.lproj/SUUpdateAlert.xib | 32 +++++++++++------ Sparkle/sv.lproj/SUUpdatePermissionPrompt.xib | 22 +++++++++--- Sparkle/th.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/th.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/th.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/tr.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/tr.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/tr.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- Sparkle/uk.lproj/SUAutomaticUpdateAlert.xib | 14 +++++--- Sparkle/uk.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ Sparkle/uk.lproj/SUUpdatePermissionPrompt.xib | 23 ++++++++++--- .../zh_CN.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/zh_CN.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ .../zh_CN.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- .../zh_TW.lproj/SUAutomaticUpdateAlert.xib | 15 +++++--- Sparkle/zh_TW.lproj/SUUpdateAlert.xib | 33 ++++++++++++------ .../zh_TW.lproj/SUUpdatePermissionPrompt.xib | 27 +++++++++++---- 81 files changed, 1425 insertions(+), 591 deletions(-) diff --git a/Sparkle/ar.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/ar.lproj/SUAutomaticUpdateAlert.xib index ffd6fc0a..44801e03 100755 --- a/Sparkle/ar.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/ar.lproj/SUAutomaticUpdateAlert.xib @@ -1,9 +1,7 @@ - + - - - + @@ -12,7 +10,7 @@ - + @@ -26,6 +24,7 @@ + @@ -34,6 +33,7 @@ + @@ -46,6 +46,7 @@ + @@ -58,6 +59,7 @@ + diff --git a/Sparkle/ar.lproj/SUUpdateAlert.xib b/Sparkle/ar.lproj/SUUpdateAlert.xib index 71173bce..7add9791 100644 --- a/Sparkle/ar.lproj/SUUpdateAlert.xib +++ b/Sparkle/ar.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + + - + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -141,6 +147,7 @@ Gw + Anonymous system profile information is used to help us plan future development work. Please contact us if you have any questions about this. @@ -158,10 +165,11 @@ This is the information that would be sent: - + + - + @@ -199,18 +207,23 @@ This is the information that would be sent: + + + diff --git a/Sparkle/cs.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/cs.lproj/SUAutomaticUpdateAlert.xib index f383c339..3192a848 100644 --- a/Sparkle/cs.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/cs.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/cs.lproj/SUUpdateAlert.xib b/Sparkle/cs.lproj/SUUpdateAlert.xib index e1ed9f80..4f99673e 100644 --- a/Sparkle/cs.lproj/SUUpdateAlert.xib +++ b/Sparkle/cs.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + - + + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + Informace z anonymního systémového profilu pomáhají vývojářům lépe plánovat budoucí vývoj aplikace @@ -160,10 +167,11 @@ Tyto informace by měli být odeslány: - + + - + @@ -201,18 +209,23 @@ Tyto informace by měli být odeslány: + + + diff --git a/Sparkle/da.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/da.lproj/SUAutomaticUpdateAlert.xib index e306261a..97ffdee7 100755 --- a/Sparkle/da.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/da.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/da.lproj/SUUpdateAlert.xib b/Sparkle/da.lproj/SUUpdateAlert.xib index 78ab21b5..2644e278 100644 --- a/Sparkle/da.lproj/SUUpdateAlert.xib +++ b/Sparkle/da.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + - + + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -141,6 +148,7 @@ Gw + Anonymous system profile information is used to help us plan future development work. Please contact us if you have any questions about this. @@ -158,10 +166,11 @@ This is the information that would be sent: - + + - + @@ -199,18 +208,23 @@ This is the information that would be sent: + + + diff --git a/Sparkle/de.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/de.lproj/SUAutomaticUpdateAlert.xib index 0bc4fc97..c978dddd 100644 --- a/Sparkle/de.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/de.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/de.lproj/SUUpdateAlert.xib b/Sparkle/de.lproj/SUUpdateAlert.xib index 0b661de8..083000da 100644 --- a/Sparkle/de.lproj/SUUpdateAlert.xib +++ b/Sparkle/de.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + + - + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + Das anonymisierte Systemprofil unterstützt uns bei der zukünftigen Entwicklung. Bitte kontaktieren Sie uns, wenn Sie Fragen hierzu haben. @@ -159,10 +166,11 @@ Diese Informationen würden an uns gesendet: - + + - + @@ -200,18 +208,23 @@ Diese Informationen würden an uns gesendet: + + + diff --git a/Sparkle/el.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/el.lproj/SUAutomaticUpdateAlert.xib index 04d090f1..d6d5fa75 100644 --- a/Sparkle/el.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/el.lproj/SUAutomaticUpdateAlert.xib @@ -1,9 +1,7 @@ - + - - - + @@ -12,7 +10,7 @@ - + @@ -26,6 +24,7 @@ + @@ -34,6 +33,7 @@ + @@ -46,6 +46,7 @@ + @@ -58,6 +59,7 @@ + diff --git a/Sparkle/el.lproj/SUUpdateAlert.xib b/Sparkle/el.lproj/SUUpdateAlert.xib index 83fe668c..ee33f5d9 100644 --- a/Sparkle/el.lproj/SUUpdateAlert.xib +++ b/Sparkle/el.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + - + + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -141,6 +147,7 @@ Gw + Το ανώνυμο προφίλ συστήματος χρησιμοποιείται για να μας βοηθήσει σε μελλοντική ανάπτυξη του προγράμματος. Παρακαλώ επικοινωνήστε μαζί μας άν έχετε ερωτήσεις. @@ -158,10 +165,11 @@ Gw - + + - + @@ -199,18 +207,23 @@ Gw + + + diff --git a/Sparkle/en.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/en.lproj/SUAutomaticUpdateAlert.xib index c707f6c3..072a1346 100644 --- a/Sparkle/en.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/en.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/en.lproj/SUUpdateAlert.xib b/Sparkle/en.lproj/SUUpdateAlert.xib index 65f653e2..bbab3974 100644 --- a/Sparkle/en.lproj/SUUpdateAlert.xib +++ b/Sparkle/en.lproj/SUUpdateAlert.xib @@ -1,12 +1,11 @@ - + - - - - + + + @@ -41,6 +40,7 @@ + @@ -51,6 +51,7 @@ + @@ -66,6 +67,7 @@ + @@ -80,12 +82,13 @@ - + + @@ -98,14 +101,16 @@ + - - - + + + + - + @@ -122,6 +127,7 @@ + @@ -144,12 +150,14 @@ + + @@ -142,6 +148,7 @@ Gw + Anonymous system profile information is used to help us plan future development work. Please contact us if you have any questions about this. @@ -159,10 +166,11 @@ This is the information that would be sent: - + + - + @@ -200,18 +208,23 @@ This is the information that would be sent: + + + diff --git a/Sparkle/es.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/es.lproj/SUAutomaticUpdateAlert.xib index 98a58ab8..d9f67da6 100644 --- a/Sparkle/es.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/es.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/es.lproj/SUUpdateAlert.xib b/Sparkle/es.lproj/SUUpdateAlert.xib index 551ac126..7bc9932f 100644 --- a/Sparkle/es.lproj/SUUpdateAlert.xib +++ b/Sparkle/es.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + + - + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + La información de perfil de sistema anónimo se usa para ayudarnos a planear el trabajo de desarrollo futuro. Por favor, póngase en cantacto con nosotros si tiene preguntas sobre esto. @@ -159,10 +166,11 @@ Esta es la información que se nos enviaría: - + + - + @@ -200,18 +208,23 @@ Esta es la información que se nos enviaría: + + + diff --git a/Sparkle/fr.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/fr.lproj/SUAutomaticUpdateAlert.xib index eb32a008..5c3de9a8 100644 --- a/Sparkle/fr.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/fr.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/fr.lproj/SUUpdateAlert.xib b/Sparkle/fr.lproj/SUUpdateAlert.xib index 60a7add4..90149e62 100644 --- a/Sparkle/fr.lproj/SUUpdateAlert.xib +++ b/Sparkle/fr.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + - + + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + Les informations anonymes de profil système nous aident à planifier les futurs développements. Contactez-nous pour toute question à ce sujet. @@ -159,10 +166,11 @@ Ci-dessous figurent les informations qui seront transmises : - + + - + @@ -200,18 +208,23 @@ Ci-dessous figurent les informations qui seront transmises : + + + diff --git a/Sparkle/is.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/is.lproj/SUAutomaticUpdateAlert.xib index 1e8542ec..91c9e038 100644 --- a/Sparkle/is.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/is.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/is.lproj/SUUpdateAlert.xib b/Sparkle/is.lproj/SUUpdateAlert.xib index 6dba3438..91e1e59b 100644 --- a/Sparkle/is.lproj/SUUpdateAlert.xib +++ b/Sparkle/is.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + + - + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + Upplýsingar úr nafnlausum kerfisskýrslum eru notaðar til að hjálpa okkur við framtíðarþróun hugbúnaðarins. Ekki hika við að hafa samband ef spurningar vakna um þetta. @@ -159,10 +166,11 @@ Gw - + + - + @@ -200,18 +208,23 @@ Gw + + + diff --git a/Sparkle/it.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/it.lproj/SUAutomaticUpdateAlert.xib index 30f0c866..a0957a47 100644 --- a/Sparkle/it.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/it.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/it.lproj/SUUpdateAlert.xib b/Sparkle/it.lproj/SUUpdateAlert.xib index 79b06d5b..74b8a82b 100644 --- a/Sparkle/it.lproj/SUUpdateAlert.xib +++ b/Sparkle/it.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + + - + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + Le informazioni del profilo di sistema anomino sono utilizzate per aiutarci in futuri lavori di sviluppo. Contattaci se hai dei quesiti sull’argomento. @@ -159,10 +166,11 @@ Queste sono le informazioni che verrebbero inviate: - + + - + @@ -200,18 +208,23 @@ Queste sono le informazioni che verrebbero inviate: + + + diff --git a/Sparkle/ja.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/ja.lproj/SUAutomaticUpdateAlert.xib index b9afe24a..1ce76dbc 100644 --- a/Sparkle/ja.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/ja.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/ja.lproj/SUUpdateAlert.xib b/Sparkle/ja.lproj/SUUpdateAlert.xib index 675fd050..4c9ae007 100644 --- a/Sparkle/ja.lproj/SUUpdateAlert.xib +++ b/Sparkle/ja.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + + - + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + 匿名のシステムプロファイル情報は、今後我が社の企画開発を計画する上で参考にさせていただきます。この件に関してご質問があれば、ご連絡下さい。 @@ -159,10 +166,11 @@ Gw - + + - + @@ -200,18 +208,23 @@ Gw + + + diff --git a/Sparkle/ko.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/ko.lproj/SUAutomaticUpdateAlert.xib index 8797c38a..b3ecde5b 100644 --- a/Sparkle/ko.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/ko.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/ko.lproj/SUUpdateAlert.xib b/Sparkle/ko.lproj/SUUpdateAlert.xib index 4cddbc2a..4a08a950 100644 --- a/Sparkle/ko.lproj/SUUpdateAlert.xib +++ b/Sparkle/ko.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + + - + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + 익명으로 보내지는 시스템 정보로 차후 프로그램 개발에 도움이 될 수 있습니다. 질문이 있으시면 연락 주십시오. @@ -159,10 +166,11 @@ Gw - + + - + @@ -200,18 +208,23 @@ Gw + + + diff --git a/Sparkle/nb.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/nb.lproj/SUAutomaticUpdateAlert.xib index aa23477e..1c420749 100644 --- a/Sparkle/nb.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/nb.lproj/SUAutomaticUpdateAlert.xib @@ -1,9 +1,7 @@ - + - - - + @@ -12,7 +10,7 @@ - + @@ -26,6 +24,7 @@ + @@ -34,6 +33,7 @@ + @@ -46,6 +46,7 @@ + @@ -58,6 +59,7 @@ + diff --git a/Sparkle/nb.lproj/SUUpdateAlert.xib b/Sparkle/nb.lproj/SUUpdateAlert.xib index 46dc0feb..21d433c4 100644 --- a/Sparkle/nb.lproj/SUUpdateAlert.xib +++ b/Sparkle/nb.lproj/SUUpdateAlert.xib @@ -1,12 +1,11 @@ - + - - - - + + + @@ -20,7 +19,7 @@ - + @@ -39,6 +38,7 @@ + @@ -49,6 +49,7 @@ + @@ -63,6 +64,7 @@ + @@ -81,6 +83,7 @@ + @@ -94,6 +97,7 @@ Gw - + + @@ -138,14 +144,16 @@ DQ + - - - + + + + - + @@ -163,6 +171,7 @@ DQ + @@ -174,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + Den anonyme systemprofilen hjelper oss med å planlegge fremtidig utviklingsarbeid. Ta gjerne kontakt med oss hvis du har spørsmål om dette.
 @@ -158,10 +165,11 @@ Følgende innhold vil bli sendt: - + + - + @@ -199,18 +207,23 @@ Følgende innhold vil bli sendt: + + + diff --git a/Sparkle/nl.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/nl.lproj/SUAutomaticUpdateAlert.xib index cc4b4589..856f7a3a 100644 --- a/Sparkle/nl.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/nl.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/nl.lproj/SUUpdateAlert.xib b/Sparkle/nl.lproj/SUUpdateAlert.xib index b730298f..98cde5ad 100644 --- a/Sparkle/nl.lproj/SUUpdateAlert.xib +++ b/Sparkle/nl.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + - + + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + Aan de hand van anonieme informatie over het systeemprofiel kunnen wij toekomstige ontwikkelingswerkzaamheden beter plannen. Neem contact met ons op als u hierover vragen hebt. @@ -159,10 +166,11 @@ Dit is de informatie die wordt verzonden: - + + - + @@ -200,18 +208,23 @@ Dit is de informatie die wordt verzonden: + + + diff --git a/Sparkle/pl.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/pl.lproj/SUAutomaticUpdateAlert.xib index aa9cdc29..a31ffba0 100644 --- a/Sparkle/pl.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/pl.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/pl.lproj/SUUpdateAlert.xib b/Sparkle/pl.lproj/SUUpdateAlert.xib index 5836777d..3267428f 100644 --- a/Sparkle/pl.lproj/SUUpdateAlert.xib +++ b/Sparkle/pl.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + + - + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + Anonymous system profile information is used to help us plan future development work. Please contact us if you have any questions about this. @@ -159,10 +166,11 @@ This is the information that would be sent: - + + - + @@ -200,18 +208,23 @@ This is the information that would be sent: + + + diff --git a/Sparkle/pt_BR.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/pt_BR.lproj/SUAutomaticUpdateAlert.xib index b4f1bad6..3d385df9 100755 --- a/Sparkle/pt_BR.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/pt_BR.lproj/SUAutomaticUpdateAlert.xib @@ -1,9 +1,7 @@ - + - - - + @@ -12,7 +10,7 @@ - + @@ -26,6 +24,7 @@ + @@ -34,6 +33,7 @@ + @@ -46,6 +46,7 @@ + @@ -58,6 +59,7 @@ + diff --git a/Sparkle/pt_BR.lproj/SUUpdateAlert.xib b/Sparkle/pt_BR.lproj/SUUpdateAlert.xib index 0f71933f..a8e87da9 100644 --- a/Sparkle/pt_BR.lproj/SUUpdateAlert.xib +++ b/Sparkle/pt_BR.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + + - + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + As informações anônimas do sistema são usadas para nos ajudar a planejar o desenvolvimento futuro do aplicativo. Contate-nos caso tenha dúvidas sobre este procedimento. @@ -159,10 +166,11 @@ As seguintes informações seriam enviadas: - + + - + @@ -200,18 +208,23 @@ As seguintes informações seriam enviadas: + + + diff --git a/Sparkle/pt_PT.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/pt_PT.lproj/SUAutomaticUpdateAlert.xib index 3aa21b7d..0419ca9e 100644 --- a/Sparkle/pt_PT.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/pt_PT.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/pt_PT.lproj/SUUpdateAlert.xib b/Sparkle/pt_PT.lproj/SUUpdateAlert.xib index 865cdbf1..74f962d0 100644 --- a/Sparkle/pt_PT.lproj/SUUpdateAlert.xib +++ b/Sparkle/pt_PT.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + - + + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + A informação anónima do perfil de sistema é usada para no futuro nos ajudar a planear o trabalho de desenvolvimento. Por favor contacte-nos se tiver alguma questão acerca deste assunto. @@ -159,10 +166,11 @@ Esta é a informação que seria enviada: - + + - + @@ -200,18 +208,23 @@ Esta é a informação que seria enviada: + + + diff --git a/Sparkle/ro.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/ro.lproj/SUAutomaticUpdateAlert.xib index 82772f84..7548d46f 100644 --- a/Sparkle/ro.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/ro.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/ro.lproj/SUUpdateAlert.xib b/Sparkle/ro.lproj/SUUpdateAlert.xib index 3f652c77..8b0fa421 100644 --- a/Sparkle/ro.lproj/SUUpdateAlert.xib +++ b/Sparkle/ro.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + - + + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -141,6 +148,7 @@ Gw + Anonymous system profile information is used to help us plan future development work. Please contact us if you have any questions about this. @@ -158,10 +166,11 @@ This is the information that would be sent: - + + - + @@ -199,18 +208,23 @@ This is the information that would be sent: + + + diff --git a/Sparkle/ru.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/ru.lproj/SUAutomaticUpdateAlert.xib index 250e3344..345a3498 100644 --- a/Sparkle/ru.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/ru.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/ru.lproj/SUUpdateAlert.xib b/Sparkle/ru.lproj/SUUpdateAlert.xib index 6f36ee82..9912699e 100644 --- a/Sparkle/ru.lproj/SUUpdateAlert.xib +++ b/Sparkle/ru.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + + - + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + Использование анонимного профиля системы помогает нам в планировании будущей работы по разработке. Если у вас есть какие-либо вопросы по этой теме, обращайтесь к нам. @@ -159,10 +166,11 @@ Gw - + + - + @@ -200,18 +208,23 @@ Gw + + + diff --git a/Sparkle/sk.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/sk.lproj/SUAutomaticUpdateAlert.xib index c999eaab..9df18e3e 100644 --- a/Sparkle/sk.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/sk.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/sk.lproj/SUUpdateAlert.xib b/Sparkle/sk.lproj/SUUpdateAlert.xib index c047f054..9c9d8afb 100644 --- a/Sparkle/sk.lproj/SUUpdateAlert.xib +++ b/Sparkle/sk.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + + - + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + Anonymný profil systému nám umožní zlepšiť plánovanie budúceho vývoja aplikácie. Ak máte ohľadom tohto akékoľvek otázky, neváhajte a kontaktujte nás. @@ -159,10 +166,11 @@ Odosielané budú nasledujúce informácie: - + + - + @@ -200,18 +208,23 @@ Odosielané budú nasledujúce informácie: + + + diff --git a/Sparkle/sl.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/sl.lproj/SUAutomaticUpdateAlert.xib index 605ee9ae..3da6eea0 100644 --- a/Sparkle/sl.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/sl.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/sl.lproj/SUUpdateAlert.xib b/Sparkle/sl.lproj/SUUpdateAlert.xib index 0021bda7..e27459ae 100644 --- a/Sparkle/sl.lproj/SUUpdateAlert.xib +++ b/Sparkle/sl.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + + - + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + Anonimni profil sistema se uporablja za načrtovanje nadaljnega razvoja programa. V primeru vprašanj nas lahko kontaktirate. @@ -159,10 +166,11 @@ Pošljejo se sledeče informacije: - + + - + @@ -200,18 +208,23 @@ Pošljejo se sledeče informacije: + - + + + diff --git a/Sparkle/sv.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/sv.lproj/SUAutomaticUpdateAlert.xib index 4d402724..dfc1f204 100644 --- a/Sparkle/sv.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/sv.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/sv.lproj/SUUpdateAlert.xib b/Sparkle/sv.lproj/SUUpdateAlert.xib index 5e55383e..f3093cef 100644 --- a/Sparkle/sv.lproj/SUUpdateAlert.xib +++ b/Sparkle/sv.lproj/SUUpdateAlert.xib @@ -1,12 +1,11 @@ - + - - - - + + + @@ -39,6 +38,7 @@ + @@ -49,6 +49,7 @@ + @@ -63,6 +64,7 @@ + @@ -81,6 +83,7 @@ + @@ -94,6 +97,7 @@ Gw - + + @@ -138,14 +144,16 @@ DQ + - - - + + + + - + @@ -163,6 +171,7 @@ DQ + @@ -174,6 +183,7 @@ DQ + @@ -143,6 +150,7 @@ Gw + Anonym systemprofilinformation används för att hjälpa oss att planera framtida utvecklingsarbete. Vänligen kontakta oss ifall du har några frågot om detta. @@ -162,8 +170,9 @@ Detta är informationen som skulle sändas: + - + @@ -201,18 +210,23 @@ Detta är informationen som skulle sändas: + + + diff --git a/Sparkle/th.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/th.lproj/SUAutomaticUpdateAlert.xib index e1724b95..98d379b4 100644 --- a/Sparkle/th.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/th.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/th.lproj/SUUpdateAlert.xib b/Sparkle/th.lproj/SUUpdateAlert.xib index cf450047..9e330a8e 100644 --- a/Sparkle/th.lproj/SUUpdateAlert.xib +++ b/Sparkle/th.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + - + + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + ข้อมูลระบบแบบนิรนามช่วยในการวางแผนพัฒนาแอปพลิเคชันของเราในอนาคต กรุณาติดต่อเราถ้าคุณมีข้อสงสัยในเรื่องนี้ @@ -159,10 +166,11 @@ Gw - + + - + @@ -200,18 +208,23 @@ Gw + + + diff --git a/Sparkle/tr.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/tr.lproj/SUAutomaticUpdateAlert.xib index 7a875283..ded2abf1 100644 --- a/Sparkle/tr.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/tr.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/tr.lproj/SUUpdateAlert.xib b/Sparkle/tr.lproj/SUUpdateAlert.xib index 4f58b04a..0cc4ed29 100644 --- a/Sparkle/tr.lproj/SUUpdateAlert.xib +++ b/Sparkle/tr.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + + - + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -140,6 +146,7 @@ Gw + Gönderdiğiniz anonim sistem bilgileri bu yazılımın geliştirilmesi için kullanılacaktır. Konu ile ilgili ayrıntılı bilgi için lütfen bizimle bağlantıya geçiniz. Göndereceğiniz Bilgiler: @@ -155,10 +162,11 @@ Gw - + + - + @@ -196,18 +204,23 @@ Gw + + + diff --git a/Sparkle/uk.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/uk.lproj/SUAutomaticUpdateAlert.xib index 865d7d5d..298b132f 100644 --- a/Sparkle/uk.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/uk.lproj/SUAutomaticUpdateAlert.xib @@ -1,9 +1,7 @@ - + - - - + @@ -26,6 +24,7 @@ + @@ -34,6 +33,7 @@ + @@ -46,6 +46,7 @@ + @@ -58,6 +59,7 @@ + diff --git a/Sparkle/uk.lproj/SUUpdateAlert.xib b/Sparkle/uk.lproj/SUUpdateAlert.xib index e130c93e..9205f36a 100644 --- a/Sparkle/uk.lproj/SUUpdateAlert.xib +++ b/Sparkle/uk.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + - + + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + Використання анонімного профілю системи допомагає нам у планування майбутньої розробки. Якщо у вас виникли питання щодо цього, звертайтесь до нас. @@ -161,8 +168,9 @@ Gw + - + @@ -200,18 +208,23 @@ Gw + + + diff --git a/Sparkle/zh_CN.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/zh_CN.lproj/SUAutomaticUpdateAlert.xib index f0040bc5..08c4b9ed 100644 --- a/Sparkle/zh_CN.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/zh_CN.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/zh_CN.lproj/SUUpdateAlert.xib b/Sparkle/zh_CN.lproj/SUUpdateAlert.xib index 6503aebc..f0831e54 100644 --- a/Sparkle/zh_CN.lproj/SUUpdateAlert.xib +++ b/Sparkle/zh_CN.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + + - + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + 无记名系统概况信息被用于帮助我们安排将来的开发工作。如果对此存在疑问请联系我们。 @@ -159,10 +166,11 @@ Gw - + + - + @@ -200,18 +208,23 @@ Gw + + + diff --git a/Sparkle/zh_TW.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/zh_TW.lproj/SUAutomaticUpdateAlert.xib index 6f05efa5..8a4524ad 100644 --- a/Sparkle/zh_TW.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/zh_TW.lproj/SUAutomaticUpdateAlert.xib @@ -1,8 +1,7 @@ - + - - + @@ -11,7 +10,7 @@ - + @@ -25,6 +24,7 @@ + @@ -33,6 +33,7 @@ + @@ -45,6 +46,7 @@ + @@ -57,6 +59,7 @@ + diff --git a/Sparkle/zh_TW.lproj/SUUpdateAlert.xib b/Sparkle/zh_TW.lproj/SUUpdateAlert.xib index afd653ca..c9812056 100644 --- a/Sparkle/zh_TW.lproj/SUUpdateAlert.xib +++ b/Sparkle/zh_TW.lproj/SUUpdateAlert.xib @@ -1,11 +1,11 @@ - + - - - + + + @@ -19,7 +19,7 @@ - + @@ -38,6 +38,7 @@ + @@ -48,6 +49,7 @@ + @@ -62,6 +64,7 @@ + @@ -80,6 +83,7 @@ + @@ -93,6 +97,7 @@ Gw - + + @@ -137,14 +144,16 @@ DQ + - - - + + + + - + @@ -162,6 +171,7 @@ DQ + @@ -173,6 +183,7 @@ DQ + @@ -142,6 +148,7 @@ Gw + 匿名系統描述資訊可用來協助我們計畫未來的開發工作。若您有任何相關問題,請與我們聯繫。 @@ -159,10 +166,11 @@ Gw - + + - + @@ -200,18 +208,23 @@ Gw + + + From 5112748e1be12fbfc99eeaab34d6d92fe5a164d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Tue, 10 Nov 2015 10:36:25 +0000 Subject: [PATCH 69/87] Re-generated XIBs --- Sparkle/cs.lproj/SUAutomaticUpdateAlert.xib | 20 +- Sparkle/cs.lproj/SUUpdateAlert.xib | 197 +++++++++-------- Sparkle/cs.lproj/SUUpdatePermissionPrompt.xib | 8 +- Sparkle/da.lproj/SUAutomaticUpdateAlert.xib | 8 +- Sparkle/da.lproj/SUUpdateAlert.xib | 195 +++++++++-------- Sparkle/da.lproj/SUUpdatePermissionPrompt.xib | 8 +- Sparkle/de.lproj/SUAutomaticUpdateAlert.xib | 18 +- Sparkle/de.lproj/SUUpdateAlert.xib | 195 +++++++++-------- Sparkle/de.lproj/SUUpdatePermissionPrompt.xib | 12 +- Sparkle/el.lproj/SUAutomaticUpdateAlert.xib | 22 +- Sparkle/el.lproj/SUUpdateAlert.xib | 201 +++++++++-------- Sparkle/el.lproj/SUUpdatePermissionPrompt.xib | 11 +- Sparkle/es.lproj/SUAutomaticUpdateAlert.xib | 16 +- Sparkle/es.lproj/SUUpdateAlert.xib | 197 +++++++++-------- Sparkle/es.lproj/SUUpdatePermissionPrompt.xib | 22 +- Sparkle/fr.lproj/SUAutomaticUpdateAlert.xib | 16 +- Sparkle/fr.lproj/SUUpdateAlert.xib | 195 +++++++++-------- Sparkle/fr.lproj/SUUpdatePermissionPrompt.xib | 24 +- Sparkle/is.lproj/SUAutomaticUpdateAlert.xib | 18 +- Sparkle/is.lproj/SUUpdateAlert.xib | 195 +++++++++-------- Sparkle/is.lproj/SUUpdatePermissionPrompt.xib | 10 +- Sparkle/it.lproj/SUAutomaticUpdateAlert.xib | 16 +- Sparkle/it.lproj/SUUpdateAlert.xib | 202 +++++++++-------- Sparkle/it.lproj/SUUpdatePermissionPrompt.xib | 22 +- Sparkle/ja.lproj/SUAutomaticUpdateAlert.xib | 22 +- Sparkle/ja.lproj/SUUpdateAlert.xib | 201 +++++++++-------- Sparkle/ja.lproj/SUUpdatePermissionPrompt.xib | 22 +- Sparkle/ko.lproj/SUAutomaticUpdateAlert.xib | 20 +- Sparkle/ko.lproj/SUUpdateAlert.xib | 193 ++++++++-------- Sparkle/ko.lproj/SUUpdatePermissionPrompt.xib | 18 +- Sparkle/nb.lproj/SUAutomaticUpdateAlert.xib | 8 +- Sparkle/nb.lproj/SUUpdateAlert.xib | 193 ++++++++-------- Sparkle/nb.lproj/SUUpdatePermissionPrompt.xib | 8 +- Sparkle/nl.lproj/SUAutomaticUpdateAlert.xib | 16 +- Sparkle/nl.lproj/SUUpdateAlert.xib | 202 +++++++++-------- Sparkle/nl.lproj/SUUpdatePermissionPrompt.xib | 16 +- Sparkle/pl.lproj/SUAutomaticUpdateAlert.xib | 20 +- Sparkle/pl.lproj/SUUpdateAlert.xib | 198 +++++++++-------- Sparkle/pl.lproj/SUUpdatePermissionPrompt.xib | 16 +- .../pt_BR.lproj/SUAutomaticUpdateAlert.xib | 18 +- Sparkle/pt_BR.lproj/SUUpdateAlert.xib | 206 ++++++++++-------- .../pt_BR.lproj/SUUpdatePermissionPrompt.xib | 24 +- .../pt_PT.lproj/SUAutomaticUpdateAlert.xib | 18 +- Sparkle/pt_PT.lproj/SUUpdateAlert.xib | 197 +++++++++-------- .../pt_PT.lproj/SUUpdatePermissionPrompt.xib | 18 +- Sparkle/ro.lproj/SUAutomaticUpdateAlert.xib | 10 +- Sparkle/ro.lproj/SUUpdateAlert.xib | 202 +++++++++-------- Sparkle/ro.lproj/SUUpdatePermissionPrompt.xib | 12 +- Sparkle/ru.lproj/SUAutomaticUpdateAlert.xib | 18 +- Sparkle/ru.lproj/SUUpdateAlert.xib | 202 +++++++++-------- Sparkle/ru.lproj/SUUpdatePermissionPrompt.xib | 22 +- Sparkle/sk.lproj/SUAutomaticUpdateAlert.xib | 20 +- Sparkle/sk.lproj/SUUpdateAlert.xib | 195 +++++++++-------- Sparkle/sk.lproj/SUUpdatePermissionPrompt.xib | 12 +- Sparkle/sl.lproj/SUAutomaticUpdateAlert.xib | 20 +- Sparkle/sl.lproj/SUUpdateAlert.xib | 202 +++++++++-------- Sparkle/sl.lproj/SUUpdatePermissionPrompt.xib | 18 +- Sparkle/sv.lproj/SUAutomaticUpdateAlert.xib | 16 +- Sparkle/sv.lproj/SUUpdateAlert.xib | 202 +++++++++-------- Sparkle/sv.lproj/SUUpdatePermissionPrompt.xib | 20 +- Sparkle/th.lproj/SUAutomaticUpdateAlert.xib | 2 +- Sparkle/th.lproj/SUUpdateAlert.xib | 191 ++++++++-------- Sparkle/th.lproj/SUUpdatePermissionPrompt.xib | 12 +- Sparkle/tr.lproj/SUAutomaticUpdateAlert.xib | 20 +- Sparkle/tr.lproj/SUUpdateAlert.xib | 197 +++++++++-------- Sparkle/tr.lproj/SUUpdatePermissionPrompt.xib | 54 ++--- Sparkle/uk.lproj/SUAutomaticUpdateAlert.xib | 18 +- Sparkle/uk.lproj/SUUpdateAlert.xib | 202 +++++++++-------- Sparkle/uk.lproj/SUUpdatePermissionPrompt.xib | 22 +- .../zh_CN.lproj/SUAutomaticUpdateAlert.xib | 22 +- Sparkle/zh_CN.lproj/SUUpdateAlert.xib | 195 +++++++++-------- .../zh_CN.lproj/SUUpdatePermissionPrompt.xib | 14 +- .../zh_TW.lproj/SUAutomaticUpdateAlert.xib | 20 +- Sparkle/zh_TW.lproj/SUUpdateAlert.xib | 193 ++++++++-------- .../zh_TW.lproj/SUUpdatePermissionPrompt.xib | 20 +- 75 files changed, 3142 insertions(+), 2673 deletions(-) mode change 100755 => 100644 Sparkle/da.lproj/SUAutomaticUpdateAlert.xib mode change 100755 => 100644 Sparkle/da.lproj/SUUpdatePermissionPrompt.xib mode change 100755 => 100644 Sparkle/pt_BR.lproj/SUAutomaticUpdateAlert.xib diff --git a/Sparkle/cs.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/cs.lproj/SUAutomaticUpdateAlert.xib index 3192a848..1b2be43d 100644 --- a/Sparkle/cs.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/cs.lproj/SUAutomaticUpdateAlert.xib @@ -11,14 +11,14 @@ - + - - + + - + @@ -31,7 +31,7 @@ - + @@ -44,7 +44,7 @@ - + @@ -57,7 +57,7 @@ - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,6 +251,7 @@ DQ + diff --git a/Sparkle/cs.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/cs.lproj/SUUpdatePermissionPrompt.xib index 4bd93622..87ea95e2 100644 --- a/Sparkle/cs.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/cs.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -26,7 +26,7 @@ - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,6 +251,7 @@ DQ + diff --git a/Sparkle/da.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/da.lproj/SUUpdatePermissionPrompt.xib old mode 100755 new mode 100644 index d85aded6..6fa23883 --- a/Sparkle/da.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/da.lproj/SUUpdatePermissionPrompt.xib @@ -19,14 +19,14 @@ - + - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,6 +251,7 @@ DQ + diff --git a/Sparkle/de.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/de.lproj/SUUpdatePermissionPrompt.xib index 17956af7..92c1570f 100644 --- a/Sparkle/de.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/de.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -56,7 +56,7 @@ Gw - + @@ -111,7 +111,7 @@ Gw - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,6 +251,7 @@ DQ + diff --git a/Sparkle/el.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/el.lproj/SUUpdatePermissionPrompt.xib index 1edaa670..c1f01b1d 100644 --- a/Sparkle/el.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/el.lproj/SUUpdatePermissionPrompt.xib @@ -9,6 +9,7 @@ + @@ -18,7 +19,7 @@ - + @@ -129,7 +130,7 @@ Gw - + visibleKey visibleValue @@ -160,7 +161,7 @@ Gw - + @@ -176,7 +177,7 @@ Gw - + @@ -192,7 +193,7 @@ Gw - + diff --git a/Sparkle/es.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/es.lproj/SUAutomaticUpdateAlert.xib index d9f67da6..e1b843f3 100644 --- a/Sparkle/es.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/es.lproj/SUAutomaticUpdateAlert.xib @@ -11,14 +11,14 @@ - + - + - + @@ -31,7 +31,7 @@ - + @@ -44,7 +44,7 @@ - + @@ -57,7 +57,7 @@ - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,6 +251,7 @@ DQ + diff --git a/Sparkle/es.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/es.lproj/SUUpdatePermissionPrompt.xib index 64f2fd89..a433e396 100644 --- a/Sparkle/es.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/es.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -18,15 +18,15 @@ - + - + - + @@ -66,7 +66,7 @@ Gw - + @@ -111,7 +111,7 @@ Gw - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,6 +251,7 @@ DQ + diff --git a/Sparkle/fr.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/fr.lproj/SUUpdatePermissionPrompt.xib index 5fe4120a..97b8bec6 100644 --- a/Sparkle/fr.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/fr.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -18,15 +18,15 @@ - + - + - + @@ -66,7 +66,7 @@ Gw - + @@ -79,7 +79,7 @@ Gw - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,6 +251,7 @@ DQ + diff --git a/Sparkle/is.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/is.lproj/SUUpdatePermissionPrompt.xib index a3563c04..1cfc2023 100644 --- a/Sparkle/is.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/is.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -26,7 +26,7 @@ - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,7 +251,7 @@ DQ - + diff --git a/Sparkle/it.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/it.lproj/SUUpdatePermissionPrompt.xib index 00a565fb..746f8ac3 100644 --- a/Sparkle/it.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/it.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -18,15 +18,15 @@ - + - + - + @@ -66,7 +66,7 @@ Gw - + @@ -111,7 +111,7 @@ Gw - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,6 +251,7 @@ DQ + diff --git a/Sparkle/ja.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/ja.lproj/SUUpdatePermissionPrompt.xib index 1a6b15f2..83a061bd 100644 --- a/Sparkle/ja.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/ja.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -26,12 +26,12 @@ - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,6 +251,7 @@ DQ + diff --git a/Sparkle/ko.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/ko.lproj/SUUpdatePermissionPrompt.xib index ae4bac7f..86c11450 100644 --- a/Sparkle/ko.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/ko.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -26,7 +26,7 @@ - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,6 +251,7 @@ DQ + diff --git a/Sparkle/nb.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/nb.lproj/SUUpdatePermissionPrompt.xib index 8c4d7bbb..af839fe9 100644 --- a/Sparkle/nb.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/nb.lproj/SUUpdatePermissionPrompt.xib @@ -26,7 +26,7 @@ - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,7 +251,7 @@ DQ - + diff --git a/Sparkle/nl.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/nl.lproj/SUUpdatePermissionPrompt.xib index ffe75b26..86082c5e 100644 --- a/Sparkle/nl.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/nl.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -18,15 +18,15 @@ - + - + - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,7 +251,7 @@ DQ - + diff --git a/Sparkle/pl.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/pl.lproj/SUUpdatePermissionPrompt.xib index 10f2d6b8..668534c9 100644 --- a/Sparkle/pl.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/pl.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -18,15 +18,15 @@ - + - + - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,7 +251,7 @@ DQ - + diff --git a/Sparkle/pt_BR.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/pt_BR.lproj/SUUpdatePermissionPrompt.xib index 81e88a59..56a5bf62 100644 --- a/Sparkle/pt_BR.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/pt_BR.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -18,15 +18,15 @@ - + - + - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,6 +251,7 @@ DQ + diff --git a/Sparkle/pt_PT.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/pt_PT.lproj/SUUpdatePermissionPrompt.xib index c1f943ef..adfc10e1 100644 --- a/Sparkle/pt_PT.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/pt_PT.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -18,15 +18,15 @@ - + - + - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,7 +251,7 @@ DQ - + diff --git a/Sparkle/ro.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/ro.lproj/SUUpdatePermissionPrompt.xib index 7d072922..ab2ecb81 100644 --- a/Sparkle/ro.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/ro.lproj/SUUpdatePermissionPrompt.xib @@ -15,18 +15,18 @@ - + - + - + @@ -161,7 +161,7 @@ This is the information that would be sent: - + diff --git a/Sparkle/ru.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/ru.lproj/SUAutomaticUpdateAlert.xib index 345a3498..2b364d86 100644 --- a/Sparkle/ru.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/ru.lproj/SUAutomaticUpdateAlert.xib @@ -11,14 +11,14 @@ - + - - + + - + @@ -31,7 +31,7 @@ - + @@ -44,7 +44,7 @@ - + @@ -57,7 +57,7 @@ - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,7 +251,7 @@ DQ - + diff --git a/Sparkle/ru.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/ru.lproj/SUUpdatePermissionPrompt.xib index 246684ee..8033cbda 100644 --- a/Sparkle/ru.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/ru.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -18,15 +18,15 @@ - + - + - + @@ -66,7 +66,7 @@ Gw - + @@ -111,7 +111,7 @@ Gw - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,6 +251,7 @@ DQ + diff --git a/Sparkle/sk.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/sk.lproj/SUUpdatePermissionPrompt.xib index 9077b34b..289afe4b 100644 --- a/Sparkle/sk.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/sk.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -18,7 +18,7 @@ - + @@ -26,7 +26,7 @@ - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,7 +251,7 @@ DQ - + diff --git a/Sparkle/sl.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/sl.lproj/SUUpdatePermissionPrompt.xib index 92854846..c6622506 100644 --- a/Sparkle/sl.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/sl.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -18,15 +18,15 @@ - + - + - + @@ -161,7 +161,7 @@ Pošljejo se sledeče informacije: - + @@ -177,7 +177,7 @@ Pošljejo se sledeče informacije: - + @@ -193,7 +193,7 @@ Pošljejo se sledeče informacije: - + diff --git a/Sparkle/sv.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/sv.lproj/SUAutomaticUpdateAlert.xib index dfc1f204..a9b3a383 100644 --- a/Sparkle/sv.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/sv.lproj/SUAutomaticUpdateAlert.xib @@ -11,14 +11,14 @@ - + - + - + @@ -31,7 +31,7 @@ - + @@ -44,7 +44,7 @@ - + @@ -57,7 +57,7 @@ - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,7 +251,7 @@ DQ - + diff --git a/Sparkle/sv.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/sv.lproj/SUUpdatePermissionPrompt.xib index 8e1f2934..3e44afc9 100644 --- a/Sparkle/sv.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/sv.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -18,15 +18,15 @@ - + - + - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,6 +251,7 @@ DQ + diff --git a/Sparkle/th.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/th.lproj/SUUpdatePermissionPrompt.xib index c176e21a..22934759 100644 --- a/Sparkle/th.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/th.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -60,7 +60,7 @@ Gw - + @@ -146,7 +146,7 @@ Gw - + @@ -159,10 +159,10 @@ Gw - + - - + + diff --git a/Sparkle/tr.lproj/SUAutomaticUpdateAlert.xib b/Sparkle/tr.lproj/SUAutomaticUpdateAlert.xib index ded2abf1..cb71c309 100644 --- a/Sparkle/tr.lproj/SUAutomaticUpdateAlert.xib +++ b/Sparkle/tr.lproj/SUAutomaticUpdateAlert.xib @@ -11,14 +11,14 @@ - + - - + + - + @@ -31,7 +31,7 @@ - + @@ -44,7 +44,7 @@ - + @@ -57,7 +57,7 @@ - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,6 +251,7 @@ DQ + diff --git a/Sparkle/tr.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/tr.lproj/SUUpdatePermissionPrompt.xib index 9e67f0e5..52c35992 100644 --- a/Sparkle/tr.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/tr.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -26,10 +26,10 @@ - + - + @@ -69,7 +69,7 @@ Gw - + @@ -82,7 +82,7 @@ Gw - + @@ -104,16 +104,16 @@ Gw - + - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,7 +251,7 @@ DQ - + diff --git a/Sparkle/uk.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/uk.lproj/SUUpdatePermissionPrompt.xib index 724e5e91..35692371 100644 --- a/Sparkle/uk.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/uk.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -18,15 +18,15 @@ - + - + - + @@ -66,7 +66,7 @@ Gw - + @@ -111,7 +111,7 @@ Gw - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,6 +251,7 @@ DQ + diff --git a/Sparkle/zh_CN.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/zh_CN.lproj/SUUpdatePermissionPrompt.xib index 61cc3ccf..0245ed0f 100644 --- a/Sparkle/zh_CN.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/zh_CN.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -26,7 +26,7 @@ - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + @@ -233,6 +251,7 @@ DQ + diff --git a/Sparkle/zh_TW.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/zh_TW.lproj/SUUpdatePermissionPrompt.xib index b64dbd78..d37a5395 100644 --- a/Sparkle/zh_TW.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/zh_TW.lproj/SUUpdatePermissionPrompt.xib @@ -9,7 +9,7 @@ - + @@ -18,15 +18,15 @@ - + - + - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - - NSNegateBoolean - - - - - - - - - - - - - - - - - - - - - + - - - + + - - - + + - - - + + + - + - + diff --git a/Sparkle/ar.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/ar.lproj/SUUpdatePermissionPrompt.xib index b428f166..95de0d26 100755 --- a/Sparkle/ar.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/ar.lproj/SUUpdatePermissionPrompt.xib @@ -9,6 +9,7 @@ + @@ -18,14 +19,14 @@ - + - + @@ -65,7 +66,7 @@ Gw - + @@ -78,7 +79,7 @@ Gw - + @@ -109,10 +110,10 @@ Gw - + diff --git a/Sparkle/el.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/el.lproj/SUUpdatePermissionPrompt.xib index c1f01b1d..4049a836 100644 --- a/Sparkle/el.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/el.lproj/SUUpdatePermissionPrompt.xib @@ -1,7 +1,8 @@ - + - + + @@ -26,7 +27,7 @@ - + @@ -66,7 +67,7 @@ Gw - + @@ -129,6 +130,7 @@ Gw + diff --git a/Sparkle/fr.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/fr.lproj/SUUpdatePermissionPrompt.xib index 97b8bec6..0a5efa67 100644 --- a/Sparkle/fr.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/fr.lproj/SUUpdatePermissionPrompt.xib @@ -1,7 +1,8 @@ - + - + + @@ -26,7 +27,7 @@ - - - - - - - - - - @@ -126,6 +117,16 @@ Gw + + + + + + + + + + diff --git a/Sparkle/is.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/is.lproj/SUUpdatePermissionPrompt.xib index 1cfc2023..926a28cc 100644 --- a/Sparkle/is.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/is.lproj/SUUpdatePermissionPrompt.xib @@ -1,7 +1,8 @@ - + - + + @@ -26,7 +27,7 @@ - + diff --git a/Sparkle/ja.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/ja.lproj/SUUpdatePermissionPrompt.xib index 83a061bd..afd45ef0 100644 --- a/Sparkle/ja.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/ja.lproj/SUUpdatePermissionPrompt.xib @@ -1,7 +1,8 @@ - + - + + @@ -26,7 +27,7 @@ - + @@ -101,7 +102,7 @@ Gw - + @@ -110,7 +111,7 @@ Gw - + @@ -66,7 +67,7 @@ Gw - + @@ -129,6 +130,7 @@ Gw + diff --git a/Sparkle/sv.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/sv.lproj/SUUpdatePermissionPrompt.xib index 3e44afc9..44ffe6fe 100644 --- a/Sparkle/sv.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/sv.lproj/SUUpdatePermissionPrompt.xib @@ -1,7 +1,8 @@ - + - + + @@ -26,7 +27,7 @@ - + @@ -66,7 +67,7 @@ Gw - + @@ -129,6 +130,7 @@ Gw + diff --git a/Sparkle/zh_CN.lproj/SUUpdatePermissionPrompt.xib b/Sparkle/zh_CN.lproj/SUUpdatePermissionPrompt.xib index 0245ed0f..f51d7fc7 100644 --- a/Sparkle/zh_CN.lproj/SUUpdatePermissionPrompt.xib +++ b/Sparkle/zh_CN.lproj/SUUpdatePermissionPrompt.xib @@ -1,7 +1,8 @@ - + - + + @@ -26,7 +27,7 @@