Compare commits

...
95 Commits
Author SHA1 Message Date
Kornel Lesiński 57101a1c5b Updated changelog 2015-07-24 00:19:47 +01:00
Kornel 382b04fe4a Merge pull request #574 from sparkle-project/unbundle
Don’t keep important settings in Sparkle’s Info.plist
2015-07-24 00:11:02 +01:00
Kornel Lesiński 07c773ace2 Move sparkleBundle from SUHost to SUUpdater 2015-07-23 11:28:20 +01:00
Kornel Lesiński a85a48c59a Don’t keep important settings in Sparkle’s Info.plist 2015-07-22 14:34:24 +01:00
Kornel cf17fff3fc Merge pull request #573 from sparkle-project/bundleid
Use bundleForClass instead of finding bundle by ID
2015-07-22 11:44:36 +01:00
Kornel Lesiński 4cc1702093 Use bundleForClass instead of finding bundle by ID
It should prevent confusion when multiple copies of Sparkle are available

Fixes #571
2015-07-22 10:37:34 +01:00
Kornel Lesiński 86fdb0c2ac Version bump 2015-07-16 23:27:50 +01:00
Kornel Lesiński 3e7c7fe249 Updated readme 2015-07-16 23:26:49 +01:00
Kornel Lesiński ce21e1b7e7 Updated changelog 2015-07-16 23:22:28 +01:00
Kornel Lesiński e9fa7c3d4a Verify relaunchToolPath is not nil
#571
2015-07-13 07:03:50 +01:00
Jake Petroules ceee82c4b1 Ignore stderr from xcrun. 2015-07-09 18:18:43 -07:00
Jake Petroules 7c39af9c99 Let CI test as many SDKs as are available. 2015-07-09 18:16:36 -07:00
Jake Petroules e086125cb8 Fix image height on GitHub. 2015-07-09 17:57:43 -07:00
Jake Petroules 5e6acc824e Add ship.io badge, which lets us prove that the build works on Xcode 5. 2015-07-09 17:48:17 -07:00
Jake Petroules ae27726b3b Rename continuous integration Makefile target to the more general 'ci'. 2015-07-09 17:40:51 -07:00
Jake Petroules 83f6dd3052 Guard some test cases for use on Xcode 6+ only. 2015-07-09 17:38:14 -07:00
Jake Petroules fb9b4a4f35 Fix nullability warnings. 2015-07-09 17:27:31 -07:00
Jake Petroules 6d7f95d912 Fix const warnings for both Xcode 6 and 7. 2015-07-09 17:16:06 -07:00
Jake Petroules 46249cc49f Turn on more warnings. 2015-07-09 17:16:06 -07:00
Jake Petroules 51712d2322 Fix a bunch of warnings so Xcode 5 still compiles cleanly. 2015-07-09 17:16:06 -07:00
Jake Petroules 24898ad60d Fix warnings in sais. These have been sent upstream as well. 2015-07-09 17:16:06 -07:00
Kornel cf9edce775 Merge pull request #569 from vokal/master
Add delegate methods for pre-download and immediately post-failed-download.
2015-07-08 01:13:45 +01:00
designatednerd 2387feeb7c Merge pull request #1 from vokal-isaac/master
Add delegate methods for pre-download and immediately post-failed-download.
2015-07-07 12:46:32 -05:00
Isaac Greenspan 363a41234d Indent new documenting comments to match existing ones. 2015-07-07 12:44:14 -05:00
Isaac Greenspan 06573e4b81 Add delegate methods for pre-download and immediately post-failed-download. 2015-07-07 12:35:49 -05:00
Kornel e702246bb5 Merge pull request #540 from zorgiepoo/code-sign-xattr
BinaryDelta Code Signed Extended Attributes Validation
2015-07-06 09:49:29 +01:00
Kornel 78c14cc574 Merge pull request #568 from xhacker/fix-default-font
Fix Lucida Grande is always used for release notes
2015-07-06 09:46:29 +01:00
LIU Dongyuan / 柳东原 976e83159f Fix Lucida Grande is always used for release notes
Use "-apple-system-font" to use system default font.
2015-07-05 21:32:07 -07:00
Kornel d7e532d268 Merge pull request #565 from sparkle-project/errtxt
More verbose error message when DSA keys don't match
2015-07-05 12:45:24 +01:00
Kornel Lesiński 33ef8ca2b4 Clarify that DSA is for archives and Apple Code Signing is for apps 2015-07-05 12:44:45 +01:00
Kornel e5e560e751 Merge pull request #566 from zorgiepoo/bundle-nil-check
Don't use main bundle if passed in bundle is nil
2015-07-03 14:46:17 +01:00
Kornel 4e33285068 Merge pull request #567 from savoirfairelinux/master
builddir: use predefined BUILDDIR
2015-07-02 17:09:59 +01:00
Alexandre Lision 313f4a497d builddir: use predefined BUILDDIR
This commit allows user to control where Sparkle will be build
2015-07-02 11:38:06 -04:00
Zorg ddb67d1c84 Added assert to make sure bundle isn't nil 2015-07-01 22:00:29 -04:00
Kornel Lesiński 99dedafc67 Fixed condition 2015-07-01 09:54:46 +01:00
Zorg 0b7e343a56 Don't use main bundle if passed in bundle is nil 2015-07-01 00:35:27 -04:00
Kornel Lesiński cd4da94cb9 GitHub pages don't support HTTPS for custom domains 2015-07-01 00:35:08 +01:00
Kornel 882fecea6b Merge pull request #564 from zorgiepoo/fixtestapp
Add public DSA file to updated test app
2015-07-01 00:34:33 +01:00
Kornel Lesiński efdf9d4421 More verbose error message when DSA keys don't match 2015-07-01 00:30:35 +01:00
Zorg 33c2eb89c9 Add public DSA file to updated test app 2015-06-30 18:42:29 -04:00
Kornel dc1cd3a259 Merge pull request #563 from kainjow/master
Fix NSAlert deprecations
2015-06-29 17:28:47 +01:00
Kevin Wojniak 11eaa3e092 Replace deprecated alertWithMessageText 2015-06-29 08:45:08 -07:00
Kevin Wojniak 4adb53dc51 Replace deprecated NSRunAlertPanel 2015-06-29 08:39:06 -07:00
Kornel d0cc3b63b4 Merge pull request #538 from zorgiepoo/verifying-update
Only check if new path is code signed
2015-06-29 12:11:56 +01:00
Jake Petroules 2aefacb7f2 Merge pull request #561 from sparkle-project/null
Nullability
2015-06-29 02:41:40 -07:00
Kornel Lesiński 3f433561d4 Hide __nonnull from Xcode 6 2015-06-29 10:10:18 +01:00
Kornel Lesiński 7bb0c69f76 Nullability 2015-06-29 10:03:31 +01:00
Kornel Lesiński 2c7ad5bc29 Const/casts 2015-06-29 10:03:31 +01:00
Kornel Lesiński 7ebb603ab7 Null checks 2015-06-29 10:03:31 +01:00
Kornel Lesiński 7b9e1fb431 Safer initialization 2015-06-28 22:50:50 +01:00
Kornel Lesiński 9f23c4f11e Comments 2015-06-28 22:50:36 +01:00
Kornel ce2a721a73 Merge pull request #560 from ksuther/pt-BR-warning-fix
pt-BR warning fix
2015-06-25 12:55:39 +01:00
Kent Sutherland eebadf5230 Fixed a warning about the window being offscreen (introduced from the pt-BR localization update). 2015-06-24 19:07:10 -04:00
Jake Petroules 51b62de4cb Fix some warnings. 2015-06-13 02:30:13 -07:00
Jake Petroules 4643becaff Upgrade settings. 2015-06-13 02:22:20 -07:00
Jake Petroules 4bbfac11aa Fix build with < 10.9 SDK. 2015-06-06 09:23:26 -07:00
Jake Petroules 0f4f7c3509 Fix build with < 10.10 SDK. 2015-06-06 08:40:17 -07:00
Jake Petroules 91af4db0c0 Update Podspec for 1.10.0. 2015-06-06 08:35:07 -07:00
Jake Petroules 21a894cd63 Fix warnings in unit test. 2015-06-06 08:35:07 -07:00
Jake Petroules e8035cc912 Silence warnings in third party code. 2015-06-06 08:35:07 -07:00
Jake Petroules 342aec164d Comment problematic clang-format property. 2015-06-06 08:35:07 -07:00
Kornel 517f7862ab Merge pull request #534 from zorgiepoo/app-update-validation
Improved app update validation
2015-06-06 11:53:41 +01:00
Zorg 6ca90a8c11 Clarification that DSA keys differ or are absent 2015-06-05 22:22:05 -04:00
Zorg a7e8e2aad5 Validate with the new public DSA key, not the old one 2015-06-05 21:59:32 -04:00
Zorg e9e5791e51 s/Pubic/Public/ 2015-06-05 21:46:52 -04:00
Zorg 7c705e5fff Remove redundant check that SUDSAVerifier does 2015-06-05 21:39:57 -04:00
Zorg b1d887264f Fix package validation from previous commit
Modern packages aren't distributed as bundles, and we wouldn't be able to obtain a "new" public DSA key from an update
2015-06-05 21:37:09 -04:00
Zorg da06dc80d6 Rely on code signing and the DSA key in the new app
Instead of relying on whether the DSA signature is provided in the appcast (which we can't trust), we rely on detecting if the public key in the new and old app differ. If they differ, then the code signatures from both apps must match. The idea is that code signing is reliable in being able to tell that the Info.plist and public DSA files came from the developer and are intact. This still allows a developer to lose access to their DSA private key, or to their Apple code signature, and be able to push new updates (as long as they didn't lose access to both). The new change, however, is that 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.
2015-06-05 18:57:36 -04:00
Kornel 2ed2f3def3 Merge pull request #554 from MaddTheSane/headers
Import the Foundation umbrella header in all the public headers.
2015-06-05 00:04:12 +01:00
C.W. Betts 3292c4ea10 Import the Foundation umbrella header in all the public headers.
This should prevent any undefined declaration warnings.
2015-06-04 11:13:48 -06:00
Kornel Lesiński fbc7a7fbf7 Log URL on appcast error 2015-05-27 19:16:55 +01:00
Kornel Lesiński 4733fe7785 Log URL on download error 2015-05-27 19:16:54 +01:00
Victor Figueiredo 8585d06bb5 pt-BR localization update 2015-05-21 00:27:57 +01:00
Kornel 4d111b96e4 Merge pull request #541 from zorgiepoo/unable-quarantine-fix
Only remove quarantine with -[NSURL setResourceValue:] when it's present
2015-05-10 02:15:54 +02:00
Zorg 0557a5ba5c Only remove quarantine with setResourceValue: when it's present
This should stop "Unable to quarantine: 93" messages from showing up in the console. Fixes issue #452
2015-05-08 23:55:23 -04:00
Zorg 61d43f860a Add tests for aborting on code signed xattr's 2015-05-05 22:04:18 -04:00
Zorg 4dd4548be4 Added comment on why code-signed xattr is not diff'ed 2015-05-05 21:47:23 -04:00
Zorg 9c3ef30f4c Diff'ing code-signed xattr's should actually not be supported
According to Apple's code signing document: https://developer.apple.com/library/mac/technotes/tn2206/_index.html
They don't recommend storing signed non-Mach-O files inside an app. They'd prefer script files for example to be in Resources directory and be unsigned.
2015-05-05 21:13:01 -04:00
Zorg 585194908e Bumping minor diff version 2015-05-05 20:32:16 -04:00
Zorg 330c733958 Don't forget to free the buffer 2015-05-05 20:25:42 -04:00
Zorg 4c782a67ed Abort if code signed xattr exists anywhere
Code signatures on non-mach-o files is not currently supported, but I'd like to implement this eventually.
2015-05-05 20:22:02 -04:00
Zorg 3a304123d9 Renaming newBundlePath to installSourcePath 2015-05-04 23:15:17 -04:00
Zorg 87da4cc0f2 Distinguish between install path found and update being a package 2015-05-04 22:49:57 -04:00
Kornel 12f29384ea Merge pull request #539 from vslavik/fix-incomplete-implementation-warning
Fix appcastDidFinishLoading: incomplete implementation warning
2015-05-04 15:13:32 +02:00
Václav Slavík 253f7c1023 Fix appcastDidFinishLoading: incomplete implementation warning
appcastDidFinishLoading: was declared in SUUIBasedUpdateDriver, but
defined and used in SUUIBasedUpdateDriver. Move the declaration back to
the base class where it belongs.
2015-05-04 14:34:49 +02:00
Zorg 65bfa1ccf2 Only check if new path is code signed
If the original app is signed, and the update is not, this is actually fine if the DSA validation goes through. And this may be desirable for people that don't want to pay cash to code sign their application anymore.
2015-05-03 20:06:41 -04:00
Kornel Lesiński f19038e5fe Add test cases 2015-05-02 23:16:58 +02:00
Kornel Lesiński 619e4a60a2 Fixed test name 2015-05-02 22:49:55 +02:00
Kornel 6e92311aaa Merge pull request #537 from antonc27/master
Fix for crash while applying delta update
2015-04-29 18:41:57 +01:00
antonc27 7d7aeb9f65 - Fix for crash while applying delta update 2015-04-29 17:54:58 +02:00
Jake Petroules ae3d04660e Merge pull request #535 from tonyarnold/hotfix/foundation-import
Properly import Foundation to fix errors when building as a module
2015-04-27 18:36:31 -07:00
Tony Arnold 2068da1cf9 Properly import Foundationto fix errors when building as a module 2015-04-28 09:40:54 +10:00
Zorg 19fdb9276d Only do DSA verification if public key is available 2015-04-27 19:18:21 -04:00
Zorg f55d2a4439 Host app needn't be signed to verify signature of updated app 2015-04-26 16:28:17 -04:00
Zorg 28ea47f796 Improved app update validation. See discussion in issue #441
If an invalid DSA or invalid code signature is provided, the update will fail, regardless if one of these requirements is valid. The logic before is that the update will succeed if either a valid DSA or matched code signature is provided.
This still allows a code signature to change, be added, or be removed, as long as the DSA and the code signature (if provided) is valid. If no DSA is provided, then this is not possible, and the code signature from the host and update app must match.
2015-04-26 13:58:40 -04:00
73 changed files with 660 additions and 288 deletions

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
#DerivePointerAlignment: false
DisableFormat: false
ForEachMacros: foreach,Q_FOREACH
#ForEachMacros: foreach,Q_FOREACH
IndentCaseLabels: true
IndentFunctionDeclarationAfterType: true
IndentWidth: 4
+1 -1
View File
@@ -1,2 +1,2 @@
language: objective-c
script: make travis
script: make ci
+18
View File
@@ -1,3 +1,21 @@
# 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)
* 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 / 柳东原)
* Only remove quarantine with setResourceValue: when it's present. Fixes "Unable to quarantine: 93" messages from showing up in the console. (Zorg)
* Fixed const and nullability warnings (Jake Petroules, Kornel Lesiński)
* Replaced deprecated NSRunAlertPanel/alertWithMessageText (Kevin Wojniak)
* Imported the Foundation umbrella header in all the public headers (C.W. Betts)
* pt-BR localization update (Victor Figueiredo)
* Reject unsupported code-signing xattrs in binary delta (Zorg)
* Fixed crash while applying delta update (antonc27)
* Added logging of appcast/download URL on error (Kornel Lesiński)
* More robust reading of Autoupdate.app path from Sparkle bundle
# 1.10.0
* Massive improvements to the BinaryDelta tool (Zorg)
@@ -1,3 +1 @@
// BinaryDelta tool only
PRODUCT_NAME = BinaryDelta
+11 -3
View File
@@ -15,20 +15,24 @@ SPARKLE_AUTOMATED_DOWNGRADES = 0
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
SPARKLE_VERSION_MAJOR = 1
SPARKLE_VERSION_MINOR = 10
SPARKLE_VERSION_MINOR = 11
SPARKLE_VERSION_PATCH = 0
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION)
ALWAYS_SEARCH_USER_PATHS = NO
ENABLE_STRICT_OBJC_MSGSEND = YES
GCC_PRECOMPILE_PREFIX_HEADER = YES
GCC_PREFIX_HEADER = Sparkle/Sparkle.pch
GCC_SYMBOLS_PRIVATE_EXTERN = YES
GCC_INLINES_ARE_PRIVATE_EXTERN = YES
ARCHS = $(ARCHS_STANDARD)
MACOSX_DEPLOYMENT_TARGET = 10.7
PRODUCT_NAME = ${TARGET_NAME}
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}
GCC_PREPROCESSOR_DEFINITIONS = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_AUTOMATED_DOWNGRADES=$(SPARKLE_AUTOMATED_DOWNGRADES) SPARKLE_APPEND_VERSION_NUMBER=$(SPARKLE_APPEND_VERSION_NUMBER) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\"
GCC_PREPROCESSOR_DEFINITIONS = SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\"
CLANG_ENABLE_OBJC_ARC = YES
// Enable warnings
@@ -37,6 +41,7 @@ CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES
CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES
CLANG_ENABLE_MODULES = YES
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES
CLANG_WARN_ASSIGN_ENUM = YES
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES
CLANG_WARN_DOCUMENTATION_COMMENTS = YES
CLANG_WARN_EMPTY_BODY = YES
@@ -48,6 +53,9 @@ CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES
CLANG_WARN_OBJC_RECEIVER_WEAK = YES
CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES
CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES
CLANG_WARN_UNREACHABLE_CODE = YES
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES
GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES
GCC_WARN_64_TO_32_BIT_CONVERSION = YES
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES
GCC_WARN_ABOUT_MISSING_NEWLINE = YES
@@ -74,4 +82,4 @@ GCC_WARN_UNUSED_VARIABLE = YES
WARNING_CFLAGS_EXTRA = -Wno-custom-atomic-properties -Wno-implicit-atomic-properties
// Turn on all warnings, then disable a few which are almost impossible to avoid
WARNING_CFLAGS = -Wall -Weverything -Wno-empty-translation-unit -Wno-unused-macros -Wno-gnu-statement-expression -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wno-auto-import -Wno-cstring-format-directive $(WARNING_CFLAGS_EXTRA)
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wno-auto-import $(WARNING_CFLAGS_EXTRA)
@@ -4,6 +4,7 @@
GCC_OPTIMIZATION_LEVEL = 0
DEBUG_INFORMATION_FORMAT = dwarf
ENABLE_TESTABILITY = YES
GCC_GENERATE_DEBUGGING_SYMBOLS = YES
SPARKLE_EXTRA_DEBUG = -DDEBUG
OTHER_CFLAGS = $(SPARKLE_EXTRA_DEBUG)
+1 -1
View File
@@ -3,7 +3,6 @@
DYLIB_INSTALL_NAME_BASE = @rpath
DYLIB_COMPATIBILITY_VERSION = 1.6
DYLIB_CURRENT_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
PRODUCT_NAME = Sparkle
WRAPPER_EXTENSION = framework
FRAMEWORK_VERSION = A
INFOPLIST_FILE = Sparkle/Sparkle-Info.plist
@@ -11,3 +10,4 @@ GCC_PREPROCESSOR_DEFINITIONS = $(inherited) BUILDING_SPARKLE=1
OTHER_LDFLAGS = -Wl,-U,_NSURLQuarantinePropertiesKey
SKIP_INSTALL = YES
DEFINES_MODULE = YES
PRODUCT_BUNDLE_IDENTIFIER = ${SPARKLE_BUNDLE_IDENTIFIER}
+1 -1
View File
@@ -1,8 +1,8 @@
// Test Application only
INFOPLIST_FILE = TestApplication/TestApplication-Info.plist
PRODUCT_NAME = Sparkle Test App
WRAPPER_EXTENSION = app
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon
CLANG_ENABLE_OBJC_ARC = NO
LD_RUNPATH_SEARCH_PATHS = @executable_path/../Frameworks
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.SparkleTestApp
-1
View File
@@ -1,7 +1,6 @@
// Unit Test only
INFOPLIST_FILE = Tests/SparkleTests-Info.plist
PRODUCT_NAME = Sparkle Unit Tests
WRAPPER_EXTENSION = xctest
OTHER_CFLAGS = $(inherited) -iframework"$(DEVELOPER_FRAMEWORKS_DIR)" -iframework"$(PLATFORM_DIR)/Developer/Library/Frameworks"
GCC_SYMBOLS_PRIVATE_EXTERN = NO
+10 -3
View File
@@ -1,6 +1,8 @@
.PHONY: all localizable-strings release build test travis
.PHONY: all localizable-strings release build test ci
BUILDDIR := $(shell mktemp -d "$(TMPDIR)/Sparkle.XXXXXX")
ifndef BUILDDIR
BUILDDIR := $(shell mktemp -d "$(TMPDIR)/Sparkle.XXXXXX")
endif
localizable-strings:
rm -f Sparkle/en.lproj/Sparkle.strings
@@ -18,4 +20,9 @@ build:
test:
xcodebuild -scheme Distribution -configuration Debug test
travis: test
ci:
for i in {7..11} ; do \
if xcrun --sdk "macosx10.$$i" --show-sdk-path 2> /dev/null ; then \
xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Debug test ; \
fi ; \
done
+4 -3
View File
@@ -1,4 +1,4 @@
# Sparkle [![Build Status](https://travis-ci.org/sparkle-project/Sparkle.svg?branch=master)](https://travis-ci.org/sparkle-project/Sparkle)
# Sparkle [![Build Status](https://travis-ci.org/sparkle-project/Sparkle.svg?branch=master)](https://travis-ci.org/sparkle-project/Sparkle) <a href='https://app.ship.io/dashboard#/jobs/8814/history' target='_blank'><img src='https://app.ship.io/jobs/V3PoCLcN5ft5Pnq0/build_status.png' height='20' /></a>
An easy-to-use software update framework for Cocoa developers.
@@ -6,20 +6,21 @@ An easy-to-use software update framework for Cocoa developers.
## Changes since 1.5b
* Up-to-date with 10.10 SDK and Xcode 6. Supports OS X 10.7+.
* Up-to-date with 10.11 SDK and Xcode 7. Supports OS X 10.7+.
* Cleaned up and modernized code, using ARC and Autolayout.
* Merged bugfixes, security fixes and some features from multiple Sparkle forks.
* Truly automatic background updates (no UI at all) when user agreed to "Automatically download and install updates in the future."
* Ability to mark updates as critical.
* Progress and status notifications for the host app.
* Name of finish_installation.app can be configured to match your app's name.
* Upgraded and more reliable binary delta and code signing verification.
## Features
* True self-updating—the user can choose to automatically download and install all updates.
* Displays a detailed progress window to the user.
* Supports authentication for installing in secure locations.
* Supports Apple code signing and DSA signatures for ultra-secure updates.
* Supports Apple Code Signing and DSA signatures for ultra-secure updates.
* Easy to install. Sparkle requires no code in your app, so it's trivial to upgrade or remove the framework.
* Uses appcasts for release information. Appcasts are supported by 3rd party update-tracking programs and websites.
* Displays release notes to the user via WebKit.
+2 -2
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "Sparkle"
s.version = "1.9.0"
s.version = "1.11.0"
s.summary = "A software update framework for OS X"
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
s.homepage = "http://sparkle-project.org"
@@ -18,7 +18,7 @@ Pod::Spec.new do |s|
s.platform = :osx, '10.7'
s.source = { :http => "https://github.com/sparkle-project/Sparkle/releases/download/#{s.version}/Sparkle-#{s.version}.tar.bz2" }
s.public_header_files = 'Sparkle.framework/Headers/*.h'
s.public_header_files = 'Sparkle.framework/Versions/A/Headers/*.h'
s.vendored_framework = 'Sparkle.framework'
s.resources = 'Sparkle.framework'
s.xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => '"${PODS_ROOT}/Sparkle"' }
+4 -6
View File
@@ -167,9 +167,9 @@
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, ); }; };
721CF1A71AD7643600D9AC09 /* bsdiff.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */; };
721CF1A81AD7644100D9AC09 /* bspatch.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */; };
721CF1A91AD7644C00D9AC09 /* sais.c in Sources */ = {isa = PBXBuildFile; fileRef = 7223E7611AD1AEFF008E3161 /* sais.c */; };
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"; }; };
721CF1AA1AD7647000D9AC09 /* libxar.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5890FD7678C0065DB48 /* libxar.1.dylib */; };
721CF1AB1AD764EB00D9AC09 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D06E8FB0FD68D61005AE3F6 /* libbz2.dylib */; };
7223E7631AD1AEFF008E3161 /* sais.c in Sources */ = {isa = PBXBuildFile; fileRef = 7223E7611AD1AEFF008E3161 /* sais.c */; };
@@ -1201,7 +1201,7 @@
isa = PBXProject;
attributes = {
CLASSPREFIX = SU;
LastUpgradeCheck = 0630;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Sparkle Project";
TargetAttributes = {
612279D80DB5470200AB99EA = {
@@ -1759,14 +1759,12 @@
14950061195FB89500BC5B5B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
14950062195FB89500BC5B5B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -48,6 +48,8 @@
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = ""
@@ -57,6 +59,7 @@
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0630"
LastUpgradeVersion = "0700"
version = "2.0">
<BuildAction
parallelizeBuildables = "YES"
@@ -48,6 +48,8 @@
ReferencedContainer = "container:Sparkle.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = ""
@@ -58,6 +60,7 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugXPCServices = "NO"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
+1 -1
View File
@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
+4 -1
View File
@@ -167,7 +167,10 @@ static const NSTimeInterval SUParentQuitCheckInterval = .25;
completionHandler:^(NSError *error) {
if (error) {
if (self.shouldShowUI) {
NSRunAlertPanel(@"", @"%@", @"OK", @"", @"", [error localizedDescription]);
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = @"";
alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]];
[alert runModal];
}
exit(EXIT_FAILURE);
} else {
+1 -1
View File
@@ -9,7 +9,7 @@
#ifndef SUAPPCAST_H
#define SUAPPCAST_H
#import <Foundation/NSURLDownload.h>
#import <Foundation/Foundation.h>
#import "SUExport.h"
@class SUAppcastItem;
+17 -5
View File
@@ -26,7 +26,11 @@
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
for (NSXMLNode *attribute in attributeEnum) {
dictionary[[attribute name]] = [attribute stringValue];
NSString *attrName = [attribute name];
if (!attrName) {
continue;
}
dictionary[attrName] = [attribute stringValue];
}
return dictionary;
}
@@ -166,9 +170,12 @@
else if ([name isEqualToString:SURSSElementPubDate])
{
// pubDate is expected to be an NSDate by SUAppcastItem, but the RSS class was returning an NSString
NSDate *date = [NSDate dateWithNaturalLanguageString:[node stringValue]];
if (date)
dict[name] = date;
NSString *string = node.stringValue;
if (string) {
NSDate *date = [NSDate dateWithNaturalLanguageString:string];
if (date)
dict[name] = date;
}
}
else if ([name isEqualToString:SUAppcastElementDeltas])
{
@@ -184,7 +191,9 @@
NSMutableArray *tags = [NSMutableArray array];
NSEnumerator *childEnum = [[node children] objectEnumerator];
for (NSXMLNode *child in childEnum) {
[tags addObject:[child name]];
NSString *childName = child.name;
if (childName)
[tags addObject:childName];
}
dict[name] = tags;
}
@@ -244,10 +253,13 @@
- (void)reportError:(NSError *)error
{
NSURL *failingUrl = error.userInfo[NSURLErrorFailingURLErrorKey];
self.completionBlock([NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastError userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey: [error localizedDescription],
NSUnderlyingErrorKey: error,
NSURLErrorFailingURLErrorKey: failingUrl ? failingUrl : [NSNull null],
}]);
self.completionBlock = nil;
}
+2 -1
View File
@@ -9,7 +9,8 @@
#ifndef SUAPPCASTITEM_H
#define SUAPPCASTITEM_H
#include "SUExport.h"
#import <Foundation/Foundation.h>
#import "SUExport.h"
SU_EXPORT @interface SUAppcastItem : NSObject
@property (copy, readonly) NSString *title;
+8 -4
View File
@@ -152,8 +152,9 @@
}
// Find the appropriate release notes URL.
if (dict[SUAppcastElementReleaseNotesLink]) {
self.releaseNotesURL = [NSURL URLWithString:dict[SUAppcastElementReleaseNotesLink]];
NSString *releaseNotesString = dict[SUAppcastElementReleaseNotesLink];
if (releaseNotesString) {
self.releaseNotesURL = [NSURL URLWithString:releaseNotesString];
} else if ([self.itemDescription hasPrefix:@"http://"] || [self.itemDescription hasPrefix:@"https://"]) { // if the description starts with http:// or https:// use that.
self.releaseNotesURL = [NSURL URLWithString:self.itemDescription];
} else {
@@ -164,12 +165,15 @@
if (deltaDictionaries) {
NSMutableDictionary *deltas = [NSMutableDictionary dictionary];
for (NSDictionary *deltaDictionary in deltaDictionaries) {
NSString *deltaFrom = deltaDictionary[SUAppcastAttributeDeltaFrom];
if (!deltaFrom) continue;
NSMutableDictionary *fakeAppCastDict = [dict mutableCopy];
[fakeAppCastDict removeObjectForKey:SUAppcastElementDeltas];
fakeAppCastDict[SURSSElementEnclosure] = deltaDictionary;
SUAppcastItem *deltaItem = [[[self class] alloc] initWithDictionary:fakeAppCastDict];
SUAppcastItem *deltaItem = [[SUAppcastItem alloc] initWithDictionary:fakeAppCastDict];
deltas[deltaDictionary[SUAppcastAttributeDeltaFrom]] = deltaItem;
deltas[deltaFrom] = deltaItem;
}
self.deltaUpdates = deltas;
}
+3 -3
View File
@@ -34,7 +34,7 @@
return self;
}
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; }
- (NSString *__nonnull)description { return [NSString stringWithFormat:@"%@ <%@, %@>", [self class], [self.host bundlePath], [self.host installationPath]]; }
- (IBAction)installNow:(id)__unused sender
{
@@ -57,12 +57,12 @@
self.completionBlock = nil;
}
- (NSImage *)applicationIcon
- (NSImage *__nonnull)applicationIcon
{
return [self.host icon];
}
- (NSString *)titleText
- (NSString *__nonnull)titleText
{
if ([self.updateItem isCriticalUpdate])
{
+1
View File
@@ -27,6 +27,7 @@
- (BOOL)hostSupportsItem:(SUAppcastItem *)ui;
- (BOOL)itemContainsSkippedVersion:(SUAppcastItem *)ui;
- (BOOL)itemContainsValidUpdate:(SUAppcastItem *)ui;
- (void)appcastDidFinishLoading:(SUAppcast *)ac;
- (void)didFindValidUpdate;
- (void)didNotFindUpdate;
+94 -24
View File
@@ -191,6 +191,11 @@
{
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]];
[request setValue:[self.updater userAgentString] forHTTPHeaderField:@"User-Agent"];
if ([[self.updater delegate] respondsToSelector:@selector(updater:willDownloadUpdate:withRequest:)]) {
[[self.updater delegate] updater:self.updater
willDownloadUpdate:self.updateItem
withRequest:request];
}
self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self];
}
@@ -219,29 +224,81 @@
[self.download setDestination:self.downloadPath allowOverwrite:YES];
}
/**
* 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)validateUpdateDownloadedToPath:(NSString *)downloadedPath extractedToPath:(NSString *)extractedPath DSASignature:(NSString *)DSASignature publicDSAKey:(NSString *)publicDSAKey
{
NSString *newBundlePath = [SUInstaller appPathInUpdateFolder:extractedPath forHost:self.host];
BOOL isPackage = NO;
NSString *installSourcePath = [SUInstaller installSourcePathInUpdateFolder:extractedPath forHost:self.host isPackage:&isPackage isGuided:NULL];
if (installSourcePath == nil) {
SULog(@"No suitable install is found in the update. The update will be rejected.");
return NO;
}
// Modern packages are not distributed as bundles and are code signed differently than regular applications
if (isPackage) {
BOOL packageValidated = [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
if (newBundlePath) {
if ([SUCodeSigningVerifier hostApplicationIsCodeSigned]) {
NSError *error = nil;
if ([SUCodeSigningVerifier codeSignatureMatchesHostAndIsValidAtPath:newBundlePath error:&error]) {
return YES;
} else {
SULog(@"Code signature check on update failed: %@. Sparkle will use DSA signature instead.", error);
}
} else {
SULog(@"The host app is not signed using Apple Code Signing, and therefore cannot verify updates this way. Sparkle will use DSA signature instead.");
if (!packageValidated) {
SULog(@"DSA signature validation of the package failed. The update will be rejected.");
}
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 {
BOOL hostIsCodeSigned = [SUCodeSigningVerifier hostApplicationIsCodeSigned];
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 codeSignatureMatchesHostAndIsValidAtPath: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;
}
}
if (DSASignature) {
return [SUDSAVerifier validatePath:downloadedPath withEncodedDSASignature:DSASignature withPublicDSAKey:publicDSAKey];
} else {
SULog(@"The appcast item for the update has no DSA signature. The update will be rejected, because both DSA and Apple Code Signing verification failed.");
return NO;
}
return YES;
}
- (void)downloadDidFinish:(NSURLDownload *)__unused d
@@ -253,9 +310,21 @@
- (void)download:(NSURLDownload *)__unused download didFailWithError:(NSError *)error
{
NSURL *failingUrl = error.userInfo[NSURLErrorFailingURLErrorKey];
if (!failingUrl) {
failingUrl = [self.updateItem fileURL];
}
if ([[self.updater delegate] respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) {
[[self.updater delegate] updater:self.updater
failedToDownloadUpdate:self.updateItem
error:error];
}
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil),
NSUnderlyingErrorKey: error,
NSURLErrorFailingURLErrorKey: failingUrl ? failingUrl : [NSNull null],
}]];
}
@@ -350,18 +419,19 @@
[updaterDelegate updater:self.updater willInstallUpdate:self.updateItem];
}
NSBundle *sparkleBundle = [NSBundle bundleWithIdentifier:SUBundleIdentifier];
NSBundle *sparkleBundle = self.updater.sparkleBundle;
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
NSString *const relaunchPathToCopy = [sparkleBundle pathForResource:[[sparkleBundle infoDictionary] objectForKey:SURelaunchToolNameKey] ofType:@"app"];
NSString *const relaunchToolName = @"" SPARKLE_RELAUNCH_TOOL_NAME;
NSString *const relaunchPathToCopy = [sparkleBundle pathForResource:relaunchToolName ofType:@"app"];
if (relaunchPathToCopy != nil) {
NSString *targetPath = [self.host.appCachePath stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
NSError *error = nil;
[[NSFileManager defaultManager] createDirectoryAtPath:[targetPath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:@{} error:&error];
if ([SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:nil error:&error]) {
if ([SUPlainInstaller copyPathWithAuthentication:relaunchPathToCopy overPath:targetPath temporaryName:nil appendVersion:SPARKLE_APPEND_VERSION_NUMBER error:&error]) {
self.relaunchPath = targetPath;
} else {
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
@@ -375,7 +445,8 @@
if ([updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)])
[updaterDelegate updaterWillRelaunchApplication:self.updater];
if (!self.relaunchPath || ![[NSFileManager defaultManager] fileExistsAtPath:self.relaunchPath]) {
NSString *relaunchToolPath = [[NSBundle bundleWithPath:self.relaunchPath] executablePath];
if (!relaunchToolPath || ![[NSFileManager defaultManager] fileExistsAtPath:self.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]],
@@ -389,7 +460,6 @@
if ([updaterDelegate respondsToSelector:@selector(pathToRelaunchForUpdater:)]) {
pathToRelaunch = [updaterDelegate pathToRelaunchForUpdater:self.updater];
}
NSString *relaunchToolPath = [[NSBundle bundleWithPath:self.relaunchPath] executablePath];
[NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:@[[self.host bundlePath],
pathToRelaunch,
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
@@ -441,7 +511,7 @@
- (void)abortUpdateWithError:(NSError *)error
{
if ([error code] != SUNoUpdateError) { // Let's not bother logging this.
SULog(@"Error: %@ %@", [error localizedDescription], [error localizedFailureReason]);
SULog(@"Error: %@ %@ (URL %@)", error.localizedDescription, error.localizedFailureReason, error.userInfo[NSURLErrorFailingURLErrorKey]);
}
if (self.download) {
[self.download cancel];
+1 -1
View File
@@ -20,7 +20,7 @@ static BOOL applyBinaryDeltaToFile(xar_t x, xar_file_t file, NSString *sourceFil
NSString *patchFile = temporaryFilename(@"apply-binary-delta");
xar_extract_tofile(x, file, [patchFile fileSystemRepresentation]);
const char *argv[] = {"/usr/bin/bspatch", [sourceFilePath fileSystemRepresentation], [destinationFilePath fileSystemRepresentation], [patchFile fileSystemRepresentation]};
BOOL success = (bspatch(4, (char **)argv) == 0);
BOOL success = (bspatch(4, argv) == 0);
unlink([patchFile fileSystemRepresentation]);
return success;
}
+8 -5
View File
@@ -9,6 +9,8 @@
#ifndef SUBINARYDELTACOMMON_H
#define SUBINARYDELTACOMMON_H
#import <Foundation/Foundation.h>
#include <fts.h>
#define PERMISSION_FLAGS (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX)
@@ -16,6 +18,10 @@
#define IS_VALID_PERMISSIONS(mode) \
(((mode & PERMISSION_FLAGS) == 0755) || ((mode & PERMISSION_FLAGS) == 0644))
#define APPLE_CODE_SIGN_XATTR_CODE_DIRECTORY_KEY "com.apple.cs.CodeDirectory"
#define APPLE_CODE_SIGN_XATTR_CODE_REQUIREMENTS_KEY "com.apple.cs.CodeRequirements"
#define APPLE_CODE_SIGN_XATTR_CODE_SIGNATURE_KEY "com.apple.cs.CodeSignature"
#define BINARY_DELTA_ATTRIBUTES_KEY "binary-delta-attributes"
#define MAJOR_DIFF_VERSION_KEY "major-version"
#define MINOR_DIFF_VERSION_KEY "minor-version"
@@ -55,17 +61,14 @@ typedef NS_ENUM(uint16_t, SUBinaryDeltaMajorVersion)
typedef NS_ENUM(uint16_t, SUBinaryDeltaMinorVersion)
{
SUAzureMinorVersion = 1,
SUBeigeMinorVersion = 0,
SUBeigeMinorVersion = 1,
};
#define FIRST_DELTA_DIFF_MAJOR_VERSION SUAzureMajorVersion
#define FIRST_DELTA_DIFF_MINOR_VERSION 0
#define FIRST_DELTA_DIFF_MINOR_VERSION ((SUBinaryDeltaMinorVersion)0)
#define LATEST_DELTA_DIFF_MAJOR_VERSION SUBeigeMajorVersion
@class NSString;
@class NSData;
extern int compareFiles(const FTSENT **a, const FTSENT **b);
extern NSData *hashOfFileContents(FTSENT *ent);
extern NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion);
+6 -3
View File
@@ -43,7 +43,7 @@ SUBinaryDeltaMinorVersion latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVe
case SUBeigeMajorVersion:
return SUBeigeMinorVersion;
}
return 0;
return (SUBinaryDeltaMinorVersion)0;
}
NSString *temporaryFilename(NSString *base)
@@ -144,8 +144,11 @@ NSData *hashOfFileContents(FTSENT *ent)
NSString *hashOfTreeWithVersion(NSString *path, uint16_t majorVersion)
{
const char *sourcePaths[] = {[path fileSystemRepresentation], 0};
FTS *fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
char pathBuffer[PATH_MAX] = {0};
[path getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)];
char * const sourcePaths[] = {pathBuffer, 0};
FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
if (!fts) {
perror("fts_open");
return nil;
+57 -4
View File
@@ -18,6 +18,7 @@
#include <sys/param.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/xattr.h>
#include <xar/xar.h>
extern int bsdiff(int argc, const char **argv);
@@ -101,6 +102,39 @@ static bool aclExists(const FTSENT *ent)
return false;
}
static bool codeSignatureExtendedAttributeExists(const FTSENT *ent)
{
const int options = XATTR_NOFOLLOW;
ssize_t listSize = listxattr(ent->fts_path, NULL, 0, options);
if (listSize == -1) {
return false;
}
char *buffer = malloc((size_t)listSize);
assert(buffer != NULL);
ssize_t sizeBack = listxattr(ent->fts_path, buffer, (size_t)listSize, options);
assert(sizeBack == listSize);
size_t startCharacterIndex = 0;
for (size_t characterIndex = 0; characterIndex < (size_t)listSize; characterIndex++) {
if (buffer[characterIndex] == '\0') {
char *attribute = &buffer[startCharacterIndex];
size_t length = characterIndex - startCharacterIndex;
if (strncmp(APPLE_CODE_SIGN_XATTR_CODE_DIRECTORY_KEY, attribute, length) == 0 ||
strncmp(APPLE_CODE_SIGN_XATTR_CODE_REQUIREMENTS_KEY, attribute, length) == 0 ||
strncmp(APPLE_CODE_SIGN_XATTR_CODE_SIGNATURE_KEY, attribute, length) == 0) {
free(buffer);
return true;
}
startCharacterIndex = characterIndex + 1;
}
}
free(buffer);
return false;
}
static NSString *absolutePath(NSString *path)
{
NSURL *url = [[NSURL alloc] initFileURLWithPath:path];
@@ -203,8 +237,11 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
NSMutableDictionary *originalTreeState = [NSMutableDictionary dictionary];
const char *sourcePaths[] = {[source fileSystemRepresentation], 0};
FTS *fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
char pathBuffer[PATH_MAX] = {0};
[source getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)];
char *sourcePaths[] = {pathBuffer, 0};
FTS *fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
if (!fts) {
perror("fts_open");
return 1;
@@ -237,6 +274,11 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
fprintf(stderr, "\nDiffing ACLs are not supported. Detected ACL in before-tree on file %s\n", ent->fts_path);
return 1;
}
if (codeSignatureExtendedAttributeExists(ent)) {
fprintf(stderr, "\nDiffing code signed extended attributes are not supported. Detected extended attribute in before-tree on file %s\n", ent->fts_path);
return 1;
}
}
fts_close(fts);
@@ -256,9 +298,12 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
if (verbose) {
fprintf(stderr, "\nProcessing %s...", [destination fileSystemRepresentation]);
}
pathBuffer[0] = 0;
[destination getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)];
sourcePaths[0] = [destination fileSystemRepresentation];
fts = fts_open((char* const*)sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
sourcePaths[0] = pathBuffer;
fts = fts_open(sourcePaths, FTS_PHYSICAL | FTS_NOCHDIR, compareFiles);
if (!fts) {
perror("fts_open");
return 1;
@@ -284,6 +329,9 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
// We should validate permissions and ACLs even if we don't store the info in the diff in the case of ACLs,
// or in the case of permissions if the patch version is 1
// We should also not allow files with code signed extended attributes since Apple doesn't recommend inserting these
// inside an application, and since we don't preserve extended attribitutes anyway
mode_t permissions = [info[INFO_PERMISSIONS_KEY] unsignedShortValue];
if (!IS_VALID_PERMISSIONS(permissions)) {
fprintf(stderr, "\nInvalid file permissions after-tree on file %s\nOnly permissions with modes 0755 and 0644 are supported\n", ent->fts_path);
@@ -295,6 +343,11 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
return 1;
}
if (codeSignatureExtendedAttributeExists(ent)) {
fprintf(stderr, "\nDiffing code signed extended attributes are not supported. Detected extended attribute in after-tree on file %s\n", ent->fts_path);
return 1;
}
NSDictionary *oldInfo = originalTreeState[key];
if ([info isEqual:oldInfo]) {
+6 -5
View File
@@ -10,6 +10,8 @@
#ifndef SUCONSTANTS_H
#define SUCONSTANTS_H
#import <Foundation/Foundation.h>
// -----------------------------------------------------------------------------
// Misc:
// -----------------------------------------------------------------------------
@@ -49,11 +51,10 @@ extern NSString *const SUPromptUserOnFirstLaunchKey;
extern NSString *const SUKeepDownloadOnFailedInstallKey;
extern NSString *const SUDefaultsDomainKey;
extern NSString *const SUFixedHTMLDisplaySizeKey __attribute__((deprecated("This key is obsolete and has no effect.")));
extern NSString *const SUAppendVersionNumberKey;
extern NSString *const SUEnableAutomatedDowngradesKey;
extern NSString *const SUNormalizeInstalledApplicationNameKey;
extern NSString *const SURelaunchToolNameKey;
extern NSString *const SUAppendVersionNumberKey __attribute__((deprecated("This key is obsolete. See SPARKLE_APPEND_VERSION_NUMBER.")));
extern NSString *const SUEnableAutomatedDowngradesKey __attribute__((deprecated("This key is obsolete. See SPARKLE_AUTOMATED_DOWNGRADES.")));
extern NSString *const SUNormalizeInstalledApplicationNameKey __attribute__((deprecated("This key is obsolete. SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME.")));
extern NSString *const SURelaunchToolNameKey __attribute__((deprecated("This key is obsolete. SPARKLE_RELAUNCH_TOOL_NAME.")));
// -----------------------------------------------------------------------------
// Appcast keys::
+8
View File
@@ -15,6 +15,14 @@
#ifndef SUDSAVERIFIER_H
#define SUDSAVERIFIER_H
#import <Foundation/Foundation.h>
#if __MAC_OS_X_VERSION_MAX_ALLOWED < 1090
@interface NSData (SUDSAVerifier)
- (id)initWithBase64Encoding:(NSString *)base64String;
@end
#endif
@interface SUDSAVerifier : NSObject
+ (BOOL)validatePath:(NSString *)path withEncodedDSASignature:(NSString *)encodedSignature withPublicDSAKey:(NSString *)pkeyString;
+1 -1
View File
@@ -65,7 +65,7 @@
CFRelease(uuid);
}
}
while (noErr == FSPathMakeRefWithOptions((UInt8 *)[mountPoint fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &tmpRef, NULL));
while (noErr == FSPathMakeRefWithOptions((const UInt8 *)[mountPoint fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &tmpRef, NULL));
NSData *promptData = nil;
promptData = [NSData dataWithBytes:"yes\n" length:4];
+2 -2
View File
@@ -22,11 +22,11 @@ A guided installation can be started by applications other than the application
#ifndef SUGUIDEDPACKAGEINSTALLER_H
#define SUGUIDEDPACKAGEINSTALLER_H
#import <Foundation/Foundation.h>
#import "Sparkle.h"
#import "SUInstaller.h"
@interface SUGuidedPackageInstaller : SUInstaller {
}
@interface SUGuidedPackageInstaller : SUInstaller
/*! Perform the guided installation */
+ (void)performInstallationToPath:(NSString *)path fromPath:(NSString *)installerGuide host:(SUHost *)host versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
+19 -14
View File
@@ -11,7 +11,7 @@
#import "SUGuidedPackageInstaller.h"
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char* executablePath, AuthorizationFlags options, const char* const* arguments)
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char* executablePath, AuthorizationFlags options, char* const* arguments)
{
sig_t oldSigChildHandler = signal(SIGCHLD, SIG_DFL);
BOOL returnValue = YES;
@@ -19,7 +19,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
/* AuthorizationExecuteWithPrivileges used to support 10.4+; should be replaced with XPC or external process */
if (AuthorizationExecuteWithPrivileges(authorization, executablePath, options, (char* const*)arguments, NULL) == errAuthorizationSuccess)
if (AuthorizationExecuteWithPrivileges(authorization, executablePath, options, arguments, NULL) == errAuthorizationSuccess)
#pragma clang diagnostic pop
{
int status = 0;
@@ -38,7 +38,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
+ (AuthorizationRef)authorizationForExecutable:(NSString*)executablePath
{
NSParameterAssert(executablePath);
SUParameterAssert(executablePath);
// Get authorization using advice in Apple's Technical Q&A1172
@@ -52,14 +52,15 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
if ((validAuth == errAuthorizationSuccess) &&
(auth != NULL))
{
const char* executableFileSystemRepresentation = [executablePath fileSystemRepresentation];
char executableFileSystemRepresentation[PATH_MAX];
[executablePath getFileSystemRepresentation:executableFileSystemRepresentation maxLength:sizeof(executableFileSystemRepresentation)];
// Prepare a right allowing script to execute with privileges
AuthorizationItem right;
memset(&right,0,sizeof(right));
right.name = kAuthorizationRightExecute;
right.value = (void*) executableFileSystemRepresentation;
right.valueLength = strlen(executableFileSystemRepresentation);
AuthorizationItem right = {
.name = kAuthorizationRightExecute,
.value = executableFileSystemRepresentation,
.valueLength = strlen(executableFileSystemRepresentation),
};
// Package up the single right
AuthorizationRights rights;
@@ -71,9 +72,10 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
validAuth = AuthorizationCopyRights(auth,
&rights,
kAuthorizationEmptyEnvironment,
kAuthorizationFlagPreAuthorize |
(AuthorizationFlags)
(kAuthorizationFlagPreAuthorize |
kAuthorizationFlagExtendRights |
kAuthorizationFlagInteractionAllowed,
kAuthorizationFlagInteractionAllowed),
NULL);
if (validAuth != errAuthorizationSuccess)
{
@@ -92,7 +94,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
+ (void)performInstallationToPath:(NSString *)destinationPath fromPath:(NSString *)packagePath host:(SUHost *)__unused host versionComparator:(id<SUVersionComparison>)__unused comparator completionHandler:(void (^)(NSError *))completionHandler
{
NSParameterAssert(packagePath);
SUParameterAssert(packagePath);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
@@ -105,10 +107,13 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
AuthorizationRef auth = [self authorizationForExecutable:installerPath];
if (auth != NULL)
{
char pathBuffer[PATH_MAX] = {0};
[packagePath getFileSystemRepresentation:pathBuffer maxLength:sizeof(pathBuffer)];
// Permission was granted to execute the installer with privileges
const char* const arguments[] = {
char * const arguments[] = {
"-pkg",
[packagePath fileSystemRepresentation],
pathBuffer,
"-target",
"/",
NULL
+1
View File
@@ -5,6 +5,7 @@
// Copyright 2008 Andy Matuschak. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SUUpdater.h"
#import "SUAppcast.h"
#import "SUAppcastItem.h"
+22 -13
View File
@@ -41,7 +41,7 @@ typedef struct {
{
if ((self = [super init]))
{
if (aBundle == nil) aBundle = [NSBundle mainBundle];
SUParameterAssert(aBundle);
self.bundle = aBundle;
if (![self.bundle bundleIdentifier]) {
SULog(@"Error: the bundle being updated at %@ has no %@! This will cause preference read/write to not work properly.", self.bundle, kCFBundleIdentifierKey);
@@ -53,7 +53,8 @@ typedef struct {
}
// If we're using the main bundle's defaults we'll use the standard user defaults mechanism, otherwise we have to get CF-y.
usesStandardUserDefaults = !self.defaultsDomain || [self.defaultsDomain isEqualToString:[[NSBundle mainBundle] bundleIdentifier]];
NSString *mainBundleIdentifier = NSBundle.mainBundle.bundleIdentifier;
usesStandardUserDefaults = !self.defaultsDomain || [self.defaultsDomain isEqualToString:mainBundleIdentifier];
}
return self;
}
@@ -90,7 +91,7 @@ typedef struct {
- (NSString *)installationPath
{
if ([[[NSBundle bundleWithIdentifier:SUBundleIdentifier] infoDictionary][SUNormalizeInstalledApplicationNameKey] boolValue]) {
if (SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) {
// We'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name.
NSString *normalizedAppPath = [[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[self.bundle bundlePath] pathExtension]]];
if (![[NSFileManager defaultManager] fileExistsAtPath:[[[self.bundle bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.%@", [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleNameKey], [[self.bundle bundlePath] pathExtension]]]]) {
@@ -100,7 +101,7 @@ typedef struct {
return [self.bundle bundlePath];
}
- (NSString *)name
- (NSString *__nonnull)name
{
NSString *name;
@@ -117,7 +118,7 @@ typedef struct {
return [[[NSFileManager defaultManager] displayNameAtPath:[self.bundle bundlePath]] stringByDeletingPathExtension];
}
- (NSString *)version
- (NSString *__nonnull)version
{
NSString *version = [self.bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
if (!version || [version isEqualToString:@""])
@@ -125,7 +126,7 @@ typedef struct {
return version;
}
- (NSString *)displayVersion
- (NSString *__nonnull)displayVersion
{
NSString *shortVersionString = [self.bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];
if (shortVersionString)
@@ -134,7 +135,7 @@ typedef struct {
return [self version]; // Fall back on the normal version string.
}
- (NSImage *)icon
- (NSImage *__nonnull)icon
{
// Cache the application icon.
NSString *iconPath = [self.bundle pathForResource:[self.bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:@"icns"];
@@ -151,7 +152,7 @@ typedef struct {
if (!icon) {
BOOL isMainBundle = (self.bundle == [NSBundle mainBundle]);
NSString *fileType = isMainBundle ? (NSString *)kUTTypeApplication : (NSString *)kUTTypeBundle;
NSString *fileType = isMainBundle ? (__bridge NSString *)kUTTypeApplication : (__bridge NSString *)kUTTypeBundle;
icon = [[NSWorkspace sharedWorkspace] iconForFileType:fileType];
}
return icon;
@@ -169,17 +170,25 @@ typedef struct {
return ([[NSApplication sharedApplication] activationPolicy] == NSApplicationActivationPolicyAccessory);
}
- (NSString *)publicDSAKey
- (NSString *__nullable)publicDSAKey
{
// Maybe the key is just a string in the Info.plist.
NSString *key = [self.bundle objectForInfoDictionaryKey:SUPublicDSAKeyKey];
if (key) { return key; }
if (key) {
return key;
}
// More likely, we've got a reference to a Resources file by filename:
NSString *keyFilename = [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
if (!keyFilename) { return nil; }
NSError *ignoreErr = nil;
return [NSString stringWithContentsOfFile:[self.bundle pathForResource:keyFilename ofType:nil] encoding:NSASCIIStringEncoding error:&ignoreErr];
if (!keyFilename) {
return nil;
}
NSString *keyPath = [self.bundle pathForResource:keyFilename ofType:nil];
if (!keyPath) {
return nil;
}
return [NSString stringWithContentsOfFile:keyPath encoding:NSASCIIStringEncoding error:nil];
}
- (NSArray *)systemProfile
+1 -1
View File
@@ -15,7 +15,7 @@
@class SUHost;
@interface SUInstaller : NSObject
+ (NSString *)appPathInUpdateFolder:(NSString *)updateFolder forHost:(SUHost *)host;
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr;
+ (void)installFromUpdateFolder:(NSString *)updateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler;
+ (NSString *)updateFolder;
+4 -10
View File
@@ -44,8 +44,8 @@ static NSString *sUpdateFolder = nil;
+ (NSString *)installSourcePathInUpdateFolder:(NSString *)inUpdateFolder forHost:(SUHost *)host isPackage:(BOOL *)isPackagePtr isGuided:(BOOL *)isGuidedPtr
{
NSParameterAssert(inUpdateFolder);
NSParameterAssert(host);
SUParameterAssert(inUpdateFolder);
SUParameterAssert(host);
// Search subdirectories for the application
NSString *currentFile,
@@ -84,7 +84,8 @@ static NSString *sUpdateFolder = nil;
} else {
// Try matching on bundle identifiers in case the user has changed the name of the host app
NSBundle *incomingBundle = [NSBundle bundleWithPath:currentPath];
if (incomingBundle && [[incomingBundle bundleIdentifier] isEqualToString:[[host bundle] bundleIdentifier]]) {
NSString *hostBundleIdentifier = host.bundle.bundleIdentifier;
if (incomingBundle && [incomingBundle.bundleIdentifier isEqualToString:hostBundleIdentifier]) {
isPackage = NO;
newAppDownloadPath = currentPath;
break;
@@ -121,13 +122,6 @@ static NSString *sUpdateFolder = nil;
return newAppDownloadPath;
}
+ (NSString *)appPathInUpdateFolder:(NSString *)updateFolder forHost:(SUHost *)host
{
BOOL isPackage = NO;
NSString *path = [self installSourcePathInUpdateFolder:updateFolder forHost:host isPackage:&isPackage isGuided:nil];
return isPackage ? nil : path;
}
+ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler
{
BOOL isPackage = NO;
+2
View File
@@ -9,6 +9,8 @@
#ifndef SUPACKAGEINSTALLER_H
#define SUPACKAGEINSTALLER_H
#import <Foundation/Foundation.h>
#import "SUUpdater.h"
#import "SUAppcast.h"
+6 -2
View File
@@ -30,9 +30,13 @@
NSString *lastPathComponent = [path lastPathComponent];
for (NSString *currentType in typeSelectorDictionary)
{
NSString *value = typeSelectorDictionary[currentType];
assert(value);
if ([currentType length] > [lastPathComponent length]) continue;
if ([[lastPathComponent substringFromIndex:[lastPathComponent length] - [currentType length]] isEqualToString:currentType])
return NSSelectorFromString(typeSelectorDictionary[currentType]);
if ([[lastPathComponent substringFromIndex:[lastPathComponent length] - [currentType length]] isEqualToString:currentType]) {
return NSSelectorFromString(value);
}
}
return NULL;
}
+2
View File
@@ -9,6 +9,8 @@
#ifndef SUPLAININSTALLER_H
#define SUPLAININSTALLER_H
#import <Foundation/Foundation.h>
#import "SUUpdater.h"
#import "SUAppcast.h"
+8 -9
View File
@@ -16,10 +16,12 @@
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler
{
NSParameterAssert(host);
SUParameterAssert(host);
BOOL allowDowngrades = SPARKLE_AUTOMATED_DOWNGRADES;
// Prevent malicious downgrades
if (![[[NSBundle bundleWithIdentifier:SUBundleIdentifier] infoDictionary][SUEnableAutomatedDowngradesKey] boolValue]) {
if (!allowDowngrades) {
if ([comparator compareVersion:[host version] toVersion:[[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]] == NSOrderedDescending) {
NSString *errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Possible attack in progress! Attempting to \"upgrade\" from %@ to %@. Aborting update.", [host version], [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]];
NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
@@ -32,14 +34,11 @@
NSError *error = nil;
NSString *oldPath = [host bundlePath];
NSString *tempName = [self temporaryNameForPath:[host installationPath]];
BOOL hostIsCodeSigned = [SUCodeSigningVerifier applicationAtPathIsCodeSigned:oldPath];
BOOL result = [self copyPathWithAuthentication:path overPath:installationPath temporaryName:tempName error:&error];
BOOL result = [self copyPathWithAuthentication:path overPath:installationPath temporaryName:tempName appendVersion:SPARKLE_APPEND_VERSION_NUMBER error:&error];
if (result) {
// If the host is code signed, then the replacement should be be too (and the signature should be valid).
BOOL needToCheckCodeSignature = (hostIsCodeSigned || [SUCodeSigningVerifier applicationAtPathIsCodeSigned:installationPath]);
if (needToCheckCodeSignature) {
if ([SUCodeSigningVerifier applicationAtPathIsCodeSigned:installationPath]) {
result = [SUCodeSigningVerifier codeSignatureIsValidAtPath:installationPath error:&error];
}
}
@@ -48,7 +47,7 @@
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.
[self _movePathToTrash:oldPath appendVersion:SPARKLE_APPEND_VERSION_NUMBER]; // On success, trash old copy if there's still one due to renaming.
}
}
+4 -2
View File
@@ -9,12 +9,14 @@
#ifndef SUPLAININSTALLERINTERNALS_H
#define SUPLAININSTALLERINTERNALS_H
#import <Foundation/Foundation.h>
#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)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)tmp appendVersion:(BOOL)a error:(NSError **)error;
+ (void)_movePathToTrash:(NSString *)path appendVersion:(BOOL)a;
+ (BOOL)_removeFileAtPath:(NSString *)path error:(NSError **)error;
+ (BOOL)_removeFileAtPathWithForcedAuthentication:(NSString *)src error:(NSError **)error;
@end
+52 -33
View File
@@ -61,14 +61,14 @@ static inline void PerformOnMainThreadSync(dispatch_block_t theBlock)
// 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, const char *const *arguments)
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, (char* const*)arguments, NULL) == errAuthorizationSuccess)
if (AuthorizationExecuteWithPrivileges(authorization, executablePath, options, arguments, NULL) == errAuthorizationSuccess)
{
int status;
pid_t pid = wait(&status);
@@ -107,7 +107,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
return [tempDir lastPathComponent];
}
+ (NSString *)_temporaryCopyNameForPath:(NSString *)path didFindTrash:(BOOL *)outDidFindTrash
+ (NSString *)_temporaryCopyNameForPath:(NSString *)path appendVersion:(BOOL)appendVersion didFindTrash:(BOOL *)outDidFindTrash
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
NSString *tempDir = nil;
@@ -117,7 +117,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
FSVolumeRefNum vSrcRefNum = kFSInvalidVolumeRefNum;
FSCatalogInfo catInfo;
memset(&catInfo, 0, sizeof(catInfo));
OSStatus err = FSPathMakeRef((UInt8 *)[path fileSystemRepresentation], &pathRef, NULL);
OSStatus err = FSPathMakeRef((const UInt8 *)[path fileSystemRepresentation], &pathRef, NULL);
if( err == noErr )
{
err = FSGetCatalogInfo(&pathRef, kFSCatInfoVolume, &catInfo, NULL, NULL, NULL);
@@ -140,7 +140,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
// Let's try to read the version number so the filename will be more meaningful
NSString *prefix;
if ([[[NSBundle bundleWithIdentifier:SUBundleIdentifier] infoDictionary][SUAppendVersionNumberKey] boolValue]) {
if (appendVersion) {
NSString *postFix = nil;
NSString *version = nil;
if ((version = [[NSBundle bundleWithPath: path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]) && ![version isEqualToString:@""])
@@ -172,9 +172,14 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
const char *srcPath = [src fileSystemRepresentation];
const char *tmpPath = [tmp fileSystemRepresentation];
const char *dstPath = [dst fileSystemRepresentation];
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.
@@ -228,16 +233,16 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
if (res) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
{
const char *coParams[] = { "-R", uidgid, srcPath, NULL };
char *coParams[] = { "-R", uidgid, srcPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams);
if (!res)
SULog(@"chown -R %s %s failed.", uidgid, srcPath);
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.
{
const char *rmParams[] = { "-rf", tmpPath, NULL };
char *rmParams[] = { "-rf", tmpPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams);
if (!res)
SULog(@"rm failed");
@@ -245,7 +250,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
if (res && haveDst) // Move old exe to tmp path.
{
const char *mvParams[] = { "-f", dstPath, tmpPath, NULL };
char *mvParams[] = { "-f", dstPath, tmpPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams);
if (!res)
SULog(@"mv 1 failed");
@@ -253,7 +258,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
if (res) // Move new exe to old exe's path.
{
const char *mvParams2[] = { "-f", srcPath, dstPath, NULL };
char *mvParams2[] = { "-f", srcPath, dstPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams2);
if (!res)
SULog(@"mv 2 failed");
@@ -304,9 +309,14 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
const char *srcPath = [src fileSystemRepresentation];
const char *dstPath = [dst fileSystemRepresentation];
const char *dstContainerPath = [[dst stringByDeletingLastPathComponent] fileSystemRepresentation];
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);
@@ -332,7 +342,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
if (res) // Set permissions while it's still in source, so we have it with working and correct perms when it arrives at destination.
{
const char *coParams[] = { "-R", uidgid, srcPath, NULL };
char *coParams[] = { "-R", uidgid, srcPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, coParams);
if (!res)
SULog(@"Can't set permissions");
@@ -341,7 +351,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
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.
{
const char *rmParams[] = { "-rf", dstPath, NULL };
char *rmParams[] = { "-rf", dstPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams);
if (!res)
SULog(@"Can't remove destination file");
@@ -349,7 +359,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
if (res) // Move!.
{
const char *mvParams[] = { "-f", srcPath, dstPath, NULL };
char *mvParams[] = { "-f", srcPath, dstPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/mv", kAuthorizationFlagDefaults, mvParams);
if (!res)
SULog(@"Can't move source file");
@@ -378,7 +388,8 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
{
// *** MUST BE SAFE TO CALL ON NON-MAIN THREAD!
const char *srcPath = [src fileSystemRepresentation];
char srcPath[PATH_MAX] = {0};
[src getFileSystemRepresentation:srcPath maxLength:sizeof(srcPath)];
AuthorizationRef auth = NULL;
OSStatus authStat = errAuthorizationDenied;
@@ -397,7 +408,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
if (res) // If there's something at our tmp path (previous failed update or whatever) delete that first.
{
const char *rmParams[] = { "-rf", srcPath, NULL };
char *rmParams[] = { "-rf", srcPath, NULL };
res = AuthorizationExecuteWithPrivilegesAndWait(auth, "/bin/rm", kAuthorizationFlagDefaults, rmParams);
if (!res)
SULog(@"Can't remove destination file");
@@ -432,14 +443,14 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
return success;
}
+ (void)_movePathToTrash:(NSString *)path
+ (void)_movePathToTrash:(NSString *)path appendVersion:(BOOL)appendVersion
{
//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];
NSString *trashPath = [self _temporaryCopyNameForPath:path appendVersion:appendVersion didFindTrash:&didFindTrash];
if( didFindTrash )
{
NSError *err = nil;
@@ -453,15 +464,15 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
}
}
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)__unused tmp error:(NSError *__autoreleasing *)error
+ (BOOL)copyPathWithAuthentication:(NSString *)src overPath:(NSString *)dst temporaryName:(NSString *)__unused tmp appendVersion:(BOOL)appendVersion error:(NSError *__autoreleasing *)error
{
FSRef srcRef, dstRef, dstDirRef, tmpDirRef;
OSStatus err;
BOOL hadFileAtDest = NO, didFindTrash = NO;
NSString *tmpPath = [self _temporaryCopyNameForPath:dst didFindTrash:&didFindTrash];
NSString *tmpPath = [self _temporaryCopyNameForPath:dst appendVersion:appendVersion didFindTrash:&didFindTrash];
// Make FSRef for destination:
err = FSPathMakeRefWithOptions((UInt8 *)[dst fileSystemRepresentation], kFSPathMakeRefDoNotFollowLeafSymlink, &dstRef, NULL);
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 )
{
@@ -481,12 +492,12 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
if( hadFileAtDest )
{
err = FSPathMakeRef((UInt8 *)[[tmpPath stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
err = FSPathMakeRef((const UInt8 *)[[tmpPath stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
if (err != noErr)
FSPathMakeRef((UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
FSPathMakeRef((const UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &tmpDirRef, NULL);
}
err = FSPathMakeRef((UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &dstDirRef, NULL);
err = FSPathMakeRef((const UInt8 *)[[dst stringByDeletingLastPathComponent] fileSystemRepresentation], &dstDirRef, NULL);
if (err == noErr && hadFileAtDest)
{
@@ -500,7 +511,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
}
}
err = FSPathMakeRef((UInt8 *)[src fileSystemRepresentation], &srcRef, NULL);
err = FSPathMakeRef((const UInt8 *)[src fileSystemRepresentation], &srcRef, NULL);
if (err == noErr)
{
NSFileManager *manager = [[NSFileManager alloc] init];
@@ -572,7 +583,7 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
NSFileManager *manager = [NSFileManager defaultManager];
#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101000
if (!&NSURLQuarantinePropertiesKey) {
NSString *const quarantineAttribute = (NSString*)kLSItemQuarantineProperties;
NSString *const quarantineAttribute = (__bridge NSString *)kLSItemQuarantineProperties;
const int removeXAttrOptions = XATTR_NOFOLLOW;
[self removeXAttr:quarantineAttribute
@@ -599,7 +610,11 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
}
#endif
NSURL *rootURL = [NSURL fileURLWithPath:root];
[rootURL setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL];
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.
@@ -612,7 +627,11 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza
NSDirectoryEnumerator *directoryEnumerator = [manager enumeratorAtURL:rootURL includingPropertiesForKeys:nil options:(NSDirectoryEnumerationOptions)0 errorHandler:nil];
for (NSURL *file in directoryEnumerator) {
[file setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL];
id fileResourceValue = nil;
[file getResourceValue:&fileResourceValue forKey:NSURLQuarantinePropertiesKey error:NULL];
if (fileResourceValue) {
[file setResourceValue:[NSNull null] forKey:NSURLQuarantinePropertiesKey error:NULL];
}
}
}
}
+1
View File
@@ -9,6 +9,7 @@
#ifndef SUSTANDARDVERSIONCOMPARATOR_H
#define SUSTANDARDVERSIONCOMPARATOR_H
#import <Foundation/Foundation.h>
#import "SUExport.h"
#import "SUVersionComparisonProtocol.h"
+1 -1
View File
@@ -9,7 +9,7 @@
#ifndef SUSYSTEMPROFILER_H
#define SUSYSTEMPROFILER_H
#import <Cocoa/Cocoa.h>
#import <Foundation/Foundation.h>
@class SUHost;
@interface SUSystemProfiler : NSObject
+1
View File
@@ -7,6 +7,7 @@
// Adapted from Sparkle+, by Tom Harrington.
//
#import <Cocoa/Cocoa.h>
#import "SUSystemProfiler.h"
#import "SUHost.h"
-1
View File
@@ -20,7 +20,6 @@
- (void)showModalAlert:(NSAlert *)alert;
- (IBAction)cancelDownload:(id)sender;
- (void)installAndRestart:(id)sender;
- (void)appcastDidFinishLoading:(SUAppcast *)ac;
@end
+8 -6
View File
@@ -63,11 +63,10 @@
[[self.updater delegate] updaterDidNotFindUpdate:self.updater];
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidNotFindUpdateNotification object:self.updater];
NSAlert *alert = [NSAlert alertWithMessageText: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.")
defaultButton:SULocalizedString(@"OK", nil)
alternateButton:nil
otherButton:nil
informativeTextWithFormat:SULocalizedString(@"%@ %@ is currently the newest version available.", nil), [self.host name], [self.host displayVersion]];
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];
}
@@ -201,7 +200,10 @@
- (void)abortUpdateWithError:(NSError *)error
{
NSAlert *alert = [NSAlert alertWithMessageText:SULocalizedString(@"Update Error!", nil) defaultButton:SULocalizedString(@"Cancel Update", nil) alternateButton:nil otherButton:nil informativeTextWithFormat:@"%@", [error localizedDescription]];
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = SULocalizedString(@"Update Error!", nil);
alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]];
[alert addButtonWithTitle:SULocalizedString(@"Cancel Update", nil)];
[self showModalAlert:alert];
[super abortUpdateWithError:error];
}
+3 -1
View File
@@ -9,13 +9,15 @@
#ifndef SUUNARCHIVER_H
#define SUUNARCHIVER_H
#import <Foundation/Foundation.h>
@class SUHost;
@protocol SUUnarchiverDelegate;
@interface SUUnarchiver : NSObject
@property (copy, readonly) NSString *archivePath;
@property (weak, readonly) NSString *updateHostBundlePath;
@property (copy, readonly) NSString *updateHostBundlePath;
@property (weak) id<SUUnarchiverDelegate> delegate;
+ (SUUnarchiver *)unarchiverForPath:(NSString *)path updatingHostBundlePath:(NSString *)host;
+13 -12
View File
@@ -107,18 +107,16 @@
- (void)displayReleaseNotes
{
// Set the default font
[self.releaseNotesView setPreferencesIdentifier:SUBundleIdentifier];
self.releaseNotesView.preferencesIdentifier = SUBundleIdentifier;
WebPreferences *prefs = [self.releaseNotesView preferences];
NSString *familyName = [[NSFont systemFontOfSize:8] familyName];
if ([familyName hasPrefix:@"."]) { // 10.9 returns ".Lucida Grande UI", which isn't a valid name for the WebView
familyName = @"Lucida Grande";
}
[prefs setStandardFontFamily:familyName];
[prefs setDefaultFontSize:(int)[NSFont systemFontSizeForControlSize:NSSmallControlSize]];
[prefs setPlugInsEnabled:NO];
[self.releaseNotesView setFrameLoadDelegate:self];
[self.releaseNotesView setPolicyDelegate:self];
prefs.plugInsEnabled = NO;
self.releaseNotesView.frameLoadDelegate = self;
self.releaseNotesView.policyDelegate = self;
// Set the default font
// "-apple-system-font" is a reference to the system UI font on OS X. "-apple-system" is the new recommended token, but for backward compatibility we can't use it.
prefs.standardFontFamily = @"-apple-system-font";
prefs.defaultFontSize = (int)[NSFont systemFontSize];
// Stick a nice big spinner in the middle of the web view until the page is loaded.
NSRect frame = [[self.releaseNotesView superview] frame];
@@ -239,7 +237,10 @@
- (void)webView:(WebView *)__unused sender decidePolicyForNavigationAction:(NSDictionary *)__unused actionInformation request:(NSURLRequest *)request frame:(WebFrame *)__unused frame decisionListener:(id<WebPolicyDecisionListener>)listener
{
if (self.webViewFinishedLoading) {
[[NSWorkspace sharedWorkspace] openURL:[request URL]];
NSURL *requestURL = request.URL;
if (requestURL) {
[[NSWorkspace sharedWorkspace] openURL:requestURL];
}
[listener ignore];
}
+8 -4
View File
@@ -63,12 +63,16 @@
// If this is a background application we need to focus it in order to bring the prompt
// to the user's attention. Otherwise the prompt would be hidden behind other applications and
// the user would not know why the application was paused.
if ([aHost isBackgroundApplication]) { [[NSApplication sharedApplication] activateIgnoringOtherApps:YES]; }
if ([aHost isBackgroundApplication]) {
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];
}
if( ![NSApp modalWindow]) // do not prompt if there is is another modal window on screen
{
if (![NSApp modalWindow]) { // do not prompt if there is is another modal window on screen
SUUpdatePermissionPrompt *prompt = [[[self class] alloc] initWithHost:aHost systemProfile:profile delegate:d];
[NSApp runModalForWindow:[prompt window]];
NSWindow *window = [prompt window];
if (window) {
[NSApp runModalForWindow:window];
}
}
}
+20
View File
@@ -9,6 +9,7 @@
#ifndef SUUPDATER_H
#define SUUPDATER_H
#import <Foundation/Foundation.h>
#import "SUExport.h"
#import "SUVersionComparisonProtocol.h"
#import "SUVersionDisplayProtocol.h"
@@ -32,6 +33,7 @@ SU_EXPORT @interface SUUpdater : NSObject
- (instancetype)initForBundle:(NSBundle *)bundle;
@property (readonly, strong) NSBundle *hostBundle;
@property (strong, readonly) NSBundle *sparkleBundle;
@property BOOL automaticallyChecksForUpdates;
@@ -208,6 +210,24 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
*/
- (void)updaterDidNotFindUpdate:(SUUpdater *)updater;
/*!
Called immediately before downloading the specified update.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be downloaded.
\param request The mutable URL request that will be used to download the update.
*/
- (void)updater:(SUUpdater *)updater willDownloadUpdate:(SUAppcastItem *)item withRequest:(NSMutableURLRequest *)request;
/*!
Called after the specified update failed to download.
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that failed to download.
\param error The error generated by the failed download.
*/
- (void)updater:(SUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error;
/*!
Called immediately before installing the specified update.
+18 -3
View File
@@ -29,6 +29,8 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
@interface SUUpdater () <SUUpdatePermissionPromptDelegate>
@property (strong) NSTimer *checkTimer;
@property (strong) NSBundle *sparkleBundle;
- (instancetype)initForBundle:(NSBundle *)bundle;
- (void)startUpdateCycle;
- (void)checkForUpdatesWithDriver:(SUUpdateDriver *)updateDriver;
@@ -54,6 +56,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
@synthesize httpHeaders;
@synthesize driver;
@synthesize host;
@synthesize sparkleBundle;
static NSMutableDictionary *sharedUpdaters = nil;
static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObservationContext";
@@ -80,6 +83,12 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
self = [super init];
if (bundle == nil) bundle = [NSBundle mainBundle];
self.sparkleBundle = [NSBundle bundleForClass:[self class]];
if (!self.sparkleBundle) {
SULog(@"Error: SUUpdater can't find Sparkle.framework it belongs to");
return nil;
}
// Register as observer straight away to avoid exceptions on -dealloc when -unregisterAsObserver is called:
if (self) {
[self registerAsObserver];
@@ -104,11 +113,17 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
BOOL hostIsCodeSigned = [SUCodeSigningVerifier hostApplicationIsCodeSigned];
if (!isMainBundle && !hasPublicDSAKey) {
[self notifyWillShowModalAlert];
NSRunAlertPanel(@"Insecure update error!", @"For security reasons, you need to sign your updates with a DSA key. See Sparkle's documentation for more information.", @"OK", nil, nil);
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = @"Insecure update error!";
alert.informativeText = @"For security reasons, you need to sign your updates with a DSA key. See Sparkle's documentation for more information.";
[alert runModal];
[self notifyDidShowModalAlert];
} else if (isMainBundle && !(hasPublicDSAKey || hostIsCodeSigned)) {
[self notifyWillShowModalAlert];
NSRunAlertPanel(@"Insecure update error!", @"For security reasons, you need to code sign your application or sign your updates with a DSA key. See Sparkle's documentation for more information.", @"OK", nil, nil);
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = @"Insecure update error!";
alert.informativeText = @"For security reasons, you need to code sign your application or sign your updates with a DSA key. See Sparkle's documentation for more information.";
[alert runModal];
[self notifyDidShowModalAlert];
}
@@ -459,7 +474,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
return customUserAgentString;
}
NSString *version = [[NSBundle bundleWithIdentifier:SUBundleIdentifier] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
NSString *version = [self.sparkleBundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
NSString *userAgent = [NSString stringWithFormat:@"%@/%@ Sparkle/%@", [self.host name], [self.host displayVersion], version ? version : @"?"];
NSData *cleanedAgent = [userAgent dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
return [[NSString alloc] initWithData:cleanedAgent encoding:NSASCIIStringEncoding];
+1 -9
View File
@@ -9,7 +9,7 @@
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>${SPARKLE_BUNDLE_IDENTIFIER}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
@@ -24,13 +24,5 @@
<string>${CURRENT_PROJECT_VERSION}</string>
<key>NSPrincipalClass</key>
<string></string>
<key>SUAppendVersionNumber</key>
<string>${SPARKLE_APPEND_VERSION_NUMBER}</string>
<key>SUEnableAutomatedDowngrades</key>
<string>${SPARKLE_AUTOMATED_DOWNGRADES}</string>
<key>SUNormalizeInstalledApplicationName</key>
<string>${SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME}</string>
<key>SURelaunchToolName</key>
<string>${SPARKLE_RELAUNCH_TOOL_NAME}</string>
</dict>
</plist>
+2
View File
@@ -9,6 +9,8 @@
#ifndef SPARKLE_H
#define SPARKLE_H
#import <Cocoa/Cocoa.h>
// 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:
+11 -1
View File
@@ -8,10 +8,20 @@
#ifdef __OBJC__
#if !defined(__clang_major__) || __clang_major__ < 7
#define __nonnull
#define __nullable
#endif
#import <Cocoa/Cocoa.h>
#import "SUConstants.h"
#import "SUErrors.h"
#define SULocalizedString(key, comment) NSLocalizedStringFromTableInBundle(key, @"Sparkle", [NSBundle bundleWithIdentifier:SUBundleIdentifier] ? [NSBundle bundleWithIdentifier:SUBundleIdentifier] : [NSBundle mainBundle], comment)
#define SULocalizedString(key, comment) NSLocalizedStringFromTableInBundle(key, @"Sparkle", (NSBundle *__nonnull)([NSBundle bundleWithIdentifier:SUBundleIdentifier] ? [NSBundle bundleWithIdentifier:SUBundleIdentifier] : [NSBundle mainBundle]), comment)
// Work around a warning generated by some versions of Xcode that we still support,
// when using NSParameterAssert
#define SUParameterAssert(condition) \
NSAssert((condition), @"Invalid parameter not satisfying: %@", @(#condition))
#endif
+1 -1
View File
@@ -97,7 +97,7 @@ Gw
<button id="17">
<rect key="frame" x="105" y="58" width="382" height="18"/>
<autoresizingMask key="autoresizingMask"/>
<buttonCell key="cell" type="check" title="Sempre baixar e instalar atualizações automaticamente" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" inset="2" id="43">
<buttonCell key="cell" type="check" title="Transferir e instalar atualizações futuras automaticamente" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" inset="2" id="43">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
+8 -8
View File
@@ -23,8 +23,8 @@
<window identifier="SUUpdateAlert" title="Atualização de Software" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="SUUpdateAlert" animationBehavior="default" id="5" userLabel="Update Alert (release notes)">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
<windowPositionMask key="initialPositionMask" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="998" y="728" width="622" height="370"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1578"/>
<rect key="contentRect" x="871" y="889" width="622" height="370"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/>
<value key="minSize" type="size" width="550" height="150"/>
<value key="maxSize" type="size" width="700" height="600"/>
<view key="contentView" id="6">
@@ -57,7 +57,7 @@
<binding destination="-2" name="value" keyPath="titleText" id="11"/>
</connections>
</textField>
<textField verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="17">
<textField verticalHuggingPriority="1000" horizontalCompressionResistancePriority="1000" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="17">
<rect key="frame" x="106" y="294" width="118" height="14"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" priority="100" constant="100" id="gkn-FW-9aC"/>
@@ -75,7 +75,7 @@
</binding>
</connections>
</textField>
<button horizontalHuggingPriority="150" verticalHuggingPriority="750" horizontalCompressionResistancePriority="997" translatesAutoresizingMaskIntoConstraints="NO" id="22">
<button horizontalHuggingPriority="150" verticalHuggingPriority="750" horizontalCompressionResistancePriority="997" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="22">
<rect key="frame" x="336" y="12" width="108" height="32"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" priority="222" constant="90" id="2Zy-5G-GBj"/>
@@ -92,8 +92,8 @@ Gw
</connections>
</button>
<button verticalHuggingPriority="750" horizontalCompressionResistancePriority="998" translatesAutoresizingMaskIntoConstraints="NO" id="23">
<rect key="frame" x="103" y="12" width="147" height="32"/>
<buttonCell key="cell" type="push" title="Pular Esta Versão" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="172">
<rect key="frame" x="103" y="12" width="161" height="32"/>
<buttonCell key="cell" type="push" title="Ignorar Esta Versão" bezelStyle="rounded" alignment="center" borderStyle="border" inset="2" id="172">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
@@ -101,7 +101,7 @@ Gw
<action selector="skipThisVersion:" target="-2" id="33"/>
</connections>
</button>
<button horizontalHuggingPriority="20" verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" translatesAutoresizingMaskIntoConstraints="NO" id="76">
<button horizontalHuggingPriority="20" verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="76">
<rect key="frame" x="444" y="12" width="164" height="32"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" priority="222" constant="120" id="N94-uf-6oP"/>
@@ -173,7 +173,7 @@ DQ
</textField>
<button translatesAutoresizingMaskIntoConstraints="NO" id="117">
<rect key="frame" x="106" y="49" width="497" height="18"/>
<buttonCell key="cell" type="check" title="Sempre baixar e instalar atualizações automaticamente" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" inset="2" id="175">
<buttonCell key="cell" type="check" title="Transferir e instalar atualizações futuras automaticamente" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" inset="2" id="175">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
+4 -4
View File
@@ -140,13 +140,13 @@ Gw
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<subviews>
<textField verticalHuggingPriority="750" id="46">
<rect key="frame" x="1" y="128" width="358" height="70"/>
<rect key="frame" x="1" y="128" width="355" height="70"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" id="183">
<font key="font" metaFont="smallSystem"/>
<string key="title">Informações anônimas do sistema são utilizadas para nos ajudar a planejar o desenvolvimento futuro do aplicativo. Caso você tenha dúvidas sobre esse procedimento, por favor contate-nos.
<string key="title">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.
A seguinte informação seria enviada:</string>
As seguintes informações seriam enviadas:</string>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
@@ -156,7 +156,7 @@ A seguinte informação seria enviada:</string>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<clipView key="contentView" id="Xyl-4B-4C7">
<rect key="frame" x="1" y="1" width="353" height="113"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<tableView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" multipleSelection="NO" autosaveColumns="NO" typeSelect="NO" rowHeight="14" id="41">
<rect key="frame" x="0.0" y="0.0" width="353" height="113"/>
+10 -10
View File
@@ -1,12 +1,12 @@
"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ foi baixado e está pronto para uso! Gostaria de instalar e reiniciar o %1$@ agora?";
"%1$@ %2$@ has been downloaded and is ready to use! Would you like to install it and relaunch %1$@ now?" = "%1$@ %2$@ foi transferido e está pronto para uso! Deseja instalar e reiniciar o %1$@ agora?";
"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again." = "%1$@ não pode ser atualizado enquanto for executado a partir de um volume somente de leitura, como uma imagem de disco ou CD/DVD. Mova %1$@ para a pasta Aplicativos, reinicie-o e tente novamente.";
"%1$@ can't be updated when it's running from a read-only volume like a disk image or an optical drive. Move %1$@ to your Applications folder, relaunch it from there, and try again." = "%1$@ não pode ser atualizado enquanto for executado a partir de um volume somente de leitura, como uma imagem de disco ou CD/DVD. Mova o %1$@ para a pasta Aplicativos, reinicie-o e tente novamente.";
"%@ %@ is currently the newest version available." = "%1$@ %2$@ é a versão mais recente disponível.";
"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ está disponível--sua versão é %3$@. Gostaria de baixá-lo agora?";
"%@ %@ is now available--you have %@. Would you like to download it now?" = "%1$@ %2$@ está disponível – sua versão é %3$@. Deseja transferi-lo agora?";
"%@ downloaded" = "%@ baixado";
"%@ downloaded" = "%@ transferidos";
"%@ of %@" = "%1$@ de %2$@";
@@ -14,15 +14,15 @@
"A new version of %@ is ready to install!" = "Uma nova versão do %@ está pronta para ser instalada!";
"An error occurred in retrieving update information. Please try again later." = "Ocorreu um erro ao buscar atualizações. Tente novamente mais tarde.";
"An error occurred in retrieving update information. Please try again later." = "Ocorreu um erro ao obter informações da atualização. Tente novamente mais tarde.";
"An error occurred while downloading the update. Please try again later." = "Ocorreu um erro ao baixar a atualização. Tente novamente mais tarde.";
"An error occurred while downloading the update. Please try again later." = "Ocorreu um erro ao transferir a atualização. Tente novamente mais tarde.";
"An error occurred while extracting the archive. Please try again later." = "Ocorreu um erro ao extrair o arquivo. Tente novamente mais tarde.";
"An error occurred while installing the update. Please try again later." = "Ocorreu um erro ao instalar a atualização. Tente novamente mais tarde.";
"An error occurred while parsing the update feed." = "Ocorreu um erro ao analisar a fonte de atualização.";
"An error occurred while parsing the update feed." = "Ocorreu um erro ao analisar o feed de atualização.";
"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@." = "Ocorreu um erro ao reiniciar o %1$@. A nova versão estará disponível da próxima vez que você abrir o %1$@.";
@@ -36,7 +36,7 @@
"Checking for updates..." = "Buscando atualizações…";
/* Take care not to overflow the status window. */
"Downloading update..." = "Baixando atualização…";
"Downloading update..." = "Transferindo atualização…";
/* Take care not to overflow the status window. */
"Extracting update..." = "Extraindo atualização…";
@@ -59,9 +59,9 @@
"Ready to Install" = "Pronto para Instalar";
"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu." = "Gostaria que %1$@ buscasse atualizações automaticamente? Você pode buscar por atualizações manualmente, através do menu %1$@.";
"Should %1$@ automatically check for updates? You can always check for updates manually from the %1$@ menu." = "Deseja que o %1$@ busque atualizações automaticamente? Você pode buscar atualizações manualmente, através do menu %1$@.";
"Update Error!" = "Erro na Atualização!";
"Update Error!" = "Erro de Atualização!";
"Updating %@" = "Atualizando %@";
@@ -0,0 +1,20 @@
-----BEGIN PUBLIC KEY-----
MIIDOzCCAi0GByqGSM44BAEwggIgAoIBAQD2WbLx8Bd1b1vp8FdDpSzkHZ0tlX5x
Hrzm0WWE9IokOmJw/UWk1GQYRJnA8UlufFTJV4dZVL3It4xwqqWWFyN36LWgQUpf
ss9eTn7M7vjk7BVYch7QMs4jGEnSYkebuYfVhUZlg5VViQ+37Rj+ENtBUrkPJxIY
CGAOIJn45uX5oNIPbElFkadU6m7zd1gn8KhRgIepa2k3iBbkFuCbxTPT/aqLI+MW
8kR4jXITTgBkDew6DXLVL9SsJup4LeAEizTGyyTBY5bfMJaO8NaB8+uPrkC3SZV+
r/LIaBcmU3vVfmw43FGzBlJtGflPaL8Ek9lRK1aSzk3Gr7tPdaado9tPAhUAmn4E
HKjL3lXfHzBmDSrrp5G5+IkCggEAFvGRfoL0u3zN4O+8imTxfiSYcFUjBUly4gIl
NXM4AgFmy8WE+diZRh6/3eg+CO0B1io+thmU2sTFAbV7sHVuGaBpPyFtcvrCHGGp
EcqWwmxuhUc1CzeoBvGw4u8mfCBvcUPjFfhllJJFdIgaTrYXFxqgsb6ZKWKsYz9J
jjJkOlRFIlRfowd1RlqodZYYvdvfWnPd32HpI9i/ofhPdlF5W2f51diH/jVJaRCo
TKECwcYG+qkPC5gkIIgzC6/DPRT8pzCLJ0NoWj3TQwL1LffMSmT9hTGAD1iyJjn5
S9ZLLkz/K+QoGS+Rv4gboMAxa0Cla7R8NwtXqMD0kpeZwDAAgQOCAQYAAoIBAQDw
tDiRJy5DsFNRIaKe6NlyW1gyjYIhbeOCDt5fYMdX7tOR64ng28ACU5ESu6jRANMp
NYjE9oTBx28C0TXXRLDiblHe6IsisKsJJgkNkNc2DwUdPcGoPTRK/MS0k0CQsPQq
cU0Uh/vYXNQ3rsJMAJ0xJ+yYllm3MVQkbZrWlJTe/nU6M8ahiR6WBelrKhzHrhuy
MZ8n+oXvBc/Jo8Z63O/5e94BS0PiGb1Eo84ds6ramno7XJpTXE/nxphBSsaXCwdy
T97rvDzfDG0v0eo9fdX9aL7jPVODDt0bk+MSRdDpcMlgJzhIpNUtafrTUHIkPyKb
/BX9wwwXLfWGTz5TRovi
-----END PUBLIC KEY-----
+14 -1
View File
@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.sparkle-project.SparkleTestApp</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
@@ -28,5 +28,18 @@
<string>http://sparkle-project.org/files/sparkletestcast.xml</string>
<key>SUPublicDSAKeyFile</key>
<string>test_app_only_dsa_pub.pem</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>sparkle-project.org</key>
<dict>
<key>NSIncludesSubdomains</key>
<false/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
</dict>
</plist>
+2 -2
View File
@@ -8,7 +8,7 @@
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
int main(int argc, const char *argv[])
{
return NSApplicationMain(argc, (const char **)argv);
return NSApplicationMain(argc, argv);
}
+39
View File
@@ -12,6 +12,7 @@
#import "SUBinaryDeltaCreate.h"
#import "SUBinaryDeltaApply.h"
#import <sys/stat.h>
#include <sys/xattr.h>
@interface SUBinaryDeltaTest : XCTestCase
@@ -930,4 +931,42 @@ typedef void (^SUDeltaHandler)(NSFileManager *fileManager, NSString *sourceDirec
}];
}
- (void)testInvalidCodeSignatureExtendedAttributeInBeforeTree
{
BOOL success = [self createAndApplyPatchWithBeforeDiffHandler:^(NSFileManager *__unused fileManager, NSString *sourceDirectory, NSString *destinationDirectory) {
NSString *sourceFile = [sourceDirectory stringByAppendingPathComponent:@"A"];
NSString *destinationFile = [destinationDirectory stringByAppendingPathComponent:@"A"];
XCTAssertTrue([[NSData data] writeToFile:sourceFile atomically:YES]);
XCTAssertTrue([[NSData dataWithBytes:"loltest" length:7] writeToFile:destinationFile atomically:YES]);
// the actual data doesn't matter for testing purposes
const char xattrValue[] = "hello";
XCTAssertEqual(0, setxattr([sourceFile fileSystemRepresentation], APPLE_CODE_SIGN_XATTR_CODE_DIRECTORY_KEY, xattrValue, sizeof(xattrValue), 0, XATTR_CREATE));
XCTAssertEqual(0, setxattr([sourceFile fileSystemRepresentation], APPLE_CODE_SIGN_XATTR_CODE_REQUIREMENTS_KEY, xattrValue, sizeof(xattrValue), 0, XATTR_CREATE));
XCTAssertEqual(0, setxattr([sourceFile fileSystemRepresentation], APPLE_CODE_SIGN_XATTR_CODE_SIGNATURE_KEY, xattrValue, sizeof(xattrValue), 0, XATTR_CREATE));
} afterDiffHandler:nil];
XCTAssertFalse(success);
}
- (void)testInvalidCodeSignatureExtendedAttributeInAfterTree
{
BOOL success = [self createAndApplyPatchWithBeforeDiffHandler:^(NSFileManager *__unused fileManager, NSString *sourceDirectory, NSString *destinationDirectory) {
NSString *sourceFile = [sourceDirectory stringByAppendingPathComponent:@"A"];
NSString *destinationFile = [destinationDirectory stringByAppendingPathComponent:@"A"];
XCTAssertTrue([[NSData data] writeToFile:sourceFile atomically:YES]);
XCTAssertTrue([[NSData dataWithBytes:"loltest" length:7] writeToFile:destinationFile atomically:YES]);
// the actual data doesn't matter for testing purposes
const char xattrValue[] = "hello";
XCTAssertEqual(0, setxattr([destinationFile fileSystemRepresentation], APPLE_CODE_SIGN_XATTR_CODE_DIRECTORY_KEY, xattrValue, sizeof(xattrValue), 0, XATTR_CREATE));
XCTAssertEqual(0, setxattr([destinationFile fileSystemRepresentation], APPLE_CODE_SIGN_XATTR_CODE_REQUIREMENTS_KEY, xattrValue, sizeof(xattrValue), 0, XATTR_CREATE));
XCTAssertEqual(0, setxattr([destinationFile fileSystemRepresentation], APPLE_CODE_SIGN_XATTR_CODE_SIGNATURE_KEY, xattrValue, sizeof(xattrValue), 0, XATTR_CREATE));
} afterDiffHandler:nil];
XCTAssertFalse(success);
}
@end
+2 -1
View File
@@ -30,8 +30,9 @@
[super setUp];
NSBundle *unitTestBundle = [NSBundle bundleForClass:[self class]];
NSString *unitTestBundleIdentifier = unitTestBundle.bundleIdentifier;
NSString *zippedAppPath = [unitTestBundle pathForResource:@"SparkleTestCodeSignApp" ofType:@"zip"];
NSString *tempDir = [NSTemporaryDirectory() stringByAppendingPathComponent:[unitTestBundle bundleIdentifier]];
NSString *tempDir = [NSTemporaryDirectory() stringByAppendingPathComponent:unitTestBundleIdentifier];
NSError *error = nil;
if ([[NSFileManager defaultManager] createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:&error]) {
if ([self unzip:zippedAppPath toPath:tempDir]) {
+2
View File
@@ -30,6 +30,7 @@
[super tearDown];
}
#if __clang_major__ >= 6
- (void)testInstallIfRoot
{
uid_t uid = getuid();
@@ -61,5 +62,6 @@
[self waitForExpectationsWithTimeout:40 handler:nil];
[fm removeItemAtPath:expectedDestination error:nil];
}
#endif
@end
+30 -18
View File
@@ -11,41 +11,52 @@
#import "SUUnarchiver.h"
#import "SUPipedUnarchiver.h"
@interface SUPipedUnarchiverTest : XCTestCase<SUUnarchiverDelegate>
#if __clang_major__ >= 6
@interface SUPipedUnarchiverTest : XCTestCase <SUUnarchiverDelegate>
@property (nonatomic, strong) XCTestExpectation *unarchived;
@property (nonatomic, assign) BOOL result;
@end
@implementation SUPipedUnarchiverTest {
XCTestExpectation *unarchived;
BOOL result;
}
@implementation SUPipedUnarchiverTest
- (void)setUp {
@synthesize unarchived;
@synthesize result;
- (void)setUp
{
[super setUp];
unarchived = [self expectationWithDescription:@"unarchived"];
self.unarchived = [self expectationWithDescription:@"unarchived"];
}
- (void)tearDown {
- (void)tearDown
{
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}
- (void) unarchiver:(SUUnarchiver *)unarchiver extractedProgress:(double)_unused {
- (void)unarchiver:(SUUnarchiver *)__unused unarchiver extractedProgress:(double)__unused progress
{
}
- (void) unarchiverDidFail:(SUUnarchiver *)_unused {
result = NO;
[unarchived fulfill];
- (void)unarchiverDidFail:(SUUnarchiver *)__unused unarchiver
{
self.result = NO;
[self.unarchived fulfill];
}
- (void) unarchiverDidFinish:(SUUnarchiver *)_unused {
result = YES;
[unarchived fulfill];
- (void)unarchiverDidFinish:(SUUnarchiver *)__unused unarchiver
{
self.result = YES;
[self.unarchived fulfill];
}
- (void)testBlah {
- (void)testZipExtract
{
NSString *originalArchivePath = [[NSBundle bundleForClass:[self class]] pathForResource:@"test archive" ofType:@"zip"];
NSString *tempDestDir = NSTemporaryDirectory();
NSString *tempArchivePath = [[tempDestDir stringByAppendingPathComponent:[NSUUID UUID].UUIDString] stringByAppendingPathExtension:@"zip"];
NSString *tempArchivePath = [[tempDestDir stringByAppendingPathComponent:[[NSUUID UUID] UUIDString]] stringByAppendingPathExtension:@"zip"];
NSFileManager *fm = [NSFileManager defaultManager];
NSString *testFile = [tempDestDir stringByAppendingPathComponent:@"extracted file.txt"];
@@ -63,8 +74,9 @@
[self waitForExpectationsWithTimeout:5.0 handler:nil];
XCTAssertTrue(result);
XCTAssertTrue(self.result);
XCTAssertTrue([fm fileExistsAtPath:testFile isDirectory:nil]);
}
@end
#endif
+31 -27
View File
@@ -16,45 +16,49 @@
@implementation SUVersionComparisonTestCase
#define SUAssertOrder(a,b,c) XCTAssertTrue([[SUStandardVersionComparator defaultComparator] compareVersion:a toVersion:b] == c, @"b should be newer than a!")
#define SUAssertAscending(a, b) SUAssertOrder(a,b,NSOrderedAscending)
#define SUAssertDescending(a, b) SUAssertOrder(a,b,NSOrderedDescending)
#define SUAssertEqual(a, b) SUAssertOrder(a,b,NSOrderedSame)
#define SUAssertOrder(a, b, c) XCTAssertTrue([[SUStandardVersionComparator defaultComparator] compareVersion:a toVersion:b] == c, @"b should be newer than a!")
#define SUAssertAscending(a, b) SUAssertOrder(a, b, NSOrderedAscending)
#define SUAssertDescending(a, b) SUAssertOrder(a, b, NSOrderedDescending)
#define SUAssertEqual(a, b) SUAssertOrder(a, b, NSOrderedSame)
- (void)testNumbers
{
SUAssertAscending(@"1.0", @"1.1");
SUAssertEqual(@"1.0", @"1.0");
SUAssertDescending(@"2.0", @"1.1");
SUAssertDescending(@"0.1", @"0.0.1");
//SUAssertDescending(@".1", @"0.0.1"); Known bug, but I'm not sure I care.
SUAssertAscending(@"0.1", @"0.1.2");
SUAssertAscending(@"1.0", @"1.1");
SUAssertEqual(@"1.0", @"1.0");
SUAssertDescending(@"2.0", @"1.1");
SUAssertDescending(@"0.1", @"0.0.1");
//SUAssertDescending(@".1", @"0.0.1"); Known bug, but I'm not sure I care.
SUAssertAscending(@"0.1", @"0.1.2");
}
- (void)testPrereleases
{
SUAssertAscending(@"1.0a1", @"1.0b1");
SUAssertAscending(@"1.0b1", @"1.0");
SUAssertAscending(@"0.9", @"1.0a1");
SUAssertAscending(@"1.0b", @"1.0b2");
SUAssertAscending(@"1.0b10", @"1.0b11");
SUAssertAscending(@"1.0b9", @"1.0b10");
SUAssertAscending(@"1.0rc", @"1.0");
SUAssertAscending(@"1.0b", @"1.0");
SUAssertAscending(@"1.0pre1", @"1.0");
SUAssertAscending(@"1.5.5", @"1.5.6a1");
SUAssertAscending(@"1.1.0b1", @"1.1.0b2");
SUAssertAscending(@"1.1.1b2", @"1.1.2b1");
SUAssertAscending(@"1.1.1b2", @"1.1.2a1");
SUAssertAscending(@"1.0a1", @"1.0b1");
SUAssertAscending(@"1.0b1", @"1.0");
SUAssertAscending(@"0.9", @"1.0a1");
SUAssertAscending(@"1.0b", @"1.0b2");
SUAssertAscending(@"1.0b10", @"1.0b11");
SUAssertAscending(@"1.0b9", @"1.0b10");
SUAssertAscending(@"1.0rc", @"1.0");
SUAssertAscending(@"1.0b", @"1.0");
SUAssertAscending(@"1.0pre1", @"1.0");
}
- (void)testVersionsWithBuildNumbers
{
SUAssertAscending(@"1.0 (1234)", @"1.0 (1235)");
SUAssertAscending(@"1.0b1 (1234)", @"1.0 (1234)");
SUAssertAscending(@"1.0b5 (1234)", @"1.0b5 (1235)");
SUAssertAscending(@"1.0b5 (1234)", @"1.0.1b5 (1234)");
SUAssertAscending(@"1.0.1b5 (1234)", @"1.0.1b6 (1234)");
SUAssertAscending(@"2.0.0.2429", @"2.0.0.2430");
SUAssertAscending(@"1.1.1.1818", @"2.0.0.2430");
SUAssertAscending(@"1.0 (1234)", @"1.0 (1235)");
SUAssertAscending(@"1.0b1 (1234)", @"1.0 (1234)");
SUAssertAscending(@"1.0b5 (1234)", @"1.0b5 (1235)");
SUAssertAscending(@"1.0b5 (1234)", @"1.0.1b5 (1234)");
SUAssertAscending(@"1.0.1b5 (1234)", @"1.0.1b6 (1234)");
SUAssertAscending(@"2.0.0.2429", @"2.0.0.2430");
SUAssertAscending(@"1.1.1.1818", @"2.0.0.2430");
SUAssertAscending(@"3.3 (5847)", @"3.3.1b1 (5902)");
SUAssertAscending(@"3.3 (5847)", @"3.3.1b1 (5902)");
}
- (void)testWordsWithSpaceInFront
+1 -1
View File
@@ -7,7 +7,7 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIdentifier</key>
<string>org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
+1 -1
View File
@@ -123,7 +123,7 @@ static off_t offtin(u_char *buf)
return y;
}
int bspatch(int argc,char * argv[])
int bspatch(int argc,const char * const argv[])
{
FILE * f, * cpf, * dpf, * epf;
stream_t cstream, dstream, estream;
+1 -1
View File
@@ -9,4 +9,4 @@
// So that we can use this method in SUBinaryDeltaApply.m.
// Silences the GCC warning that the prototype doesn't exist.
int bspatch(int argc, char * argv[]);
int bspatch(int argc, const char * const argv[]);
+1 -1
View File
@@ -40,7 +40,7 @@
#define SAIS_MYMALLOC(_num, _type) ((_type *)malloc((_num) * sizeof(_type)))
#define SAIS_MYFREE(_ptr, _num, _type) free((_ptr))
#define chr(_a) (cs == sizeof(sais_index_type) ? ((sais_index_type *)T)[(_a)] : ((unsigned char *)T)[(_a)])
#define chr(_a) (cs == sizeof(sais_index_type) ? ((const sais_index_type *)T)[(_a)] : ((const unsigned char *)T)[(_a)])
/* find the start or end of each bucket */
static
+3 -3
View File
@@ -24,8 +24,8 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _SAIS_H
#define _SAIS_H 1
#ifndef SAIS_H
#define SAIS_H 1
#ifdef __cplusplus
extern "C" {
@@ -56,4 +56,4 @@ sais_int_bwt(const sais_index_type *T, sais_index_type *U, sais_index_type *A, i
} /* extern "C" */
#endif /* __cplusplus */
#endif /* _SAIS_H */
#endif /* SAIS_H */