diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 549fa9ed..3e91fab1 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -81,13 +81,10 @@ 5D06E8E90FD68CDB005AE3F6 /* bsdiff.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */; settings = {COMPILER_FLAGS = "-w"; }; }; 5D06E8EA0FD68CDB005AE3F6 /* SUBinaryDeltaTool.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8E30FD68CC7005AE3F6 /* SUBinaryDeltaTool.m */; }; 5D06E8EB0FD68CE4005AE3F6 /* bspatch.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */; settings = {COMPILER_FLAGS = "-w"; }; }; - 5D06E8EC0FD68CE4005AE3F6 /* SUBinaryDeltaApply.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8E00FD68CC7005AE3F6 /* SUBinaryDeltaApply.m */; }; - 5D06E8ED0FD68CE4005AE3F6 /* SUBinaryDeltaCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8E20FD68CC7005AE3F6 /* SUBinaryDeltaCommon.m */; }; 5D06E8FD0FD68D6B005AE3F6 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D06E8FB0FD68D61005AE3F6 /* libbz2.dylib */; }; 5D06E8FF0FD68D6D005AE3F6 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D06E8FB0FD68D61005AE3F6 /* libbz2.dylib */; }; 5D06E9050FD68D7D005AE3F6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; }; 5D06E9390FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D06E9370FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.h */; }; - 5D06E93A0FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E9380FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.m */; }; 5D1AF58A0FD7678C0065DB48 /* libxar.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5890FD7678C0065DB48 /* libxar.1.dylib */; }; 5D1AF58B0FD7678C0065DB48 /* libxar.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5890FD7678C0065DB48 /* libxar.1.dylib */; }; 5D1AF5900FD767AD0065DB48 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF58F0FD767AD0065DB48 /* libxml2.dylib */; }; @@ -99,28 +96,22 @@ 6101347C0DD2541A0049ACDF /* SUProbingUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6101347A0DD2541A0049ACDF /* SUProbingUpdateDriver.m */; }; 6102FE460E077FCE00F85D09 /* SUPipedUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE440E077FCE00F85D09 /* SUPipedUnarchiver.h */; settings = {ATTRIBUTES = (); }; }; 6102FE4A0E07803800F85D09 /* SUDiskImageUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE480E07803800F85D09 /* SUDiskImageUnarchiver.h */; settings = {ATTRIBUTES = (); }; }; - 6102FE4B0E07803800F85D09 /* SUDiskImageUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */; }; 6102FE5B0E08C7EC00F85D09 /* SUUnarchiver_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */; settings = {ATTRIBUTES = (); }; }; 611142E910FB1BE5009810AA /* bspatch.h in Headers */ = {isa = PBXBuildFile; fileRef = 611142E810FB1BE5009810AA /* bspatch.h */; }; 6120721209CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.h in Headers */ = {isa = PBXBuildFile; fileRef = 6120721009CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.h */; settings = {ATTRIBUTES = (); }; }; 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"; }; }; 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, ); }; }; - 61299A8E09CA790200B7442F /* SUUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A8C09CA790200B7442F /* SUUnarchiver.m */; }; 61299B3609CB04E000B7442F /* Sparkle.h in Headers */ = {isa = PBXBuildFile; fileRef = 61299B3509CB04E000B7442F /* Sparkle.h */; settings = {ATTRIBUTES = (Public, ); }; }; 612DCBAF0D488BC60015DBEA /* SUUpdatePermissionPrompt.h in Headers */ = {isa = PBXBuildFile; fileRef = 612DCBAD0D488BC60015DBEA /* SUUpdatePermissionPrompt.h */; settings = {ATTRIBUTES = (); }; }; 612DCBB00D488BC60015DBEA /* SUUpdatePermissionPrompt.m in Sources */ = {isa = PBXBuildFile; fileRef = 612DCBAE0D488BC60015DBEA /* SUUpdatePermissionPrompt.m */; }; 6158A1C5137904B300487EC1 /* SUUpdater_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 6158A1C4137904B300487EC1 /* SUUpdater_Private.h */; }; 615AE3D00D64DC40001CA7BD /* SUModelTranslation.plist in Resources */ = {isa = PBXBuildFile; fileRef = 615AE3CF0D64DC40001CA7BD /* SUModelTranslation.plist */; }; 618FA5010DAE88B40026945C /* SUInstaller.h in Headers */ = {isa = PBXBuildFile; fileRef = 618FA4FF0DAE88B40026945C /* SUInstaller.h */; settings = {ATTRIBUTES = (); }; }; - 618FA5020DAE88B40026945C /* SUInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 618FA5000DAE88B40026945C /* SUInstaller.m */; }; 618FA5050DAE8AB80026945C /* SUPlainInstaller.h in Headers */ = {isa = PBXBuildFile; fileRef = 618FA5030DAE8AB80026945C /* SUPlainInstaller.h */; settings = {ATTRIBUTES = (); }; }; - 618FA5060DAE8AB80026945C /* SUPlainInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 618FA5040DAE8AB80026945C /* SUPlainInstaller.m */; }; 618FA5220DAE8E8A0026945C /* SUPackageInstaller.h in Headers */ = {isa = PBXBuildFile; fileRef = 618FA5200DAE8E8A0026945C /* SUPackageInstaller.h */; settings = {ATTRIBUTES = (); }; }; - 618FA5230DAE8E8A0026945C /* SUPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 618FA5210DAE8E8A0026945C /* SUPackageInstaller.m */; }; 6196CFF909C72148000DC222 /* SUStatusController.h in Headers */ = {isa = PBXBuildFile; fileRef = 6196CFE309C71ADE000DC222 /* SUStatusController.h */; settings = {ATTRIBUTES = (); }; }; 6196CFFA09C72149000DC222 /* SUStatusController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6196CFE409C71ADE000DC222 /* SUStatusController.m */; }; 61A2259E0D1C495D00430CCD /* SUVersionComparisonProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 61A2259C0D1C495D00430CCD /* SUVersionComparisonProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -132,7 +123,6 @@ 61A354560DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61A354540DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.m */; }; 61AAE8280A321A7F00D8810D /* Sparkle.strings in Resources */ = {isa = PBXBuildFile; fileRef = 61AAE8220A321A7F00D8810D /* Sparkle.strings */; }; 61B078CE15A5FB6100600039 /* SUCodeSigningVerifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 61B078CC15A5FB6100600039 /* SUCodeSigningVerifier.h */; }; - 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 */; }; 61B5F8F709C4CEB300B25A18 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B5F8F609C4CEB300B25A18 /* Security.framework */; }; @@ -154,7 +144,6 @@ 61B93C090DD112FF00DCD2F8 /* SUScheduledUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 61B93C070DD112FF00DCD2F8 /* SUScheduledUpdateDriver.h */; settings = {ATTRIBUTES = (); }; }; 61B93C0A0DD112FF00DCD2F8 /* SUScheduledUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B93C080DD112FF00DCD2F8 /* SUScheduledUpdateDriver.m */; }; 61CFB3290E385186007A1735 /* Sparkle.pch in Headers */ = {isa = PBXBuildFile; fileRef = 61CFB3280E385186007A1735 /* Sparkle.pch */; }; - 61D85D6D0E10B2ED00F9B4A9 /* SUPipedUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6129C0B90E0B79810062CE76 /* SUPipedUnarchiver.m */; }; 61EF67560E25B58D00F754E0 /* SUHost.m in Sources */ = {isa = PBXBuildFile; fileRef = 61EF67550E25B58D00F754E0 /* SUHost.m */; }; 61EF67590E25C5B400F754E0 /* SUHost.h in Headers */ = {isa = PBXBuildFile; fileRef = 61EF67580E25C5B400F754E0 /* SUHost.h */; }; 61F83F720DBFE140006FDD30 /* SUBasicUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61F83F700DBFE137006FDD30 /* SUBasicUpdateDriver.m */; }; @@ -212,6 +201,17 @@ 7275F9C31B5F1F2900B1D19E /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; }; 729746201C8E8D9A00FC134E /* TerminationListener.m in Sources */ = {isa = PBXBuildFile; fileRef = 7297461F1C8E8D9A00FC134E /* TerminationListener.m */; }; 729746231C8E8F1100FC134E /* AppInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 729746221C8E8F1100FC134E /* AppInstaller.m */; }; + 729746371C8FC04600FC134E /* SUUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A8C09CA790200B7442F /* SUUnarchiver.m */; }; + 729746381C8FC04B00FC134E /* SUPipedUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6129C0B90E0B79810062CE76 /* SUPipedUnarchiver.m */; }; + 729746391C8FC04F00FC134E /* SUDiskImageUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */; }; + 7297463A1C8FCA4900FC134E /* SUDSAVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A2E09CA2DAB00B7442F /* SUDSAVerifier.m */; }; + 7297463C1C8FF6AE00FC134E /* SUCodeSigningVerifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 61B078CD15A5FB6100600039 /* SUCodeSigningVerifier.m */; }; + 729746401C9119F300FC134E /* SULocalMessagePort.h in Headers */ = {isa = PBXBuildFile; fileRef = 7297463E1C9119F300FC134E /* SULocalMessagePort.h */; }; + 729746411C9119F300FC134E /* SULocalMessagePort.m in Sources */ = {isa = PBXBuildFile; fileRef = 7297463F1C9119F300FC134E /* SULocalMessagePort.m */; }; + 729746421C9119F300FC134E /* SULocalMessagePort.m in Sources */ = {isa = PBXBuildFile; fileRef = 7297463F1C9119F300FC134E /* SULocalMessagePort.m */; }; + 729746451C91212400FC134E /* SURemoteMessagePort.h in Headers */ = {isa = PBXBuildFile; fileRef = 729746431C91212400FC134E /* SURemoteMessagePort.h */; }; + 729746461C91212400FC134E /* SURemoteMessagePort.m in Sources */ = {isa = PBXBuildFile; fileRef = 729746441C91212400FC134E /* SURemoteMessagePort.m */; }; + 729746471C91212400FC134E /* SURemoteMessagePort.m in Sources */ = {isa = PBXBuildFile; fileRef = 729746441C91212400FC134E /* SURemoteMessagePort.m */; }; 72A450531C69A68900D67EEA /* SUUpdatePermissionPromptResult.h in Headers */ = {isa = PBXBuildFile; fileRef = 72A450511C69A68900D67EEA /* SUUpdatePermissionPromptResult.h */; settings = {ATTRIBUTES = (Public, ); }; }; 72A450541C69A68900D67EEA /* SUUpdatePermissionPromptResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 72A450521C69A68900D67EEA /* SUUpdatePermissionPromptResult.m */; }; 72A4A2401BB6567D00E7820D /* SUFileManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 72A4A23F1BB6567D00E7820D /* SUFileManagerTest.swift */; }; @@ -228,7 +228,6 @@ 72E45CFE1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem in Resources */ = {isa = PBXBuildFile; fileRef = 72E45CFD1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem */; }; 72E45DDD1B65C3BD005C701A /* sign_update in Resources */ = {isa = PBXBuildFile; fileRef = 72E45DDC1B65C3BD005C701A /* sign_update */; }; 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 */; }; C23E885B1BE7B24F0050BB73 /* SparkleTestCodeSignApp.enc.dmg in Resources */ = {isa = PBXBuildFile; fileRef = C23E88591BE7AF890050BB73 /* SparkleTestCodeSignApp.enc.dmg */; }; F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F8761EB01ADC5068000C9034 /* SUCodeSigningVerifierTest.m */; }; @@ -716,6 +715,10 @@ 7297461F1C8E8D9A00FC134E /* TerminationListener.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TerminationListener.m; sourceTree = ""; }; 729746211C8E8F1100FC134E /* AppInstaller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppInstaller.h; sourceTree = ""; }; 729746221C8E8F1100FC134E /* AppInstaller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppInstaller.m; sourceTree = ""; }; + 7297463E1C9119F300FC134E /* SULocalMessagePort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SULocalMessagePort.h; path = Sparkle/SULocalMessagePort.h; sourceTree = SOURCE_ROOT; }; + 7297463F1C9119F300FC134E /* SULocalMessagePort.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SULocalMessagePort.m; path = Sparkle/SULocalMessagePort.m; sourceTree = SOURCE_ROOT; }; + 729746431C91212400FC134E /* SURemoteMessagePort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SURemoteMessagePort.h; path = ../SURemoteMessagePort.h; sourceTree = ""; }; + 729746441C91212400FC134E /* SURemoteMessagePort.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SURemoteMessagePort.m; path = ../SURemoteMessagePort.m; sourceTree = ""; }; 729F10FD1C65A9B500DFCCC5 /* ConfigUITest.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITest.xcconfig; sourceTree = ""; }; 729F10FE1C65A9B500DFCCC5 /* ConfigUITestCoverage.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestCoverage.xcconfig; sourceTree = ""; }; 729F10FF1C65A9B500DFCCC5 /* ConfigUITestDebug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigUITestDebug.xcconfig; sourceTree = ""; }; @@ -970,9 +973,7 @@ 61299B3909CB055000B7442F /* Appcast Support */, 55C14BD5136EEFD000649790 /* Autoupdate */, 089C1665FE841158C02AAC07 /* Framework Resources */, - 618FA6DB0DB485440026945C /* Installation */, 61B5F8F309C4CE5900B25A18 /* Other Sources */, - 6101354A0DD25B7F0049ACDF /* Unarchiving */, 61F83F6E0DBFE07A006FDD30 /* Update Control */, 61299B3A09CB056100B7442F /* User Interface */, ); @@ -1000,12 +1001,16 @@ 55C14BD5136EEFD000649790 /* Autoupdate */ = { isa = PBXGroup; children = ( + 61CFB2C10E384958007A1735 /* Verifiers */, + 6101354A0DD25B7F0049ACDF /* Unarchiving */, + 618FA6DB0DB485440026945C /* Installation */, 55C14BB9136EEF1500649790 /* Autoupdate-Info.plist */, 55C14BD3136EEFCE00649790 /* Autoupdate.m */, 729746211C8E8F1100FC134E /* AppInstaller.h */, 729746221C8E8F1100FC134E /* AppInstaller.m */, 7297461E1C8E8D9A00FC134E /* TerminationListener.h */, 7297461F1C8E8D9A00FC134E /* TerminationListener.m */, + 729746481C91483B00FC134E /* IPC */, ); path = Autoupdate; sourceTree = ""; @@ -1039,6 +1044,7 @@ 6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */, ); name = Unarchiving; + path = ..; sourceTree = ""; }; 61227A100DB5484000AB99EA /* Tests */ = { @@ -1110,6 +1116,7 @@ 618FA5040DAE8AB80026945C /* SUPlainInstaller.m */, ); name = Installation; + path = ..; sourceTree = ""; }; 61B5F8F309C4CE5900B25A18 /* Other Sources */ = { @@ -1171,7 +1178,7 @@ path = TestApplication; sourceTree = ""; }; - 61CFB2C10E384958007A1735 /* Support */ = { + 61CFB2C10E384958007A1735 /* Verifiers */ = { isa = PBXGroup; children = ( 61B078CC15A5FB6100600039 /* SUCodeSigningVerifier.h */, @@ -1179,7 +1186,8 @@ 61299A2D09CA2DAB00B7442F /* SUDSAVerifier.h */, 61299A2E09CA2DAB00B7442F /* SUDSAVerifier.m */, ); - name = Support; + name = Verifiers; + path = ..; sourceTree = ""; }; 61CFB2C20E38496B007A1735 /* Drivers */ = { @@ -1211,7 +1219,6 @@ isa = PBXGroup; children = ( 61CFB2C20E38496B007A1735 /* Drivers */, - 61CFB2C10E384958007A1735 /* Support */, 61B5F8E309C4CE3C00B25A18 /* SUUpdater.h */, 61B5F8E409C4CE3C00B25A18 /* SUUpdater.m */, 6158A1C4137904B300487EC1 /* SUUpdater_Private.h */, @@ -1258,6 +1265,17 @@ path = ../TestAppHelper; sourceTree = ""; }; + 729746481C91483B00FC134E /* IPC */ = { + isa = PBXGroup; + children = ( + 7297463E1C9119F300FC134E /* SULocalMessagePort.h */, + 7297463F1C9119F300FC134E /* SULocalMessagePort.m */, + 729746431C91212400FC134E /* SURemoteMessagePort.h */, + 729746441C91212400FC134E /* SURemoteMessagePort.m */, + ); + name = IPC; + sourceTree = ""; + }; FA1941C40D94A6EA00DD942E /* Configurations */ = { isa = PBXGroup; children = ( @@ -1313,6 +1331,7 @@ 726DF88E1C84277600188804 /* SUStatusCompletionResults.h in Headers */, 72A450531C69A68900D67EEA /* SUUpdatePermissionPromptResult.h in Headers */, 611142E910FB1BE5009810AA /* bspatch.h in Headers */, + 729746401C9119F300FC134E /* SULocalMessagePort.h in Headers */, 61299B3609CB04E000B7442F /* Sparkle.h in Headers */, 61CFB3290E385186007A1735 /* Sparkle.pch in Headers */, 72162B081C82C9600013C1C5 /* SULocalizations.h in Headers */, @@ -1343,6 +1362,7 @@ 61B93C090DD112FF00DCD2F8 /* SUScheduledUpdateDriver.h in Headers */, 61A225A40D1C4AC000430CCD /* SUStandardVersionComparator.h in Headers */, 725F977B1C8A896F00265BE4 /* SUUserDriverCoreComponent.h in Headers */, + 729746451C91212400FC134E /* SURemoteMessagePort.h in Headers */, 6196CFF909C72148000DC222 /* SUStatusController.h in Headers */, 61A2279C0D1CEE7600430CCD /* SUSystemProfiler.h in Headers */, 61B93A3C0DD02D7000DCD2F8 /* SUUIBasedUpdateDriver.h in Headers */, @@ -1559,6 +1579,11 @@ }; 726E4A151C86C88F00C57C6A = { CreatedOnToolsVersion = 7.2.1; + SystemCapabilities = { + com.apple.Sandbox = { + enabled = 0; + }; + }; }; }; }; @@ -1780,6 +1805,10 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 7297463A1C8FCA4900FC134E /* SUDSAVerifier.m in Sources */, + 729746391C8FC04F00FC134E /* SUDiskImageUnarchiver.m in Sources */, + 729746381C8FC04B00FC134E /* SUPipedUnarchiver.m in Sources */, + 729746371C8FC04600FC134E /* SUUnarchiver.m in Sources */, 729746201C8E8D9A00FC134E /* TerminationListener.m in Sources */, 725602D71C83576100DAA70E /* SUApplicationInfo.m in Sources */, 55C14BD4136EEFCE00649790 /* Autoupdate.m in Sources */, @@ -1793,9 +1822,11 @@ 55C14F08136EF6DB00649790 /* SULog.m in Sources */, 726F2CE71BC9C3E2001971A4 /* SUOperatingSystem.m in Sources */, 55C14F24136EF86F00649790 /* SUPackageInstaller.m in Sources */, + 729746471C91212400FC134E /* SURemoteMessagePort.m in Sources */, 55C14F21136EF84D00649790 /* SUPlainInstaller.m in Sources */, 55C14F22136EF86000649790 /* SUStandardVersionComparator.m in Sources */, 55C14F20136EF84300649790 /* SUStatusController.m in Sources */, + 729746421C9119F300FC134E /* SULocalMessagePort.m in Sources */, 55C14F23136EF86700649790 /* SUSystemProfiler.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1876,32 +1907,23 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 7297463C1C8FF6AE00FC134E /* SUCodeSigningVerifier.m in Sources */, 5D06E8EB0FD68CE4005AE3F6 /* bspatch.c in Sources */, 61B5FBB709C4FAFF00B25A18 /* SUAppcast.m in Sources */, 61B5FC6F09C51F4900B25A18 /* SUAppcastItem.m in Sources */, 6120721309CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.m in Sources */, 61B93B280DD0FDD300DCD2F8 /* SUAutomaticUpdateDriver.m in Sources */, 61F83F720DBFE140006FDD30 /* SUBasicUpdateDriver.m in Sources */, - 5D06E8EC0FD68CE4005AE3F6 /* SUBinaryDeltaApply.m in Sources */, - 5D06E8ED0FD68CE4005AE3F6 /* SUBinaryDeltaCommon.m in Sources */, - 5D06E93A0FD69271005AE3F6 /* SUBinaryDeltaUnarchiver.m in Sources */, - 61B078CF15A5FB6100600039 /* SUCodeSigningVerifier.m in Sources */, 61299A6009CA6EB100B7442F /* SUConstants.m in Sources */, - 6102FE4B0E07803800F85D09 /* SUDiskImageUnarchiver.m in Sources */, - 61299A3009CA2DAB00B7442F /* SUDSAVerifier.m in Sources */, 725602D61C83551C00DAA70E /* SUApplicationInfo.m in Sources */, 72A450541C69A68900D67EEA /* SUUpdatePermissionPromptResult.m in Sources */, + 729746411C9119F300FC134E /* SULocalMessagePort.m in Sources */, 7275F9C21B5F1F2900B1D19E /* SUFileManager.m in Sources */, - 767B61AD1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */, 725CB95B1C7121830064365A /* SUStandardUserDriver.m in Sources */, 61EF67560E25B58D00F754E0 /* SUHost.m in Sources */, - 618FA5020DAE88B40026945C /* SUInstaller.m in Sources */, 55C14F07136EF6DB00649790 /* SULog.m in Sources */, 726F2CE61BC9C33D001971A4 /* SUOperatingSystem.m in Sources */, - 618FA5230DAE8E8A0026945C /* SUPackageInstaller.m in Sources */, - 61D85D6D0E10B2ED00F9B4A9 /* SUPipedUnarchiver.m in Sources */, 725F97801C8A93D700265BE4 /* SUUserDriverUIComponent.m in Sources */, - 618FA5060DAE8AB80026945C /* SUPlainInstaller.m in Sources */, 6101347C0DD2541A0049ACDF /* SUProbingUpdateDriver.m in Sources */, 61B93C0A0DD112FF00DCD2F8 /* SUScheduledUpdateDriver.m in Sources */, 61A225A50D1C4AC000430CCD /* SUStandardVersionComparator.m in Sources */, @@ -1909,13 +1931,13 @@ 61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */, 61B93A3D0DD02D7000DCD2F8 /* SUUIBasedUpdateDriver.m in Sources */, 7246E0A41C83B685003B4E75 /* SUStandardUpdaterController.m in Sources */, - 61299A8E09CA790200B7442F /* SUUnarchiver.m in Sources */, 725F977C1C8A896F00265BE4 /* SUUserDriverCoreComponent.m in Sources */, 61B5FCDE09C52A9F00B25A18 /* SUUpdateAlert.m in Sources */, 610134740DD250470049ACDF /* SUUpdateDriver.m in Sources */, 612DCBB00D488BC60015DBEA /* SUUpdatePermissionPrompt.m in Sources */, 61B5F8EE09C4CE3C00B25A18 /* SUUpdater.m in Sources */, 61A354560DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.m in Sources */, + 729746461C91212400FC134E /* SURemoteMessagePort.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Sparkle/Autoupdate/AppInstaller.h b/Sparkle/Autoupdate/AppInstaller.h index 714135ba..01fdd84a 100644 --- a/Sparkle/Autoupdate/AppInstaller.h +++ b/Sparkle/Autoupdate/AppInstaller.h @@ -7,11 +7,14 @@ // #import +#import "SUUnarchiver.h" -@interface AppInstaller : NSObject +@interface AppInstaller : NSObject -- (instancetype)initWithHostPath:(NSString *)hostPath relaunchPath:(NSString *)relaunchPath hostProcessIdentifier:(NSNumber *)hostProcessIdentifier updateFolderPath:(NSString *)updateFolderPath shouldRelaunch:(BOOL)shouldRelaunch shouldShowUI:(BOOL)shouldShowUI; +- (instancetype)initWithHostPath:(NSString *)hostPath relaunchPath:(NSString *)relaunchPath hostProcessIdentifier:(NSNumber *)hostProcessIdentifier updateFolderPath:(NSString *)updateFolderPath downloadPath:(NSString *)downloadPath dsaSignature:(NSString *)dsaSignature; - (void)installAfterHostTermination; +- (void)extractUpdate; + @end diff --git a/Sparkle/Autoupdate/AppInstaller.m b/Sparkle/Autoupdate/AppInstaller.m index 066178a9..9da5af99 100644 --- a/Sparkle/Autoupdate/AppInstaller.m +++ b/Sparkle/Autoupdate/AppInstaller.m @@ -14,6 +14,10 @@ #import "SUHost.h" #import "SULocalizations.h" #import "SUStandardVersionComparator.h" +#import "SUDSAVerifier.h" +#import "SUCodeSigningVerifier.h" +#import "SURemoteMessagePort.h" +#import "SULocalMessagePort.h" /*! * If the Installation takes longer than this time the Application Icon is shown in the Dock so that the user has some feedback. @@ -32,8 +36,12 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5; @property (nonatomic, strong) TerminationListener *terminationListener; @property (nonatomic, strong) SUStatusController *statusController; +@property (nonatomic) SUHost *host; +@property (nonatomic) SULocalMessagePort *localPort; +@property (nonatomic) SURemoteMessagePort *remotePort; @property (nonatomic, copy) NSString *updateFolderPath; -@property (nonatomic, copy) NSString *hostPath; +@property (nonatomic, copy) NSString *downloadPath; +@property (nonatomic, copy) NSString *dsaSignature; @property (nonatomic, copy) NSString *relaunchPath; @property (nonatomic, assign) BOOL shouldRelaunch; @property (nonatomic, assign) BOOL shouldShowUI; @@ -46,8 +54,12 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5; @synthesize terminationListener = _terminationListener; @synthesize statusController = _statusController; +@synthesize localPort = _localPort; +@synthesize remotePort = _remotePort; +@synthesize host = _host; @synthesize updateFolderPath = _updateFolderPath; -@synthesize hostPath = _hostPath; +@synthesize downloadPath = _downloadPath; +@synthesize dsaSignature = _dsaSignature; @synthesize relaunchPath = _relaunchPath; @synthesize shouldRelaunch = _shouldRelaunch; @synthesize shouldShowUI = _shouldShowUI; @@ -57,26 +69,233 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5; * hostPath - path to host (original) application * relaunchPath - path to what the host wants to relaunch (default is same as hostPath) * hostProcessIdentifier - process identifier of the host before launching us - * updateFolderPath - path to update folder (i.e, temporary directory containing the new update) + * updateFolderPath - path to update folder (i.e, temporary directory containing the new update archive) + * downloadPath - path to new downloaded update archive * shouldRelaunch - indicates if the new installed app should re-launched * shouldShowUI - indicates if we should show the status window when installing the update */ -- (instancetype)initWithHostPath:(NSString *)hostPath relaunchPath:(NSString *)relaunchPath hostProcessIdentifier:(NSNumber *)hostProcessIdentifier updateFolderPath:(NSString *)updateFolderPath shouldRelaunch:(BOOL)shouldRelaunch shouldShowUI:(BOOL)shouldShowUI +- (instancetype)initWithHostPath:(NSString *)hostPath relaunchPath:(NSString *)relaunchPath hostProcessIdentifier:(NSNumber *)hostProcessIdentifier updateFolderPath:(NSString *)updateFolderPath downloadPath:(NSString *)downloadPath dsaSignature:(NSString *)dsaSignature { if (!(self = [super init])) { return nil; } - self.hostPath = hostPath; + NSBundle *bundle = [NSBundle bundleWithPath:hostPath]; + self.host = [[SUHost alloc] initWithBundle:bundle]; + self.relaunchPath = relaunchPath; self.terminationListener = [[TerminationListener alloc] initWithProcessIdentifier:hostProcessIdentifier]; self.updateFolderPath = updateFolderPath; - self.shouldRelaunch = shouldRelaunch; - self.shouldShowUI = shouldShowUI; + self.downloadPath = downloadPath; + self.dsaSignature = dsaSignature; + + NSBundle *hostBundle = [NSBundle bundleWithPath:hostPath]; + NSString *serviceName = [NSString stringWithFormat:@"%@-sparkle-updater", hostBundle.bundleIdentifier]; + + self.remotePort = [[SURemoteMessagePort alloc] initWithServiceName:serviceName invalidationCallback:^{ + dispatch_async(dispatch_get_main_queue(), ^{ + if (self.remotePort != nil) { + [self cleanupAndExitWithStatus:EXIT_FAILURE]; + } + }); + }]; + + if (self.remotePort == nil) { + SULog(@"We have failed you!!"); + [self cleanupAndExitWithStatus:EXIT_FAILURE]; + } return self; } +/** + * If the update is a package, then it must be signed using DSA. No other verification is done. + * + * If the update is a bundle, then it must meet any one of: + * + * * old and new DSA public keys are the same and valid (it allows change of Code Signing identity), or + * + * * old and new Code Signing identity are the same and valid + * + */ +- (BOOL)validateUpdateForHost:(SUHost *)host downloadedToPath:(NSString *)downloadedPath extractedToPath:(NSString *)extractedPath DSASignature:(NSString *)DSASignature +{ + BOOL isPackage = NO; + NSString *installSourcePath = [SUInstaller installSourcePathInUpdateFolder:extractedPath forHost:host isPackage:&isPackage isGuided:NULL]; + if (installSourcePath == nil) { + SULog(@"No suitable install is found in the update. The update will be rejected."); + return NO; + } + + NSString *publicDSAKey = host.publicDSAKey; + + // Modern packages are not distributed as bundles and are code signed differently than regular applications + if (isPackage) { + if (nil == publicDSAKey) { + SULog(@"The existing app bundle does not have a DSA key, so it can't verify installer packages."); + } + + BOOL packageValidated = [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey]; + + if (!packageValidated) { + SULog(@"DSA signature validation of the package failed. The update contains an installer package, and valid DSA signatures are mandatory for all installer packages. The update will be rejected. Sign the installer with a valid DSA key or use an .app bundle update instead."); + } + + return packageValidated; + } + + NSBundle *newBundle = [NSBundle bundleWithPath:installSourcePath]; + if (newBundle == nil) { + SULog(@"No suitable bundle is found in the update. The update will be rejected."); + return NO; + } + + SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle]; + NSString *newPublicDSAKey = newHost.publicDSAKey; + + BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey]; + + if (newPublicDSAKey != nil) { + if (![SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) { + SULog(@"DSA signature validation failed. The update has a public DSA key and is signed with a DSA key, but the %@ doesn't match the signature. The update will be rejected.", + dsaKeysMatch ? @"public key" : @"new public key shipped with the update"); + return NO; + } + } + + BOOL updateIsCodeSigned = [SUCodeSigningVerifier applicationAtPathIsCodeSigned:installSourcePath]; + + if (dsaKeysMatch) { + NSError *error = nil; + if (updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtPath:installSourcePath error:&error]) { + SULog(@"The update archive has a valid DSA signature, but the app is also signed with Code Signing, which is corrupted: %@. The update will be rejected.", error); + return NO; + } + } else { + NSString *hostBundlePath = host.bundlePath; + BOOL hostIsCodeSigned = [SUCodeSigningVerifier applicationAtPathIsCodeSigned:hostBundlePath]; + + NSString *dsaStatus = newPublicDSAKey ? @"has a new DSA key that doesn't match the previous one" : (publicDSAKey ? @"removes the DSA key" : @"isn't signed with a DSA key"); + if (!hostIsCodeSigned || !updateIsCodeSigned) { + NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with app Code Signing" : @"new app isn't signed with app Code Signing"; + SULog(@"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus); + return NO; + } + + NSError *error = nil; + if (![SUCodeSigningVerifier codeSignatureAtPath:hostBundlePath matchesSignatureAtPath:installSourcePath error:&error]) { + SULog(@"The update archive %@, and the app is signed with a new Code Signing identity that doesn't match code signing of the original app: %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, error); + return NO; + } + } + + return YES; +} + +- (void)extractUpdate +{ +#warning passing nothing for password atm + SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:self.host.bundlePath withPassword:nil]; + + if (!unarchiver) { + SULog(@"Error: No valid unarchiver for %@!", self.downloadPath); + [self unarchiverDidFail:nil]; + } else { + unarchiver.delegate = self; + [unarchiver start]; + } +} + +- (void)unarchiver:(SUUnarchiver *)__unused unarchiver extractedProgress:(double)progress +{ + NSData *data = [NSData dataWithBytes:&progress length:sizeof(progress)]; + if (![self.remotePort sendMessageWithIdentifier:1 data:data]) { + NSLog(@"Error sending extracted progress"); + } +} + +- (void)unarchiverDidFail:(SUUnarchiver *)__unused unarchiver +{ + NSLog(@"Unarchiving completely failed!"); + if (![self.remotePort sendMessageWithIdentifier:3 data:[NSData data]]) { + NSLog(@"Error sending extracted progress"); + } +} + +- (void)unarchiverDidFinish:(SUUnarchiver *)__unused unarchiver +{ + BOOL validationSuccess = [self validateUpdateForHost:self.host downloadedToPath:self.downloadPath extractedToPath:self.updateFolderPath DSASignature:self.dsaSignature]; + uint8_t success = (uint8_t)validationSuccess; + + NSData *validationData = [NSData dataWithBytes:&success length:sizeof(success)]; + if (![self.remotePort sendMessageWithIdentifier:2 data:validationData]) { + NSLog(@"Error sending validation success"); + } + + if (!validationSuccess) { + [self cleanupAndExitWithStatus:EXIT_FAILURE]; + } else { + // start listening now + NSString *serviceName = [NSString stringWithFormat:@"%@-sparkle-installer", self.host.bundle.bundleIdentifier]; + + self.localPort = + [[SULocalMessagePort alloc] + initWithServiceName:serviceName + messageCallback:^(int32_t identifier, NSData * _Nonnull data) { + dispatch_async(dispatch_get_main_queue(), ^{ + [self handleMessageWithIdentifier:identifier data:data]; + }); + } + invalidationCallback:^{ + dispatch_async(dispatch_get_main_queue(), ^{ + if (self.localPort != nil) { + [self cleanupAndExitWithStatus:EXIT_FAILURE]; + } + }); + }]; + + if (self.localPort == nil) { + SULog(@"We failed to create local port!"); + [self cleanupAndExitWithStatus:EXIT_FAILURE]; + } + + if (![self.remotePort sendMessageWithIdentifier:4 data:[NSData data]]) { + NSLog(@"Error sending wait-reply"); + [self cleanupAndExitWithStatus:EXIT_FAILURE]; + } else { + [self.remotePort invalidate]; + self.remotePort = nil; + } + } +} + +- (void)handleMessageWithIdentifier:(int32_t)identifier data:(NSData *)data +{ + BOOL shouldExit = YES; + + if (identifier == 1 && data.length == sizeof(uint8_t) * 3) { + uint8_t response = *(const uint8_t *)data.bytes; + if (response == 1) { + shouldExit = NO; + + [self.localPort invalidate]; + self.localPort = nil; + + uint8_t relaunch = *((const uint8_t *)data.bytes + 1); + uint8_t showsUI = *((const uint8_t *)data.bytes + 2); + + self.shouldRelaunch = (BOOL)relaunch; + self.shouldShowUI = (BOOL)showsUI; + + [self installAfterHostTermination]; + } + } + + if (shouldExit) { + [self cleanupAndExitWithStatus:EXIT_FAILURE]; + } +} + - (void)installAfterHostTermination { [self.terminationListener startListeningWithCompletion:^(BOOL success){ @@ -84,18 +303,18 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5; if (!success) { // We should just give up now - should we show an alert though?? - SULog(@"Timed out waiting for target to terminate. Target path is %@", self.hostPath); - [self cleanupAndExit]; + SULog(@"Timed out waiting for target to terminate. Target path is %@", self.host.bundlePath); + [self cleanupAndExitWithStatus:EXIT_FAILURE]; } else { - if (self.shouldShowUI) { - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(SUInstallationTimeLimit * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ - if (!self.isTerminating) { - // 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(), ^{ +// if (!self.isTerminating) { +// // Show app icon in the dock +// ProcessSerialNumber psn = { 0, kCurrentProcess }; +// TransformProcessType(&psn, kProcessTransformToForegroundApplication); +// } +// }); +// } [self install]; } @@ -104,39 +323,37 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5; - (void)install { - NSBundle *theBundle = [NSBundle bundleWithPath:self.hostPath]; - SUHost *host = [[SUHost alloc] initWithBundle:theBundle]; - NSString *installationPath = [[host installationPath] copy]; + NSString *installationPath = [[self.host installationPath] copy]; - if (self.shouldShowUI) { - 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: @""]; - [self.statusController showWindow:self]; - [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; - } +// if (self.shouldShowUI) { +// self.statusController = [[SUStatusController alloc] initWithHost:self.host]; +// [self.statusController setButtonTitle:SULocalizedString(@"Cancel Update", @"") target:nil action:Nil isDefault:NO]; +// [self.statusController beginActionWithTitle:SULocalizedString(@"Installing update...", @"") +// maxProgressValue: 0 statusText: @""]; +// [self.statusController showWindow:self]; +// [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; +// } [SUInstaller installFromUpdateFolder:self.updateFolderPath - overHost:host + overHost:self.host installationPath:installationPath versionComparator:[SUStandardVersionComparator defaultComparator] completionHandler:^(NSError *error) { if (error) { SULog(@"Installation Error: %@", error); - if (self.shouldShowUI) { - NSAlert *alert = [[NSAlert alloc] init]; - alert.messageText = @""; - alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]]; - [alert runModal]; - } - exit(EXIT_FAILURE); +// if (self.shouldShowUI) { +// NSAlert *alert = [[NSAlert alloc] init]; +// alert.messageText = @""; +// alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]]; +// [alert runModal]; +// } + [self cleanupAndExitWithStatus:EXIT_FAILURE]; } else { NSString *pathToRelaunch = nil; // If the installation path differs from the host path, we give higher precedence for it than // if the desired relaunch path differs from the host path - if (![installationPath.pathComponents isEqualToArray:self.hostPath.pathComponents] || [self.relaunchPath.pathComponents isEqualToArray:self.hostPath.pathComponents]) { + if (![installationPath.pathComponents isEqualToArray:self.host.bundlePath.pathComponents] || [self.relaunchPath.pathComponents isEqualToArray:self.host.bundlePath.pathComponents]) { pathToRelaunch = installationPath; } else { pathToRelaunch = self.relaunchPath; @@ -146,8 +363,16 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5; }]; } -- (void)cleanupAndExit __attribute__((noreturn)) +- (void)cleanupAndExitWithStatus:(int)status __attribute__((noreturn)) { + // It's nice to tell the other end we're invalidating + + [self.localPort invalidate]; + self.localPort = nil; + + [self.remotePort invalidate]; + self.remotePort = nil; + NSError *theError = nil; if (![[NSFileManager defaultManager] removeItemAtPath:self.updateFolderPath error:&theError]) { SULog(@"Couldn't remove update folder: %@.", theError); @@ -155,7 +380,7 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5; [[NSFileManager defaultManager] removeItemAtPath:[[NSBundle mainBundle] bundlePath] error:NULL]; - exit(EXIT_SUCCESS); + exit(status); } - (void)cleanupAndTerminateWithPathToRelaunch:(NSString *)relaunchPath @@ -180,10 +405,10 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5; // 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(), ^{ - [self cleanupAndExit]; + [self cleanupAndExitWithStatus:EXIT_SUCCESS]; }); } else { - [self cleanupAndExit]; + [self cleanupAndExitWithStatus:EXIT_SUCCESS]; } } diff --git a/Sparkle/Autoupdate/Autoupdate.m b/Sparkle/Autoupdate/Autoupdate.m index 543955d7..08f831a4 100644 --- a/Sparkle/Autoupdate/Autoupdate.m +++ b/Sparkle/Autoupdate/Autoupdate.m @@ -23,7 +23,8 @@ - (void)applicationDidFinishLaunching:(NSNotification __unused *)notification { - [self.appInstaller installAfterHostTermination]; + //[self.appInstaller installAfterHostTermination]; + [self.appInstaller extractUpdate]; } @end @@ -40,8 +41,8 @@ int main(int __unused argc, const char __unused *argv[]) NSString *relaunchPath = args[1]; NSString *hostBundlePath = args[2]; NSString *updateDirectoryPath = args[3]; - BOOL shouldRelaunchApp = [args[4] boolValue]; - BOOL shouldShowUI = [args[5] boolValue]; + NSString *downloadPath = args[4]; + NSString *dsaSignature = args[5]; BOOL shouldRelaunchTool = [args[6] boolValue]; if (shouldRelaunchTool) { @@ -83,12 +84,14 @@ int main(int __unused argc, const char __unused *argv[]) } } - AppInstaller *appInstaller = [[AppInstaller alloc] initWithHostPath:hostBundlePath - relaunchPath:relaunchPath - hostProcessIdentifier:activeProcessIdentifier - updateFolderPath:updateDirectoryPath - shouldRelaunch:shouldRelaunchApp - shouldShowUI:shouldShowUI]; + AppInstaller *appInstaller = + [[AppInstaller alloc] + initWithHostPath:hostBundlePath + relaunchPath:relaunchPath + hostProcessIdentifier:activeProcessIdentifier + updateFolderPath:updateDirectoryPath + downloadPath:downloadPath + dsaSignature:dsaSignature]; AppDelegate *delegate = [[AppDelegate alloc] initWithAppInstaller:appInstaller]; [application setDelegate:delegate]; diff --git a/Sparkle/SUAutomaticUpdateDriver.h b/Sparkle/SUAutomaticUpdateDriver.h index 38255561..f4d9ac4e 100644 --- a/Sparkle/SUAutomaticUpdateDriver.h +++ b/Sparkle/SUAutomaticUpdateDriver.h @@ -12,7 +12,7 @@ #import #import "SUBasicUpdateDriver.h" -@interface SUAutomaticUpdateDriver : SUBasicUpdateDriver +@interface SUAutomaticUpdateDriver : SUBasicUpdateDriver @end diff --git a/Sparkle/SUAutomaticUpdateDriver.m b/Sparkle/SUAutomaticUpdateDriver.m index ad14750f..4087ec1b 100644 --- a/Sparkle/SUAutomaticUpdateDriver.m +++ b/Sparkle/SUAutomaticUpdateDriver.m @@ -78,7 +78,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 // Overridden to do nothing: see -installUpdateWithTerminationStatus: as to why - (void)terminateApp { } -- (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua +- (void)installerIsReadyForRelaunch { [self.updater.userDriver registerApplicationTermination:^(SUApplicationTerminationStatus terminationStatus) { // We use -performSelectorOnMainThread:withObject:waitUntilDone: rather than GCD because if we are on the main thread already, diff --git a/Sparkle/SUBasicUpdateDriver.h b/Sparkle/SUBasicUpdateDriver.h index b5c7b832..266b6854 100644 --- a/Sparkle/SUBasicUpdateDriver.h +++ b/Sparkle/SUBasicUpdateDriver.h @@ -11,11 +11,10 @@ #import #import "SUUpdateDriver.h" -#import "SUUnarchiver.h" #import "SUAppcast.h" @class SUAppcastItem, SUHost; -@interface SUBasicUpdateDriver : SUUpdateDriver +@interface SUBasicUpdateDriver : SUUpdateDriver @property (strong, readonly) SUAppcastItem *updateItem; @property (strong, readonly) NSURLDownload *download; @@ -37,10 +36,12 @@ - (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error; - (void)extractUpdate; -- (void)unarchiverDidFinish:(SUUnarchiver *)ua; -- (void)unarchiverDidFail:(SUUnarchiver *)ua; +- (void)unarchiverExtractedProgress:(double)progress; - (void)failedToApplyDeltaUpdate; +- (void)installerDidStart; +- (void)installerIsReadyForRelaunch; + - (void)installWithToolAndRelaunch:(BOOL)relaunch; - (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI; diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 674f874f..c6a1ff47 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -12,19 +12,17 @@ #import "SUHost.h" #import "SUOperatingSystem.h" -#import "SUDSAVerifier.h" -#import "SUInstaller.h" #import "SUStandardVersionComparator.h" -#import "SUUnarchiver.h" #import "SUConstants.h" #import "SULog.h" #import "SUBinaryDeltaCommon.h" -#import "SUCodeSigningVerifier.h" #import "SUUpdater_Private.h" #import "SUFileManager.h" #import "SUErrors.h" #import "SULocalizations.h" #import "SUAppcastItem.h" +#import "SULocalMessagePort.h" +#import "SURemoteMessagePort.h" #ifdef _APPKITDEFINES_H #error This is a "core" class and should NOT import AppKit @@ -41,6 +39,9 @@ @property (nonatomic) BOOL postponedOnce; +@property (nonatomic) SULocalMessagePort *localPort; +@property (nonatomic) SURemoteMessagePort *remotePort; + @end @implementation SUBasicUpdateDriver @@ -54,6 +55,9 @@ @synthesize postponedOnce; +@synthesize localPort = _localPort; +@synthesize remotePort = _remotePort; + - (void)checkForUpdatesAtURL:(NSURL *)URL { [super checkForUpdatesAtURL:URL]; @@ -258,90 +262,6 @@ } } -/** - * If the update is a package, then it must be signed using DSA. No other verification is done. - * - * If the update is a bundle, then it must meet any one of: - * - * * old and new DSA public keys are the same and valid (it allows change of Code Signing identity), or - * - * * old and new Code Signing identity are the same and valid - * - */ -- (BOOL)validateUpdateForHost:(SUHost *)host downloadedToPath:(NSString *)downloadedPath extractedToPath:(NSString *)extractedPath DSASignature:(NSString *)DSASignature -{ - BOOL isPackage = NO; - NSString *installSourcePath = [SUInstaller installSourcePathInUpdateFolder:extractedPath forHost:host isPackage:&isPackage isGuided:NULL]; - if (installSourcePath == nil) { - SULog(@"No suitable install is found in the update. The update will be rejected."); - return NO; - } - - NSString *publicDSAKey = host.publicDSAKey; - - // Modern packages are not distributed as bundles and are code signed differently than regular applications - if (isPackage) { - if (nil == publicDSAKey) { - SULog(@"The existing app bundle does not have a DSA key, so it can't verify installer packages."); - } - - BOOL packageValidated = [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey]; - - if (!packageValidated) { - SULog(@"DSA signature validation of the package failed. The update contains an installer package, and valid DSA signatures are mandatory for all installer packages. The update will be rejected. Sign the installer with a valid DSA key or use an .app bundle update instead."); - } - - return packageValidated; - } - - NSBundle *newBundle = [NSBundle bundleWithPath:installSourcePath]; - if (newBundle == nil) { - SULog(@"No suitable bundle is found in the update. The update will be rejected."); - return NO; - } - - SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle]; - NSString *newPublicDSAKey = newHost.publicDSAKey; - - BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey]; - - if (newPublicDSAKey != nil) { - if (![SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:newPublicDSAKey]) { - SULog(@"DSA signature validation failed. The update has a public DSA key and is signed with a DSA key, but the %@ doesn't match the signature. The update will be rejected.", - dsaKeysMatch ? @"public key" : @"new public key shipped with the update"); - return NO; - } - } - - BOOL updateIsCodeSigned = [SUCodeSigningVerifier applicationAtPathIsCodeSigned:installSourcePath]; - - if (dsaKeysMatch) { - NSError *error = nil; - if (updateIsCodeSigned && ![SUCodeSigningVerifier codeSignatureIsValidAtPath:installSourcePath error:&error]) { - SULog(@"The update archive has a valid DSA signature, but the app is also signed with Code Signing, which is corrupted: %@. The update will be rejected.", error); - return NO; - } - } else { - NSString *hostBundlePath = host.bundlePath; - BOOL hostIsCodeSigned = [SUCodeSigningVerifier applicationAtPathIsCodeSigned:hostBundlePath]; - - NSString *dsaStatus = newPublicDSAKey ? @"has a new DSA key that doesn't match the previous one" : (publicDSAKey ? @"removes the DSA key" : @"isn't signed with a DSA key"); - if (!hostIsCodeSigned || !updateIsCodeSigned) { - NSString *acsStatus = !hostIsCodeSigned ? @"old app hasn't been signed with app Code Signing" : @"new app isn't signed with app Code Signing"; - SULog(@"The update archive %@, and the %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, acsStatus); - return NO; - } - - NSError *error = nil; - if (![SUCodeSigningVerifier codeSignatureAtPath:hostBundlePath matchesSignatureAtPath:installSourcePath error:&error]) { - SULog(@"The update archive %@, and the app is signed with a new Code Signing identity that doesn't match code signing of the original app: %@. At least one method of signature verification must be valid. The update will be rejected.", dsaStatus, error); - return NO; - } - } - - return YES; -} - - (void)downloadDidFinish:(NSURLDownload *)__unused d { assert(self.updateItem); @@ -383,16 +303,90 @@ return ([encodingType rangeOfString:@"gzip"].location == NSNotFound); } +- (void)unarchiverExtractedProgress:(double)__unused progress {} + +- (void)installerDidStart {} + +- (void)installerIsReadyForRelaunch {} + +- (void)handleMessageWithIdentifier:(int32_t)identifier data:(NSData *)data +{ + if (identifier == 1) { + if (data.length == sizeof(double)) { + double progress = *(const double *)data.bytes; + [self unarchiverExtractedProgress:progress]; + } + } else if (identifier == 2) { + BOOL success = NO; + if (data.length == sizeof(uint8_t)) { + success = (BOOL)*(const uint8_t *)data.bytes; + } + + if (success) { + [self installerDidStart]; + } else { +#warning put in a custom error + [self abortUpdate]; + } + } else if (identifier == 3) { + [self extractingInstallDidFail]; + } else if (identifier == 4) { + [self.localPort invalidate]; + self.localPort = nil; + + NSString *serviceName = [NSString stringWithFormat:@"%@-sparkle-installer", self.host.bundle.bundleIdentifier]; + __weak SUBasicUpdateDriver *weakSelf = self; + self.remotePort = [[SURemoteMessagePort alloc] initWithServiceName:serviceName invalidationCallback:^{ + dispatch_async(dispatch_get_main_queue(), ^{ +#warning put in a custom error for connection closed + if (weakSelf.remotePort != nil) { + [weakSelf abortUpdate]; + } + }); + }]; + + if (self.remotePort == nil) { +#warning put in a custom error + SULog(@"We have failed creating remote port you!!"); + [self abortUpdate]; + } else { + [self installerIsReadyForRelaunch]; + } + } +} + - (void)extractUpdate { - SUUnarchiver *unarchiver = [SUUnarchiver unarchiverForPath:self.downloadPath updatingHostBundlePath:[[self.host bundle] bundlePath] withPassword:self.updater.decryptionPassword]; - if (!unarchiver) { - SULog(@"Error: No valid unarchiver for %@!", self.downloadPath); - [self unarchiverDidFail:nil]; - return; + NSError *error = nil; + if (![self launchAutoUpdate:&error]) { + [self abortUpdateWithError:error]; + } else { + NSString *serviceName = [NSString stringWithFormat:@"%@-sparkle-updater", self.host.bundle.bundleIdentifier]; + + __weak SUBasicUpdateDriver *weakSelf = self; + self.localPort = + [[SULocalMessagePort alloc] + initWithServiceName:serviceName + messageCallback:^(int32_t identifier, NSData * _Nonnull data) { + dispatch_async(dispatch_get_main_queue(), ^{ + // Note: should not use weakSelf here + [self handleMessageWithIdentifier:identifier data:data]; + }); + } + invalidationCallback:^{ + dispatch_async(dispatch_get_main_queue(), ^{ + if (weakSelf.localPort != nil) { +#warning use a custom error + [weakSelf abortUpdate]; + } + }); + }]; + + if (self.localPort == nil) { +#warning use a custom error + [self abortUpdate]; + } } - unarchiver.delegate = self; - [unarchiver start]; } - (void)failedToApplyDeltaUpdate @@ -404,20 +398,13 @@ [self downloadUpdate]; } -- (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua -{ - assert(self.updateItem); - - [self installWithToolAndRelaunch:YES]; -} - -- (void)unarchiverDidFail:(SUUnarchiver *)__unused ua +- (void)extractingInstallDidFail { if ([self.updateItem isDeltaUpdate]) { [self failedToApplyDeltaUpdate]; return; } - + [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil) }]]; } @@ -452,50 +439,12 @@ return YES; } -- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI +- (BOOL)launchAutoUpdate:(NSError * __autoreleasing *)outError { - assert(self.updateItem); - - if (![self validateUpdateForHost:self.host downloadedToPath:self.downloadPath extractedToPath:self.tempDir DSASignature:self.updateItem.DSASignature]) - { - NSDictionary *userInfo = @{ - NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil), - NSLocalizedFailureReasonErrorKey: SULocalizedString(@"The update is improperly signed.", nil), - }; - [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUSignatureError userInfo:userInfo]]; - return; - } - - if (![self.updater mayUpdateAndRestart]) - { - [self abortUpdate]; - return; - } - - // Give the host app an opportunity to postpone the install and relaunch. - id updaterDelegate = [self.updater delegate]; - - if (!self.postponedOnce && [updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)]) - { - NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]]; - [invocation setSelector:@selector(installWithToolAndRelaunch:)]; - [invocation setArgument:&relaunch atIndex:2]; - [invocation setTarget:self]; - self.postponedOnce = YES; - if ([updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvoking:invocation]) { - return; - } - } - - - if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdate:)]) { - [updaterDelegate updater:self.updater willInstallUpdate:self.updateItem]; - } - NSBundle *sparkleBundle = self.updater.sparkleBundle; NSString *relaunchPath = nil; - + // 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 relaunchToolName = @"" SPARKLE_RELAUNCH_TOOL_NAME; @@ -512,47 +461,55 @@ // 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 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. + // Releasing quarantine is definitely important (didn't used to be) now that we launch AutoUpdate via LaunchServices + // Perhaps even if this fails, we should continue on in the hopes maybe this isn't a fatal error though NSError *quarantineError = nil; if (![fileManager releaseItemFromQuarantineAtRootURL:targetURL error:&quarantineError]) { SULog(@"Failed to release quarantine on %@ with error %@", targetPath, quarantineError); } relaunchPath = targetPath; } else { - [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{ - NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil), - NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@", relaunchPathToCopy, targetPath, (error ? [error localizedDescription] : @"")] - }]]; + if (outError != NULL) { + *outError = + [NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{ + NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil), + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@", relaunchPathToCopy, targetPath, (error ? [error localizedDescription] : @"")] + }]; + } + + return NO; } } - - [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self]; - if ([updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)]) - [updaterDelegate updaterWillRelaunchApplication:self.updater]; - + NSString *relaunchToolPath = [[NSBundle bundleWithPath:relaunchPath] executablePath]; if (!relaunchToolPath || ![[NSFileManager defaultManager] fileExistsAtPath:relaunchPath]) { // Note that we explicitly use the host app's name here, since updating plugin for Mail relaunches Mail, not just the plugin. - [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{ - NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [self.host name]], - NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", relaunchPath] - }]]; + if (outError != NULL) { + *outError = + [NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [self.host name]], + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", relaunchPath] + }]; + } + // We intentionally don't abandon the update here so that the host won't initiate another. - return; + return NO; } - + NSString *pathToRelaunch = [self.host bundlePath]; + id updaterDelegate = [self.updater delegate]; if ([updaterDelegate respondsToSelector:@selector(pathToRelaunchForUpdater:)]) { pathToRelaunch = [updaterDelegate pathToRelaunchForUpdater:self.updater]; } + NSString *dsaSignature = self.updateItem.DSASignature == nil ? @"" : self.updateItem.DSASignature; + NSArray *launchArguments = @[ pathToRelaunch, self.host.bundlePath, self.tempDir, - relaunch ? @"1" : @"0", - showUI ? @"1" : @"0", + self.downloadPath, + dsaSignature, @"1"]; // last one signifies the relaunch tool should exit & reply back to us immediately // Make sure the launched task finishes & replies back. @@ -575,11 +532,63 @@ SULog(@"Update tool failed with exit code: %d", terminationStatus); } - [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{ - NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while launching the updater. Please try again later.", nil), - NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't launch relauncher at %@", relaunchToolPath] - }]]; + if (outError != NULL) { + *outError = + [NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{ + NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while launching the updater. Please try again later.", nil), + NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't launch relauncher at %@", relaunchToolPath] + }]; + } + + return NO; + } + + return YES; +} + +- (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI +{ + assert(self.updateItem); + + if (![self.updater mayUpdateAndRestart]) + { + [self abortUpdate]; + return; + } + + // Give the host app an opportunity to postpone the install and relaunch. + id updaterDelegate = [self.updater delegate]; + + if (!self.postponedOnce && [updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)]) + { + NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]]; + [invocation setSelector:@selector(installWithToolAndRelaunch:)]; + [invocation setArgument:&relaunch atIndex:2]; + [invocation setTarget:self]; + self.postponedOnce = YES; + if ([updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvoking:invocation]) { + return; + } + } + + if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdate:)]) { + [updaterDelegate updater:self.updater willInstallUpdate:self.updateItem]; + } + + [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self]; + if ([updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)]) + [updaterDelegate updaterWillRelaunchApplication:self.updater]; + + uint8_t response[3] = {1, (uint8_t)relaunch, (uint8_t)showUI}; + NSData *responseData = [NSData dataWithBytes:&response length:sizeof(response)]; + if (![self.remotePort sendMessageWithIdentifier:1 data:responseData]) { + NSLog(@"Message failed!!"); +#warning put in a custom error + [self abortUpdate]; } else { + [self.remotePort invalidate]; + self.remotePort = nil; + [self terminateApp]; } } @@ -592,6 +601,7 @@ - (void)cleanUpDownload { +#warning review if download cleanup should really be done here if (self.tempDir != nil) // tempDir contains downloadPath, so we implicitly delete both here. { BOOL success = NO; @@ -614,6 +624,20 @@ - (void)abortUpdate { + if (self.localPort != nil) { + [self.localPort invalidate]; + self.localPort = nil; + } + + if (self.remotePort != nil) { + uint8_t exitCode = 0; + NSData *exitData = [NSData dataWithBytes:&exitCode length:sizeof(exitCode)]; + [self.remotePort sendMessageWithIdentifier:1 data:exitData]; + + [self.remotePort invalidate]; + self.remotePort = nil; + } + [self.updater.userDriver dismissUpdateInstallation]; [self cleanUpDownload]; diff --git a/Sparkle/SULocalMessagePort.h b/Sparkle/SULocalMessagePort.h new file mode 100644 index 00000000..cf9f3798 --- /dev/null +++ b/Sparkle/SULocalMessagePort.h @@ -0,0 +1,22 @@ +// +// SULocalMessagePort.h +// Sparkle +// +// Created by Mayur Pawashe on 3/9/16. +// Copyright © 2016 Sparkle Project. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface SULocalMessagePort : NSObject + +// Note: messageCallback may not be called on the main thread +- (nullable instancetype)initWithServiceName:(NSString *)serviceName messageCallback:(void (^)(int32_t identifier, NSData *data))messageCallback invalidationCallback:(void (^)(void))invalidationCallback; + +- (void)invalidate; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Sparkle/SULocalMessagePort.m b/Sparkle/SULocalMessagePort.m new file mode 100644 index 00000000..5b56a28d --- /dev/null +++ b/Sparkle/SULocalMessagePort.m @@ -0,0 +1,97 @@ +// +// SULocalMessagePort.m +// Sparkle +// +// Created by Mayur Pawashe on 3/9/16. +// Copyright © 2016 Sparkle Project. All rights reserved. +// + +#import "SULocalMessagePort.h" + +@interface SULocalMessagePort () + +@property (nonatomic) CFMessagePortRef messagePort; +@property (nonatomic, copy) void (^messageCallback)(int32_t, NSData *); +@property (nonatomic, copy) void (^invalidationCallback)(void); + +@end + +@implementation SULocalMessagePort + +@synthesize messagePort = _messagePort; +@synthesize messageCallback = _messageCallback; +@synthesize invalidationCallback = _invalidationCallback; + +- (nullable instancetype)initWithServiceName:(NSString *)serviceName messageCallback:(void (^)(int32_t identifier, NSData *data))messageCallback invalidationCallback:(void (^)(void))invalidationCallback +{ + self = [super init]; + if (self != nil) { + CFMessagePortContext context = {.version = 0, .info = (void *)CFBridgingRetain(self), .retain = NULL, .release = NULL, .copyDescription = NULL}; + CFMessagePortRef messagePort = CFMessagePortCreateLocal(kCFAllocatorDefault, (CFStringRef)serviceName, messagePortCallback, &context, NULL); + + if (messagePort == NULL) { + CFRelease((__bridge CFTypeRef)(self)); + return nil; + } + + _messagePort = messagePort; + _messageCallback = [messageCallback copy]; + _invalidationCallback = [invalidationCallback copy]; + + CFMessagePortSetDispatchQueue(messagePort, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)); + CFMessagePortSetInvalidationCallBack(messagePort, messageInvalidationCallback); + } + return self; +} + +- (void)invalidate +{ + @synchronized(self) { + if (self.invalidationCallback != nil) { + self.invalidationCallback = nil; + CFMessagePortInvalidate(self.messagePort); + } + } +} + +- (void)dealloc +{ + [self invalidate]; +} + +// Called on non-main thread +static CFDataRef messagePortCallback(CFMessagePortRef __unused messagePort, SInt32 messageID, CFDataRef dataRef, void *info) +{ + SULocalMessagePort *self = (__bridge SULocalMessagePort *)info; + NSData *data = (__bridge NSData *)dataRef; + + if (self.messageCallback != nil) { + self.messageCallback(messageID, data); + } + + // Don't have any use case where I need a reply, for now + return NULL; +} + +// Called on non-main thread +static void messageInvalidationCallback(CFMessagePortRef messagePort, void *info) +{ + SULocalMessagePort *self = (__bridge SULocalMessagePort *)info; + + @synchronized(self) { + // note that messageCallback is deallocated on same queue that we're receiving messages from, which is good + self.messageCallback = nil; + + if (self.invalidationCallback != nil) { + self.invalidationCallback(); + self.invalidationCallback = nil; + } + + self.messagePort = NULL; + } + + CFRelease(messagePort); + CFRelease((__bridge CFTypeRef)(self)); +} + +@end diff --git a/Sparkle/SURemoteMessagePort.h b/Sparkle/SURemoteMessagePort.h new file mode 100644 index 00000000..ea11f849 --- /dev/null +++ b/Sparkle/SURemoteMessagePort.h @@ -0,0 +1,23 @@ +// +// SURemoteMessagePort.h +// Sparkle +// +// Created by Mayur Pawashe on 3/9/16. +// Copyright © 2016 Sparkle Project. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface SURemoteMessagePort : NSObject + +- (nullable instancetype)initWithServiceName:(NSString *)serviceName invalidationCallback:(void (^)(void))invalidationCallback; + +- (BOOL)sendMessageWithIdentifier:(int32_t)identifier data:(NSData *)data; + +- (void)invalidate; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Sparkle/SURemoteMessagePort.m b/Sparkle/SURemoteMessagePort.m new file mode 100644 index 00000000..841670ff --- /dev/null +++ b/Sparkle/SURemoteMessagePort.m @@ -0,0 +1,93 @@ +// +// SURemoteMessagePort.m +// Sparkle +// +// Created by Mayur Pawashe on 3/9/16. +// Copyright © 2016 Sparkle Project. All rights reserved. +// + +#import "SURemoteMessagePort.h" +#import + +@interface SURemoteMessagePort () + +@property (nonatomic) CFMessagePortRef messagePort; +@property (nonatomic, copy) void (^invalidationCallback)(void); + +@end + +@implementation SURemoteMessagePort + +static const char *SURemoteMessagePortSelfKey = "su_messagePort"; + +@synthesize messagePort = _messagePort; +@synthesize invalidationCallback = _invalidationCallback; + +- (nullable instancetype)initWithServiceName:(NSString *)serviceName invalidationCallback:(void (^)(void))invalidationCallback +{ + self = [super init]; + if (self != nil) { + CFMessagePortRef messagePort = CFMessagePortCreateRemote(kCFAllocatorDefault, (CFStringRef)serviceName); + if (messagePort == NULL) { + return nil; + } + + _messagePort = messagePort; + _invalidationCallback = [invalidationCallback copy]; + + // We have to set an associated object here because we can't pass an info context to remote message ports when setting up an invalidation handler + objc_setAssociatedObject((__bridge id)messagePort, SURemoteMessagePortSelfKey, self, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + + // Note: do not add messagePort to dispatch queue or run loop: it will complain that one shouldn't be added for remote ports + CFMessagePortSetInvalidationCallBack(messagePort, messageInvalidationCallback); + } + return self; +} + +- (BOOL)sendMessageWithIdentifier:(int32_t)identifier data:(NSData *)data +{ + @synchronized(self) { + SInt32 status = 0; + if (self.messagePort != NULL) { + status = CFMessagePortSendRequest(self.messagePort, identifier, (CFDataRef)data, 0.1, 0.0, NULL, NULL); + } else { + status = kCFMessagePortIsInvalid; + } + return (status == kCFMessagePortSuccess); + } +} + +- (void)invalidate +{ + @synchronized(self) { + if (self.invalidationCallback != nil) { + self.invalidationCallback = nil; + CFMessagePortInvalidate(self.messagePort); + } + } +} + +- (void)dealloc +{ + [self invalidate]; +} + +// For safetly, let's not assume what thread this may be called on +static void messageInvalidationCallback(CFMessagePortRef messagePort, void * __unused info) +{ + SURemoteMessagePort *self = objc_getAssociatedObject((__bridge id)(messagePort), SURemoteMessagePortSelfKey); + + @synchronized(self) { + if (self.invalidationCallback != nil) { + self.invalidationCallback(); + self.invalidationCallback = nil; + } + + self.messagePort = NULL; + } + + objc_setAssociatedObject((__bridge id)(messagePort), SURemoteMessagePortSelfKey, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC); + CFRelease(messagePort); +} + +@end diff --git a/Sparkle/SUUIBasedUpdateDriver.h b/Sparkle/SUUIBasedUpdateDriver.h index a3f8da69..0bf72da8 100644 --- a/Sparkle/SUUIBasedUpdateDriver.h +++ b/Sparkle/SUUIBasedUpdateDriver.h @@ -14,7 +14,7 @@ @class SUStatusController; -@interface SUUIBasedUpdateDriver : SUBasicUpdateDriver +@interface SUUIBasedUpdateDriver : SUBasicUpdateDriver - (instancetype)initWithUpdater:(SUUpdater *)updater host:(SUHost *)host; diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index f59ee5b9..0d69bc4f 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -120,12 +120,17 @@ [super extractUpdate]; } -- (void)unarchiver:(SUUnarchiver *)__unused ua extractedProgress:(double)progress +- (void)unarchiverExtractedProgress:(double)progress { [self.updater.userDriver showExtractionReceivedProgress:progress]; } -- (void)unarchiverDidFinish:(SUUnarchiver *)__unused ua +- (void)installerDidStart +{ + [self.updater.userDriver showInstallingUpdate]; +} + +- (void)installerIsReadyForRelaunch { if (self.automaticallyInstallUpdates) { [self installWithToolAndRelaunch:YES]; @@ -148,8 +153,7 @@ - (void)installWithToolAndRelaunch:(BOOL)relaunch { - [self.updater.userDriver showInstallingUpdate]; - + //[self.updater.userDriver showInstallingUpdate]; [super installWithToolAndRelaunch:relaunch]; }