Compare commits

...
64 Commits
Author SHA1 Message Date
Kornel Lesiński 20be93e96b Version bump 2016-08-27 16:13:05 +01:00
Kornel Lesiński 668e258cff Updated CHANGELOG 2016-08-27 16:12:02 +01:00
Kornel 20f90f1544 Merge pull request #873 from zorgiepoo/dsa-existence
Dsa existence
2016-08-27 16:05:26 +01:00
Kornel 6dbb0d9988 Merge pull request #874 from zorgiepoo/dmg-remove-vendor
Remove NTSynchronousTask
2016-08-27 16:04:58 +01:00
Zorg f700c96e47 Read stdout to end before waiting for task to end to prevent deadlock 2016-08-27 09:27:06 -04:00
Zorg 626d2c96f5 Show the public DSA file key that doesn't exist in the insecure alert 2016-08-27 09:11:08 -04:00
Kornel 5db4e1505b Merge pull request #872 from zorgiepoo/menuvalidation
Menu item validation
2016-08-27 10:42:25 +01:00
Zorg 115686cd07 Change dmg and test verifying code by removing NTSynchronousTask 2016-08-27 01:09:24 -04:00
Zorg e2fc8b4258 Prevent public DSA key -> no public DSA key downgrade
This may prevent developers from making accidental downgrades.
2016-08-27 00:32:01 -04:00
Zorg 99f34299f1 Show alert if no pub key exists, but SUPublicDSAKeyFileKey exists 2016-08-27 00:07:11 -04:00
Zorg fdf79bc3a6 Enable check for updates menu item if update driver is interruptible 2016-08-26 23:07:13 -04:00
Zorg eb810c7d8f Implement menu item validation in Test Applications window controller 2016-08-26 23:03:08 -04:00
Zorg 38af7cd8cd Export -validateMenuItem: as a method in SUUpdater.h for public use 2016-08-26 23:01:30 -04:00
Kornel 5f2ebb8edf Merge pull request #862 from moubry/master
Remove <link> from SampleAppCast.xml
2016-08-10 23:37:09 +01:00
Sean Moubry ac4ef7d9a0 Remove <link> from SampleAppCast.xml
Sparkle doesn’t use the channel’s link element. This resolves issue:
https://github.com/sparkle-project/Sparkle/issues/861.
2016-08-10 17:11:48 -05:00
Kornel cc7c0ae052 Merge pull request #858 from catnapgames/patch-1
Make sign_update work when Bash is not the default
2016-08-09 16:34:51 +01:00
Tomas Andrle b8dc5b3f3d Make sign_update work when Bash is not the default
This script fails when Bash is not the default shell. This fixes it and allows the script to run on a default Ubuntu system, for example.
2016-08-09 14:52:26 +02:00
Kornel 43e96f7ee8 Merge pull request #847 from sparkle-project/relaunch
Better error message when relaunch tool bundle is not found.
2016-08-01 19:15:18 +01:00
Kornel dbff23ea9d Merge pull request #851 from sorccu/patch-1
Add Carthage/Build to .gitignore
2016-07-22 13:02:36 +01:00
Simo Kinnunen ed97e6cb75 Add Carthage/Build to .gitignore
With Carthage, if Sparkle is included as a Git submodule (e.g. with the --use-submodules option), the main module's .gitignore can't reach all the way inside the submodule to ignore the added Carthage/Build symlink, and Git keeps complaining about untracked changes in the submodule forever, which is very annoying. To avoid that issue, ignore here in Sparkle instead.
2016-07-22 18:26:15 +09:00
Kornel Lesiński 492664c611 Clarify comment 2016-07-21 20:01:22 +01:00
Kornel Lesiński fdf07644d0 Better error message when relaunch tool bundle is not found. 2016-07-19 16:06:03 +01:00
Kornel 092feba9f9 Merge pull request #836 from zorgiepoo/remove-reachability
Don't use reachability as a preflight check
2016-07-08 10:27:13 +01:00
Zorg 91c813b6ab Don't use reachability as a preflight check
This removes the reachability code that we have for background scheduled updates.
Apple (and others) don't recommend using reachability to test if a network connection is online.

See:
http://stackoverflow.com/questions/7178330/what-is-the-advantage-of-using-reachability
https://www.mikeash.com/pyblog/friday-qa-2013-06-14-reachability.html (just the comments)
Apple 2012/2011 WWDC videos on networking

Also, our current reachability code is rather illogical:

* reachabilityResult is always NO
* isNetworkReachable is always YES
* flags is ignored
* horrible use of dispatch_sync & putFeedURLIntoDictionary is terrifying
* NSException handling shouldn't be done

Removing this code which wasn't even coded properly, and which would still be misusing the reachability API anyway, also leads to removing some multithreading races and simpler logic :)
2016-07-06 22:38:49 -04:00
Kornel 1ced9c428a Merge pull request #834 from zorgiepoo/dsa-key-comment
DSA security check comment
2016-07-05 14:44:11 +01:00
Zorg 16de00d81d If the old & new DSA keys are the same, then DSA validation must pass for security 2016-07-04 23:43:05 -04:00
Jake Petroules 3f637c9674 Sanity check that the Podspec version matches the Sparkle version. 2016-06-26 15:03:48 -07:00
Kornel 4a4dc3629f Merge pull request #828 from zorgiepoo/fileop-compile-error
Fix SUFileOperationConstants not found in Test App under Release
2016-06-25 11:45:10 +01:00
Zorg c77cd49036 Fix SUFileOperationConstants not found in Test App under Release 2016-06-24 19:55:40 -04:00
Kornel 9d7e4d676d Merge pull request #823 from nivekkagicom/master
update Sparkle framework headers to use modules if modules are available
2016-06-23 17:41:44 +01:00
Kornel 1aa0ee8152 Merge pull request #825 from jerrykrinock/xcode8
Changes for Xcode 8
2016-06-23 17:38:47 +01:00
Kornel Lesiński 9944f2496c Comment 2016-06-23 17:24:16 +01:00
Jerry Krinock 33907ec4ed • In SUUpdater.m, use SULocalizedString macro instead of NSLocalizedString.
• In SUOperatingSystem.m, assert instead of test for nil URL.
2016-06-17 22:24:43 -07:00
Jerry Krinock 7892e41b27 Fix for warning in in SUAppcast.m now tests for nil instead of using setValue:forKey: 2016-06-17 20:23:32 -07:00
Jerry Krinock 53983d9452 The following changes were made to clear warnings from static analyzer in Xcode 8:
• In ConfigCommon.xcconfig, removed references to CLANG_WARN_OBJC_RECEIVER_WEAK and -Wno-receiver-is-weak, because apparently these had been deprecated and are now no longer recognized.
• In SUAppcast.m, changed to method which can accept nil.
• In SUOperatingSystem.h, added a check for nil which probably never happens.
• In SUUpdateAlert.m, swapped receiver with parameter in -isEqualToString, 3 places, so that nonnull parameter could never be nil.
• In SUUpdater.m, added NSLocalizedString() wrappers around 8 recently-added (in the last few years, I think) user-facing warning strings.
2016-06-17 14:42:44 -07:00
B. Kevin Hardman f3a151d473 update Sparkle framework headers to use modules if modules are available 2016-06-16 12:16:31 -04:00
Jake Petroules bb624ffa59 Replace OS X with macOS or more generic terminology. 2016-06-15 13:46:19 -07:00
Jake Petroules 2963f788e1 Fix version number in Doxyfile. 2016-06-15 13:43:40 -07:00
Kornel 9017962ab9 Merge pull request #818 from zorgiepoo/auth-wait-fileop
Improve Authorization Usage (Take 2)
2016-06-11 00:24:22 +01:00
Zorg dd0805c05b No need to log the underlying error
This is already logged when logging the main error
2016-06-10 16:13:18 -04:00
Zorg e4c3c29a85 Fix SUFileOperationConstants link errors in BinaryDelta 2016-06-09 07:59:46 -04:00
Zorg be1e86174a Wait for the appropriate process when authorizing file operations
This changes the way we authorize & execute commands, and how we wait for their completion. In order to obtain the correct child to wait (instead of another one terminating intermediately), we use a wrapper tool (fileop) to output its pid onto the communication pipe that we read from the other end.
2016-06-08 21:49:58 -04:00
Kornel 8b56fba39b Merge pull request #814 from DivineDominion/master
add Carthage & CocoaPods compatibility indicators to README
2016-05-26 11:06:42 +01:00
Christian Tietze db232a263b add CocoaPods indicator 2016-05-26 10:44:15 +02:00
Christian Tietze 4d952e9961 add Carthage indicator 2016-05-26 10:43:29 +02:00
Kornel Lesiński 64fd27d918 Fix 10.7 compat in new code 2016-05-22 23:09:23 +01:00
Kornel Lesiński 666e86b0bb Merge remote-tracking branch 'origin/master' into nsparse
* origin/master: (31 commits)
  Fix indentation with bspatch.c
  Fix warnings for bsdiff.c
  Improve error handling on readfile()
  Don't forget to free the buffer on failure
  Don't exit the program on failure for bsdiff.c
  Don't exit the program on failure for bspatch.c
  Use FILE* functions in bspatch.c
  Use FILE* (fopen/fread/etc) functions for bsdiff.c
  Fix warnings for bspatch
  Don't hide warnings for bsdiff/bspatch
  Reorganize checks for clarity
  Update changelog
  Update screenshot with new logo.
  Remove Sparkle.png. This does not appear to be used anywhere anymore.
  Set correct DPI for all images (72 for @1x, 144 for @2x).
  Assign newly added icon images in asset catalog (#801) (#804)
  Update app icon for Autoupdate.app (#347)
  Updated sponsored by text and links (#800)
  Upgrade warning to alert for signing update over HTTP with no DSA key
  Clear update caches directory before downloading new update
  ...
2016-05-22 23:09:08 +01:00
Kornel 601b4a7a7f Merge pull request #811 from zorgiepoo/bsdiff-fixes
bsdiff fixes
2016-05-22 22:31:12 +01:00
Zorg 1316707136 Fix indentation with bspatch.c 2016-05-16 22:30:48 -04:00
Zorg e485baf8b8 Fix warnings for bsdiff.c 2016-05-16 22:20:35 -04:00
Zorg d71fe4a17d Improve error handling on readfile() 2016-05-16 22:05:53 -04:00
Zorg f990f5fcfc Don't forget to free the buffer on failure 2016-05-16 22:05:43 -04:00
Zorg 07ac154e2e Don't exit the program on failure for bsdiff.c 2016-05-16 22:05:29 -04:00
Zorg 48eb25fbf3 Don't exit the program on failure for bspatch.c
We call warn type functions instead of err ones now and do some cleanup
2016-05-16 22:05:19 -04:00
Zorg 914bf9e333 Use FILE* functions in bspatch.c 2016-05-16 22:04:44 -04:00
Zorg 271b7a1daf Use FILE* (fopen/fread/etc) functions for bsdiff.c
This way we don't have to handle EINTR
2016-05-16 22:01:41 -04:00
Zorg c11c660f22 Fix warnings for bspatch 2016-05-16 21:58:32 -04:00
Zorg 0e2fe68399 Don't hide warnings for bsdiff/bspatch 2016-05-16 21:57:19 -04:00
Kornel 852965d824 Merge pull request #807 from sparkle-project/seccheck
Simpler conditions for security config check
2016-05-12 23:19:08 +01:00
Kornel Lesiński e2c60be805 Reorganize checks for clarity 2016-05-12 15:19:57 +01:00
Kornel Lesiński 71e15f4b1d Update changelog 2016-05-10 13:32:27 +01:00
Kornel Lesiński 8cca51d08b Merge remote-tracking branch 'origin/master' into nsparse 2016-03-14 12:32:15 +00:00
Kornel Lesiński c9fa1142c9 Formatting/comments 2016-03-14 12:22:35 +00:00
Kornel Lesiński 48f18d000c Support XML namespace prefixes when parsing appcasts
Fixes #771
2016-03-01 00:37:52 +00:00
57 changed files with 1429 additions and 881 deletions

No files matched your search

+7
View File
@@ -28,6 +28,13 @@ Icon
.Spotlight-V100
.Trashes
# With Carthage, if Sparkle is included as a Git submodule (e.g. with the
# --use-submodules option), the main module's .gitignore can't reach all the
# way inside the submodule to ignore the added Carthage/Build symlink, and Git
# keeps complaining about untracked changes in the submodule forever, which
# is very annoying. To avoid that issue, ignore here in Sparkle instead.
Carthage/Build
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
+30 -4
View File
@@ -1,3 +1,29 @@
# 1.15.0
* A new icon! Thanks to 1024jp
* Show alert when an update is sent over insecure HTTP with no DSA key (Zorg)
- If you can't use HTTPS, you must at least sign updates with a DSA key.
* Improved binary delta implementation (Zorg)
* Added improved -validateMenuItem: as a method in SUUpdater.h for public use (Zorg)
* Removed reachability preflight check (Zorg)
* Clear update caches directory before downloading new update (Zorg)
* Check the bundle's parent directory for writability too (Zorg)
* Don't follow symbolic links for file operations (Zorg)
* Don't bring up an authorized dialog during cleanup (Zorg)
* Made Sparkle look for the highest compatible version regardless of timestamps (Zorg)
* Fixed compatibility with 10.7
* Fixed crash on 10.7 - subscript operator not available (kleuter)
* Fixed warnings caused by -Wpartial-availability (Zorg)
* Fixed german l10n. (Sebastian Volland)
* Error code for download errors (Kornel Lesiński)
* Update last update check date when the update driver finishes (Zorg)
* Scale app icon up if needed in Software Update window (Nicholas Riley)
* Don't register for termination notifications more than once (Zorg)
* Don't terminate the app if we're already terminating (Zorg)
* Removed SUEnableAutomaticChecksKeyOld and SUCheckAtStartup constants (Eitot)
* Updated Sparkle framework headers to use modules if modules are available (B. Kevin Hardman)
* Fixed warnings, fixed uses of SULocalizedString (Jerry Krinock)
# 1.14.0 (Mar 11, 2016)
* Disable javascript by default and make it opt-in (Zorg)
@@ -35,7 +61,7 @@ Important security fixes:
- Strong documentation, easier to read code.
* Automatic updates won't be installed if the system is about to shut off (Zorg)
* Deprecated serving over HTTP without DSA (Zorg)
- Note that Apple has deprecated insecure HTTP in OS X 10.11
- Note that Apple has deprecated insecure HTTP in macOS 10.11
* Improved Autoupdate application (Zorg)
* Do all the installation work after the runloop is set up
* TerminationListener only does termination listening now
@@ -133,12 +159,12 @@ Important security fixes:
# 1.8.0 (Jul 26, 2014)
* New SUDSAVerifier based on up-to-date OS X APIs (Zachary Waldowski)
* New SUDSAVerifier based on up-to-date macOS APIs (Zachary Waldowski)
* Detailed error log for failed signature checks (Kornel Lesiński)
* Converted Sparkle to ARC (C.W. Betts)
* Converted ivars to properties. (Jake Petroules)
* Cocoapod support (Xhacker Liu)
* Quarantine removal on OS X 10.10 (C.W. Betts)
* Quarantine removal on macOS 10.10 (C.W. Betts)
* Updated Japanese localization (1024jp)
* Added Greek localization
@@ -159,7 +185,7 @@ Important security fixes:
# 1.7.0
* Dropped support for OS X 10.6. Sparkle now supports 10.7 and newer (including 10.10 Yosemite) on 64-bit Intel Macs (the last 32-bit Mac was released in 2006).
* Dropped support for macOS 10.6. Sparkle now supports 10.7 and newer (including 10.10 Yosemite) on 64-bit Intel Macs (the last 32-bit Mac was released in 2006).
* Removed use of deprecated functions (Zachary Waldowski)
* Switched to modern Obj-C runtime and new literals syntax
* Removed pre-10.7 code. (C.W. Betts)
+4 -4
View File
@@ -2,6 +2,7 @@
SPARKLE_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle
SPARKLE_RELAUNCH_TOOL_NAME = Autoupdate
SPARKLE_FILEOP_TOOL_NAME = fileop
SPARKLE_APPEND_VERSION_NUMBER = 1
@@ -15,7 +16,7 @@ SPARKLE_AUTOMATED_DOWNGRADES = 0
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0
SPARKLE_VERSION_MAJOR = 1
SPARKLE_VERSION_MINOR = 14
SPARKLE_VERSION_MINOR = 15
SPARKLE_VERSION_PATCH = 0
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)
@@ -31,7 +32,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.7
PRODUCT_NAME = ${TARGET_NAME}
PRODUCT_BUNDLE_IDENTIFIER = org.sparkle-project.Sparkle.${PRODUCT_NAME:rfc1034identifier}
GCC_PREPROCESSOR_DEFINITIONS_COMMON = 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_COMMON = 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)\" SPARKLE_FILEOP_TOOL_NAME=\"$(SPARKLE_FILEOP_TOOL_NAME)\"
CLANG_ENABLE_OBJC_ARC = YES
GCC_ENABLE_PASCAL_STRINGS = NO
@@ -51,7 +52,6 @@ CLANG_WARN_OBJC_EXPLICIT_OWNERSHIP_TYPE = YES
CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES
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
@@ -87,4 +87,4 @@ CLANG_ENABLE_MODULES[sdk=macosx10.8] = NO
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-unused-macros -Wno-gnu-statement-expression -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wno-auto-import $(WARNING_CFLAGS_EXTRA)
WARNING_CFLAGS = -Wall -Weverything -Wno-unused-macros -Wno-gnu-statement-expression -Wno-arc-repeated-use-of-weak -Wno-auto-import $(WARNING_CFLAGS_EXTRA)
+5
View File
@@ -0,0 +1,5 @@
// Fileop tool only
PRODUCT_NAME = $(SPARKLE_FILEOP_TOOL_NAME)
SKIP_INSTALL = YES
CLANG_ENABLE_MODULES = NO
+7
View File
@@ -2,6 +2,13 @@
set -e
if [ "$ACTION" = "" ] ; then
# Sanity check that the Podspec version matches the Sparkle version
spec_version=$(printf "require 'cocoapods'\nspec = %s\nprint spec.version" "$(cat "$SRCROOT/Sparkle.podspec")" | LANG=en_US.UTF-8 ruby)
if [ "$spec_version" != "$CURRENT_PROJECT_VERSION" ] ; then
echo "podspec version '$spec_version' does not match the current project version '$CURRENT_PROJECT_VERSION'" >&2
exit 1
fi
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2"
+2 -2
View File
@@ -1,6 +1,6 @@
PROJECT_NAME = Sparkle
PROJECT_NUMBER = 1.7.1
PROJECT_BRIEF = "A software update framework for OS X"
PROJECT_NUMBER = 1.14.0
PROJECT_BRIEF = "A software update framework for macOS"
PROJECT_LOGO = Resources/Images.xcassets/AppIcon.appiconset/icon_32x32@2x.png
RECURSIVE = YES
+3 -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) [![Coverage Status](https://coveralls.io/repos/sparkle-project/Sparkle/badge.svg?branch=master&service=github)](https://coveralls.io/github/sparkle-project/Sparkle?branch=master) <a href="https://www.maxcdn.com/?utm_source=sparkle-github&amp;utm_medium=badge&amp;utm_campaign=readme"><img src="https://img.shields.io/badge/sponsored%20by-MaxCDN-orange.svg" alt="sponsored by: MaxCDN"></a>
# Sparkle [![Build Status](https://travis-ci.org/sparkle-project/Sparkle.svg?branch=master)](https://travis-ci.org/sparkle-project/Sparkle) [![Coverage Status](https://coveralls.io/repos/sparkle-project/Sparkle/badge.svg?branch=master&service=github)](https://coveralls.io/github/sparkle-project/Sparkle?branch=master) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![CocoaPods](https://img.shields.io/cocoapods/v/Sparkle.svg?maxAge=2592000)]() <a href="https://www.maxcdn.com/?utm_source=sparkle-github&amp;utm_medium=badge&amp;utm_campaign=readme"><img src="https://img.shields.io/badge/sponsored%20by-MaxCDN-orange.svg" alt="sponsored by: MaxCDN"></a>
An easy-to-use software update framework for Cocoa developers.
@@ -6,7 +6,7 @@ An easy-to-use software update framework for Cocoa developers.
## Changes since 1.5b
* Up-to-date with 10.11 SDK and Xcode 7. Supports OS X 10.7+.
* Up-to-date with 10.11 SDK and Xcode 7. Supports macOS 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."
@@ -33,7 +33,7 @@ An easy-to-use software update framework for Cocoa developers.
## Requirements
* Runtime: OS X 10.7 or greater
* Runtime: macOS 10.7 or greater
* Build: Xcode 5 and 10.8 SDK or greater
* HTTPS server for serving updates (see [App Transport Security](http://sparkle-project.org/documentation/app-transport-security/))
-1
View File
@@ -2,7 +2,6 @@
<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Your Great App's Changelog</title>
<link>http://you.com/app/appcast.xml</link>
<description>Most recent changes with links to updates.</description>
<language>en</language>
<item>
+1 -1
View File
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "Sparkle"
s.version = "1.14.0"
s.summary = "A software update framework for OS X"
s.summary = "A software update framework for macOS"
s.description = "Sparkle is an easy-to-use software update framework for Cocoa developers."
s.homepage = "http://sparkle-project.org"
s.documentation_url = "http://sparkle-project.org/documentation/"
+176 -22
View File
@@ -33,7 +33,7 @@
142E0E0919A83AAC00E4312B /* SUBinaryDeltaTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 142E0E0819A83AAC00E4312B /* SUBinaryDeltaTest.m */; };
14652F7C19A9725300959E44 /* SUBinaryDeltaCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8E20FD68CC7005AE3F6 /* SUBinaryDeltaCommon.m */; };
14652F7D19A9726700959E44 /* SUBinaryDeltaApply.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8E00FD68CC7005AE3F6 /* SUBinaryDeltaApply.m */; };
14652F7E19A9728A00959E44 /* bspatch.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */; settings = {COMPILER_FLAGS = "-w"; }; };
14652F7E19A9728A00959E44 /* bspatch.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */; };
14652F8019A9740F00959E44 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B5F8F609C4CEB300B25A18 /* Security.framework */; };
14652F8219A9746000959E44 /* SULog.m in Sources */ = {isa = PBXBuildFile; fileRef = 55C14F05136EF6DB00649790 /* SULog.m */; };
14652F8419A978C200959E44 /* SUExport.h in Headers */ = {isa = PBXBuildFile; fileRef = 14652F8319A9759F00959E44 /* SUExport.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -81,9 +81,9 @@
5AF6C74F1AEA46D10014A3AB /* test.sparkle_guided.pkg in Resources */ = {isa = PBXBuildFile; fileRef = 5AF6C74E1AEA46D10014A3AB /* test.sparkle_guided.pkg */; };
5AF6C7541AEA49840014A3AB /* SUInstallerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF6C74C1AEA40760014A3AB /* SUInstallerTest.m */; };
5AF9DC3C1981DBEE001EA135 /* SUDSAVerifierTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 5AF9DC3B1981DBEE001EA135 /* SUDSAVerifierTest.m */; };
5D06E8E90FD68CDB005AE3F6 /* bsdiff.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */; settings = {COMPILER_FLAGS = "-w"; }; };
5D06E8E90FD68CDB005AE3F6 /* bsdiff.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */; };
5D06E8EA0FD68CDB005AE3F6 /* SUBinaryDeltaTool.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8E30FD68CC7005AE3F6 /* SUBinaryDeltaTool.m */; };
5D06E8EB0FD68CE4005AE3F6 /* bspatch.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */; settings = {COMPILER_FLAGS = "-w"; }; };
5D06E8EB0FD68CE4005AE3F6 /* bspatch.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */; };
5D06E8EC0FD68CE4005AE3F6 /* SUBinaryDeltaApply.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8E00FD68CC7005AE3F6 /* SUBinaryDeltaApply.m */; };
5D06E8ED0FD68CE4005AE3F6 /* SUBinaryDeltaCommon.m in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8E20FD68CC7005AE3F6 /* SUBinaryDeltaCommon.m */; };
5D06E8FD0FD68D6B005AE3F6 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D06E8FB0FD68D61005AE3F6 /* libbz2.dylib */; };
@@ -96,6 +96,7 @@
5D1AF5900FD767AD0065DB48 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF58F0FD767AD0065DB48 /* libxml2.dylib */; };
5D1AF59A0FD767E50065DB48 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5990FD767E50065DB48 /* libz.dylib */; };
5D1AF82B0FD768180065DB48 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5990FD767E50065DB48 /* libz.dylib */; };
5F1510A21C96E591006E1629 /* testnamespaces.xml in Resources */ = {isa = PBXBuildFile; fileRef = 5F1510A11C96E591006E1629 /* testnamespaces.xml */; };
610134730DD250470049ACDF /* SUUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 610134710DD250470049ACDF /* SUUpdateDriver.h */; settings = {ATTRIBUTES = (); }; };
610134740DD250470049ACDF /* SUUpdateDriver.m in Sources */ = {isa = PBXBuildFile; fileRef = 610134720DD250470049ACDF /* SUUpdateDriver.m */; };
6101347B0DD2541A0049ACDF /* SUProbingUpdateDriver.h in Headers */ = {isa = PBXBuildFile; fileRef = 610134790DD2541A0049ACDF /* SUProbingUpdateDriver.h */; settings = {ATTRIBUTES = (); }; };
@@ -104,7 +105,6 @@
6102FE4A0E07803800F85D09 /* SUDiskImageUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE480E07803800F85D09 /* SUDiskImageUnarchiver.h */; settings = {ATTRIBUTES = (); }; };
6102FE4B0E07803800F85D09 /* SUDiskImageUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */; };
6102FE5B0E08C7EC00F85D09 /* SUUnarchiver_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */; settings = {ATTRIBUTES = (); }; };
610EC1E00CF3A5FE00AE239E /* NTSynchronousTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 610EC1BF0CF3914D00AE239E /* NTSynchronousTask.m */; };
611142E910FB1BE5009810AA /* bspatch.h in Headers */ = {isa = PBXBuildFile; fileRef = 611142E810FB1BE5009810AA /* bspatch.h */; };
61177A1F0D1112E900749C97 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6117796E0D1112E000749C97 /* IOKit.framework */; };
61180BCA0D64138900B4E0D1 /* SUWindowController.h in Headers */ = {isa = PBXBuildFile; fileRef = 61180BC80D64138900B4E0D1 /* SUWindowController.h */; settings = {ATTRIBUTES = (); }; };
@@ -122,7 +122,6 @@
612DCBB00D488BC60015DBEA /* SUUpdatePermissionPrompt.m in Sources */ = {isa = PBXBuildFile; fileRef = 612DCBAE0D488BC60015DBEA /* SUUpdatePermissionPrompt.m */; };
6158A1C5137904B300487EC1 /* SUUpdater_Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 6158A1C4137904B300487EC1 /* SUUpdater_Private.h */; };
615AE3D00D64DC40001CA7BD /* SUModelTranslation.plist in Resources */ = {isa = PBXBuildFile; fileRef = 615AE3CF0D64DC40001CA7BD /* SUModelTranslation.plist */; };
6160E7E10D3B4A8800E9CD71 /* NTSynchronousTask.h in Headers */ = {isa = PBXBuildFile; fileRef = 610EC1C00CF3914D00AE239E /* NTSynchronousTask.h */; settings = {ATTRIBUTES = (); }; };
618FA5010DAE88B40026945C /* SUInstaller.h in Headers */ = {isa = PBXBuildFile; fileRef = 618FA4FF0DAE88B40026945C /* SUInstaller.h */; settings = {ATTRIBUTES = (); }; };
618FA5020DAE88B40026945C /* SUInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 618FA5000DAE88B40026945C /* SUInstaller.m */; };
618FA5050DAE8AB80026945C /* SUPlainInstaller.h in Headers */ = {isa = PBXBuildFile; fileRef = 618FA5030DAE8AB80026945C /* SUPlainInstaller.h */; settings = {ATTRIBUTES = (); }; };
@@ -171,12 +170,30 @@
720B16441C66433D006985FB /* UITests-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 720B16421C66433D006985FB /* UITests-Info.plist */; };
720B16451C66433D006985FB /* SUTestApplicationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 720B16431C66433D006985FB /* SUTestApplicationTest.swift */; };
7210C7681B9A9A1500EB90AC /* SUUnarchiverTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */; };
721CF1A71AD7643600D9AC09 /* bsdiff.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */; settings = {COMPILER_FLAGS = "-w"; }; };
721CF1A81AD7644100D9AC09 /* bspatch.c in Sources */ = {isa = PBXBuildFile; fileRef = 5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */; settings = {COMPILER_FLAGS = "-w"; }; };
721CF1A91AD7644C00D9AC09 /* sais.c in Sources */ = {isa = PBXBuildFile; fileRef = 7223E7611AD1AEFF008E3161 /* sais.c */; settings = {COMPILER_FLAGS = "-w"; }; };
721BC2111D1DFF05002BC71E /* SUFileOperationConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 722954C31D04E66F00ECF9CA /* SUFileOperationConstants.m */; };
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 */; };
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 */; };
722954B71D04ADAF00ECF9CA /* fileop.m in Sources */ = {isa = PBXBuildFile; fileRef = 722954B61D04ADAF00ECF9CA /* fileop.m */; };
722954BC1D04AE1100ECF9CA /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; };
722954BD1D04AE3800ECF9CA /* SUConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 61299A5F09CA6EB100B7442F /* SUConstants.m */; };
722954C11D04D9ED00ECF9CA /* fileop in Copy fileop */ = {isa = PBXBuildFile; fileRef = 722954B41D04ADAF00ECF9CA /* fileop */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
722954C41D04E66F00ECF9CA /* SUFileOperationConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 722954C21D04E66F00ECF9CA /* SUFileOperationConstants.h */; };
722954C51D04E66F00ECF9CA /* SUFileOperationConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 722954C31D04E66F00ECF9CA /* SUFileOperationConstants.m */; };
722954C61D04E66F00ECF9CA /* SUFileOperationConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 722954C31D04E66F00ECF9CA /* SUFileOperationConstants.m */; };
722954C71D04E66F00ECF9CA /* SUFileOperationConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 722954C31D04E66F00ECF9CA /* SUFileOperationConstants.m */; };
722954C91D04EA5C00ECF9CA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D69BFE84028FC02AAC07 /* Foundation.framework */; };
722954CA1D04EA6000ECF9CA /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0867D6A5FE840307C02AAC07 /* AppKit.framework */; };
722954CB1D04EA6900ECF9CA /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 61B5F8F609C4CEB300B25A18 /* Security.framework */; };
722954CC1D04EA7000ECF9CA /* SUOperatingSystem.m in Sources */ = {isa = PBXBuildFile; fileRef = 726F2CE41BC9C33D001971A4 /* SUOperatingSystem.m */; };
723B252D1CEAB3A600909873 /* bscommon.c in Sources */ = {isa = PBXBuildFile; fileRef = 723B252B1CEAB3A600909873 /* bscommon.c */; };
723B252E1CEAB3A600909873 /* bscommon.c in Sources */ = {isa = PBXBuildFile; fileRef = 723B252B1CEAB3A600909873 /* bscommon.c */; };
723B252F1CEAB3A600909873 /* bscommon.c in Sources */ = {isa = PBXBuildFile; fileRef = 723B252B1CEAB3A600909873 /* bscommon.c */; };
723B25301CEAB3A600909873 /* bscommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 723B252C1CEAB3A600909873 /* bscommon.h */; };
72544FFC1D0991A4000CFB2C /* SUFileOperationConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 722954C31D04E66F00ECF9CA /* SUFileOperationConstants.m */; };
7268AC631AD634C200C3E0C1 /* SUBinaryDeltaCreate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */; };
726F2CDE1BC9BE5B001971A4 /* SUFileManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7275F9C01B5F1F2900B1D19E /* SUFileManager.m */; };
726F2CE51BC9C33D001971A4 /* SUOperatingSystem.h in Headers */ = {isa = PBXBuildFile; fileRef = 726F2CE31BC9C33D001971A4 /* SUOperatingSystem.h */; };
@@ -201,6 +218,7 @@
72E45CFC1B641961005C701A /* sparkletestcast.xml in Resources */ = {isa = PBXBuildFile; fileRef = 72E45CFB1B641961005C701A /* sparkletestcast.xml */; };
72E45CFE1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem in Resources */ = {isa = PBXBuildFile; fileRef = 72E45CFD1B641D0D005C701A /* test_app_only_dsa_priv_dont_ever_do_this_for_real.pem */; };
72E45DDD1B65C3BD005C701A /* sign_update in Resources */ = {isa = PBXBuildFile; fileRef = 72E45DDC1B65C3BD005C701A /* sign_update */; };
72E641801D08D754000404CA /* fileop in Resources */ = {isa = PBXBuildFile; fileRef = 722954B41D04ADAF00ECF9CA /* fileop */; };
767B61AC1972D488004E0C3C /* SUGuidedPackageInstaller.h in Headers */ = {isa = PBXBuildFile; fileRef = 767B61AA1972D488004E0C3C /* SUGuidedPackageInstaller.h */; };
767B61AD1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; };
767B61AE1972D488004E0C3C /* SUGuidedPackageInstaller.m in Sources */ = {isa = PBXBuildFile; fileRef = 767B61AB1972D488004E0C3C /* SUGuidedPackageInstaller.m */; };
@@ -303,6 +321,13 @@
remoteGlobalIDString = 8DC2EF4F0486A6940098B216;
remoteInfo = Sparkle;
};
722954BE1D04D9CB00ECF9CA /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 722954B31D04ADAF00ECF9CA;
remoteInfo = fileop;
};
726B2B621C645FC900388755 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
@@ -345,6 +370,26 @@
name = "Copy Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
722954B21D04ADAF00ECF9CA /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = /usr/share/man/man1/;
dstSubfolderSpec = 0;
files = (
);
runOnlyForDeploymentPostprocessing = 1;
};
722954C01D04D9D600ECF9CA /* Copy fileop */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 6;
files = (
722954C11D04D9ED00ECF9CA /* fileop in Copy fileop */,
);
name = "Copy fileop";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
@@ -513,6 +558,7 @@
5D1AF5890FD7678C0065DB48 /* libxar.1.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxar.1.dylib; path = usr/lib/libxar.1.dylib; sourceTree = SDKROOT; };
5D1AF58F0FD767AD0065DB48 /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; };
5D1AF5990FD767E50065DB48 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; };
5F1510A11C96E591006E1629 /* testnamespaces.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = testnamespaces.xml; sourceTree = "<group>"; };
610134710DD250470049ACDF /* SUUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUpdateDriver.h; sourceTree = "<group>"; };
610134720DD250470049ACDF /* SUUpdateDriver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUUpdateDriver.m; sourceTree = "<group>"; };
610134790DD2541A0049ACDF /* SUProbingUpdateDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUProbingUpdateDriver.h; sourceTree = "<group>"; };
@@ -521,8 +567,6 @@
6102FE480E07803800F85D09 /* SUDiskImageUnarchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUDiskImageUnarchiver.h; sourceTree = "<group>"; };
6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUDiskImageUnarchiver.m; sourceTree = "<group>"; };
6102FE590E08C7EC00F85D09 /* SUUnarchiver_Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUnarchiver_Private.h; sourceTree = "<group>"; };
610EC1BF0CF3914D00AE239E /* NTSynchronousTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NTSynchronousTask.m; sourceTree = "<group>"; };
610EC1C00CF3914D00AE239E /* NTSynchronousTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NTSynchronousTask.h; sourceTree = "<group>"; };
611142E810FB1BE5009810AA /* bspatch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bspatch.h; sourceTree = "<group>"; };
61131A050F846CE600E97AF6 /* da */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = da; path = da.lproj/Sparkle.strings; sourceTree = "<group>"; };
61131A090F846D0A00E97AF6 /* zh_CN */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = zh_CN; path = zh_CN.lproj/Sparkle.strings; sourceTree = "<group>"; };
@@ -628,6 +672,13 @@
7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUUnarchiverTest.swift; sourceTree = "<group>"; };
7223E7611AD1AEFF008E3161 /* sais.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sais.c; sourceTree = "<group>"; };
7223E7621AD1AEFF008E3161 /* sais.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sais.h; sourceTree = "<group>"; };
722954B41D04ADAF00ECF9CA /* fileop */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = fileop; sourceTree = BUILT_PRODUCTS_DIR; };
722954B61D04ADAF00ECF9CA /* fileop.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = fileop.m; sourceTree = "<group>"; };
722954C21D04E66F00ECF9CA /* SUFileOperationConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUFileOperationConstants.h; sourceTree = "<group>"; };
722954C31D04E66F00ECF9CA /* SUFileOperationConstants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUFileOperationConstants.m; sourceTree = "<group>"; };
722954C81D04E89500ECF9CA /* ConfigFileop.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = ConfigFileop.xcconfig; sourceTree = "<group>"; };
723B252B1CEAB3A600909873 /* bscommon.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bscommon.c; sourceTree = "<group>"; };
723B252C1CEAB3A600909873 /* bscommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = bscommon.h; sourceTree = "<group>"; };
7268AC621AD634C200C3E0C1 /* SUBinaryDeltaCreate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBinaryDeltaCreate.m; sourceTree = "<group>"; };
7268AC641AD634E400C3E0C1 /* SUBinaryDeltaCreate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUBinaryDeltaCreate.h; sourceTree = "<group>"; };
726B2B5D1C645FC900388755 /* UI Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "UI Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -729,6 +780,16 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
722954B11D04ADAF00ECF9CA /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
722954CB1D04EA6900ECF9CA /* Security.framework in Frameworks */,
722954CA1D04EA6000ECF9CA /* AppKit.framework in Frameworks */,
722954C91D04EA5C00ECF9CA /* Foundation.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
726B2B5A1C645FC900388755 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -764,6 +825,7 @@
612279D90DB5470200AB99EA /* Sparkle Unit Tests.xctest */,
8DC2EF5B0486A6940098B216 /* Sparkle.framework */,
726B2B5D1C645FC900388755 /* UI Tests.xctest */,
722954B41D04ADAF00ECF9CA /* fileop */,
);
name = Products;
sourceTree = "<group>";
@@ -831,7 +893,6 @@
isa = PBXGroup;
children = (
14732BB61960ECE800593899 /* bsdiff */,
14732BB71960ECF000593899 /* CocoatechCore */,
);
name = "Third Party";
path = Vendor;
@@ -840,6 +901,8 @@
14732BB61960ECE800593899 /* bsdiff */ = {
isa = PBXGroup;
children = (
723B252B1CEAB3A600909873 /* bscommon.c */,
723B252C1CEAB3A600909873 /* bscommon.h */,
5D06E8DB0FD68CB9005AE3F6 /* bsdiff.c */,
5D06E8DC0FD68CB9005AE3F6 /* bspatch.c */,
611142E810FB1BE5009810AA /* bspatch.h */,
@@ -849,15 +912,6 @@
path = bsdiff;
sourceTree = "<group>";
};
14732BB71960ECF000593899 /* CocoatechCore */ = {
isa = PBXGroup;
children = (
610EC1C00CF3914D00AE239E /* NTSynchronousTask.h */,
610EC1BF0CF3914D00AE239E /* NTSynchronousTask.m */,
);
path = CocoatechCore;
sourceTree = "<group>";
};
14732BB81960EEB600593899 /* Resources */ = {
isa = PBXGroup;
children = (
@@ -912,6 +966,7 @@
14958C6C19AEBC610061B14F /* test-pubkey.pem */,
5AF6C74E1AEA46D10014A3AB /* test.sparkle_guided.pkg */,
5AD0FA7E1C73F2E2004BCEFF /* testappcast.xml */,
5F1510A11C96E591006E1629 /* testnamespaces.xml */,
);
path = Resources;
sourceTree = "<group>";
@@ -919,6 +974,7 @@
55C14BD5136EEFD000649790 /* Autoupdate */ = {
isa = PBXGroup;
children = (
722954B51D04ADAF00ECF9CA /* fileop */,
55C14BB9136EEF1500649790 /* Autoupdate-Info.plist */,
55C14BD3136EEFCE00649790 /* Autoupdate.m */,
);
@@ -1113,6 +1169,17 @@
name = "Update Control";
sourceTree = "<group>";
};
722954B51D04ADAF00ECF9CA /* fileop */ = {
isa = PBXGroup;
children = (
722954B61D04ADAF00ECF9CA /* fileop.m */,
722954C21D04E66F00ECF9CA /* SUFileOperationConstants.h */,
722954C31D04E66F00ECF9CA /* SUFileOperationConstants.m */,
);
name = fileop;
path = ../../fileop;
sourceTree = "<group>";
};
726B2B5E1C645FC900388755 /* UI Tests */ = {
isa = PBXGroup;
children = (
@@ -1139,6 +1206,7 @@
FA1941CE0D94A70100DD942E /* ConfigRelaunch.xcconfig */,
FA1941D30D94A70100DD942E /* ConfigRelaunchDebug.xcconfig */,
FA1941D40D94A70100DD942E /* ConfigRelaunchRelease.xcconfig */,
722954C81D04E89500ECF9CA /* ConfigFileop.xcconfig */,
FA1941CD0D94A70100DD942E /* ConfigTestApp.xcconfig */,
FA1941CB0D94A70100DD942E /* ConfigTestAppDebug.xcconfig */,
FA1941D20D94A70100DD942E /* ConfigTestAppRelease.xcconfig */,
@@ -1165,7 +1233,6 @@
buildActionMask = 2147483647;
files = (
611142E910FB1BE5009810AA /* bspatch.h in Headers */,
6160E7E10D3B4A8800E9CD71 /* NTSynchronousTask.h in Headers */,
61299B3609CB04E000B7442F /* Sparkle.h in Headers */,
61CFB3290E385186007A1735 /* Sparkle.pch in Headers */,
61B5FC0D09C4FC8200B25A18 /* SUAppcast.h in Headers */,
@@ -1183,6 +1250,7 @@
7275F9C11B5F1F2900B1D19E /* SUFileManager.h in Headers */,
767B61AC1972D488004E0C3C /* SUGuidedPackageInstaller.h in Headers */,
61EF67590E25C5B400F754E0 /* SUHost.h in Headers */,
723B25301CEAB3A600909873 /* bscommon.h in Headers */,
618FA5010DAE88B40026945C /* SUInstaller.h in Headers */,
55C14F06136EF6DB00649790 /* SULog.h in Headers */,
726F2CE51BC9C33D001971A4 /* SUOperatingSystem.h in Headers */,
@@ -1205,6 +1273,7 @@
61A354550DF113C70076ECB1 /* SUUserInitiatedUpdateDriver.h in Headers */,
61A2259E0D1C495D00430CCD /* SUVersionComparisonProtocol.h in Headers */,
3772FEA913DE0B6B00F79537 /* SUVersionDisplayProtocol.h in Headers */,
722954C41D04E66F00ECF9CA /* SUFileOperationConstants.h in Headers */,
61180BCA0D64138900B4E0D1 /* SUWindowController.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -1255,10 +1324,12 @@
55C14BB4136EEF1500649790 /* Sources */,
55C14BB5136EEF1500649790 /* Frameworks */,
14652F7B19A945D600959E44 /* Run Script: Set Git Version Info */,
722954C01D04D9D600ECF9CA /* Copy fileop */,
);
buildRules = (
);
dependencies = (
722954BF1D04D9CB00ECF9CA /* PBXTargetDependency */,
);
name = Autoupdate;
productName = Autoupdate;
@@ -1320,6 +1391,23 @@
productReference = 61B5F90209C4CEE200B25A18 /* Sparkle Test App.app */;
productType = "com.apple.product-type.application";
};
722954B31D04ADAF00ECF9CA /* fileop */ = {
isa = PBXNativeTarget;
buildConfigurationList = 722954BB1D04ADAF00ECF9CA /* Build configuration list for PBXNativeTarget "fileop" */;
buildPhases = (
722954B01D04ADAF00ECF9CA /* Sources */,
722954B11D04ADAF00ECF9CA /* Frameworks */,
722954B21D04ADAF00ECF9CA /* CopyFiles */,
);
buildRules = (
);
dependencies = (
);
name = fileop;
productName = fileop;
productReference = 722954B41D04ADAF00ECF9CA /* fileop */;
productType = "com.apple.product-type.tool";
};
726B2B5C1C645FC900388755 /* UI Tests */ = {
isa = PBXNativeTarget;
buildConfigurationList = 726B2B671C645FC900388755 /* Build configuration list for PBXNativeTarget "UI Tests" */;
@@ -1376,6 +1464,9 @@
612279D80DB5470200AB99EA = {
TestTargetID = 8DC2EF4F0486A6940098B216;
};
722954B31D04ADAF00ECF9CA = {
CreatedOnToolsVersion = 7.3.1;
};
726B2B5C1C645FC900388755 = {
CreatedOnToolsVersion = 7.2.1;
TestTargetID = 61B5F90109C4CEE200B25A18;
@@ -1448,6 +1539,7 @@
1420DF491962329200203BB0 /* Documentation */,
1495005F195FB89400BC5B5B /* All */,
726B2B5C1C645FC900388755 /* UI Tests */,
722954B31D04ADAF00ECF9CA /* fileop */,
);
};
/* End PBXProject section */
@@ -1457,7 +1549,9 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
72E641801D08D754000404CA /* fileop in Resources */,
14958C6E19AEBC950061B14F /* signed-test-file.txt in Resources */,
5F1510A21C96E591006E1629 /* testnamespaces.xml in Resources */,
72AC6B2E1B9B218C00F62325 /* SparkleTestCodeSignApp.dmg in Resources */,
C23E885B1BE7B24F0050BB73 /* SparkleTestCodeSignApp.enc.dmg in Resources */,
72AC6B281B9AAD6700F62325 /* SparkleTestCodeSignApp.tar in Resources */,
@@ -1602,6 +1696,7 @@
726F2CE71BC9C3E2001971A4 /* SUOperatingSystem.m in Sources */,
55C14F24136EF86F00649790 /* SUPackageInstaller.m in Sources */,
55C14F21136EF84D00649790 /* SUPlainInstaller.m in Sources */,
722954C61D04E66F00ECF9CA /* SUFileOperationConstants.m in Sources */,
55C14F22136EF86000649790 /* SUStandardVersionComparator.m in Sources */,
55C14F20136EF84300649790 /* SUStatusController.m in Sources */,
55C14F23136EF86700649790 /* SUSystemProfiler.m in Sources */,
@@ -1613,9 +1708,11 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
72544FFC1D0991A4000CFB2C /* SUFileOperationConstants.m in Sources */,
5D06E8E90FD68CDB005AE3F6 /* bsdiff.c in Sources */,
14652F7E19A9728A00959E44 /* bspatch.c in Sources */,
7223E7631AD1AEFF008E3161 /* sais.c in Sources */,
723B252F1CEAB3A600909873 /* bscommon.c in Sources */,
14652F7D19A9726700959E44 /* SUBinaryDeltaApply.m in Sources */,
14652F7C19A9725300959E44 /* SUBinaryDeltaCommon.m in Sources */,
7268AC631AD634C200C3E0C1 /* SUBinaryDeltaCreate.m in Sources */,
@@ -1635,6 +1732,7 @@
721CF1A91AD7644C00D9AC09 /* sais.c in Sources */,
5A4094481C74EA5200983BE0 /* SUAppcastTest.swift in Sources */,
72D4DAA11AD7632900B211E2 /* SUBinaryDeltaCreate.m in Sources */,
723B252E1CEAB3A600909873 /* bscommon.c in Sources */,
142E0E0919A83AAC00E4312B /* SUBinaryDeltaTest.m in Sources */,
F8761EB11ADC5068000C9034 /* SUCodeSigningVerifierTest.m in Sources */,
5AF9DC3C1981DBEE001EA135 /* SUDSAVerifierTest.m in Sources */,
@@ -1654,6 +1752,7 @@
61B5F93009C4CFDC00B25A18 /* main.m in Sources */,
726F2CEB1BC9C733001971A4 /* SUConstants.m in Sources */,
5A6D31EE1BF53245009C5157 /* SUFileManager.m in Sources */,
721BC2111D1DFF05002BC71E /* SUFileOperationConstants.m in Sources */,
5A6D31EF1BF5325F009C5157 /* SUOperatingSystem.m in Sources */,
72E45CF31B640CDD005C701A /* SUTestApplicationDelegate.m in Sources */,
A5BF4F1D1BC7668B007A052A /* SUTestWebServer.m in Sources */,
@@ -1661,6 +1760,18 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
722954B01D04ADAF00ECF9CA /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
722954CC1D04EA7000ECF9CA /* SUOperatingSystem.m in Sources */,
722954BD1D04AE3800ECF9CA /* SUConstants.m in Sources */,
722954BC1D04AE1100ECF9CA /* SUFileManager.m in Sources */,
722954B71D04ADAF00ECF9CA /* fileop.m in Sources */,
722954C71D04E66F00ECF9CA /* SUFileOperationConstants.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
726B2B591C645FC900388755 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -1674,7 +1785,7 @@
buildActionMask = 2147483647;
files = (
5D06E8EB0FD68CE4005AE3F6 /* bspatch.c in Sources */,
610EC1E00CF3A5FE00AE239E /* NTSynchronousTask.m in Sources */,
722954C51D04E66F00ECF9CA /* SUFileOperationConstants.m in Sources */,
61B5FBB709C4FAFF00B25A18 /* SUAppcast.m in Sources */,
61B5FC6F09C51F4900B25A18 /* SUAppcastItem.m in Sources */,
6120721309CC5C4B007FE0F6 /* SUAutomaticUpdateAlert.m in Sources */,
@@ -1692,6 +1803,7 @@
61EF67560E25B58D00F754E0 /* SUHost.m in Sources */,
618FA5020DAE88B40026945C /* SUInstaller.m in Sources */,
55C14F07136EF6DB00649790 /* SULog.m in Sources */,
723B252D1CEAB3A600909873 /* bscommon.c in Sources */,
726F2CE61BC9C33D001971A4 /* SUOperatingSystem.m in Sources */,
618FA5230DAE8E8A0026945C /* SUPackageInstaller.m in Sources */,
61D85D6D0E10B2ED00F9B4A9 /* SUPipedUnarchiver.m in Sources */,
@@ -1780,6 +1892,11 @@
target = 8DC2EF4F0486A6940098B216 /* Sparkle */;
targetProxy = 61FA528C0E2D9EB200EF58AD /* PBXContainerItemProxy */;
};
722954BF1D04D9CB00ECF9CA /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 722954B31D04ADAF00ECF9CA /* fileop */;
targetProxy = 722954BE1D04D9CB00ECF9CA /* PBXContainerItemProxy */;
};
726B2B631C645FC900388755 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 61B5F90109C4CEE200B25A18 /* Sparkle Test App */;
@@ -2160,6 +2277,33 @@
};
name = Release;
};
722954B81D04ADAF00ECF9CA /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 722954C81D04E89500ECF9CA /* ConfigFileop.xcconfig */;
buildSettings = {
GCC_WARN_UNUSED_VARIABLE = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
722954B91D04ADAF00ECF9CA /* Coverage */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 722954C81D04E89500ECF9CA /* ConfigFileop.xcconfig */;
buildSettings = {
GCC_WARN_UNUSED_VARIABLE = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Coverage;
};
722954BA1D04ADAF00ECF9CA /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 722954C81D04E89500ECF9CA /* ConfigFileop.xcconfig */;
buildSettings = {
GCC_WARN_UNUSED_VARIABLE = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
726B2B641C645FC900388755 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 729F10FF1C65A9B500DFCCC5 /* ConfigUITestDebug.xcconfig */;
@@ -2282,6 +2426,16 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
722954BB1D04ADAF00ECF9CA /* Build configuration list for PBXNativeTarget "fileop" */ = {
isa = XCConfigurationList;
buildConfigurations = (
722954B81D04ADAF00ECF9CA /* Debug */,
722954B91D04ADAF00ECF9CA /* Coverage */,
722954BA1D04ADAF00ECF9CA /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
726B2B671C645FC900388755 /* Build configuration list for PBXNativeTarget "UI Tests" */ = {
isa = XCConfigurationList;
buildConfigurations = (
+16 -6
View File
@@ -166,18 +166,28 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.5;
[self.statusController showWindow:self];
}
NSString *fileOperationToolPath = [[[[NSBundle mainBundle] executablePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@""SPARKLE_FILEOP_TOOL_NAME];
if (![[NSFileManager defaultManager] fileExistsAtPath:fileOperationToolPath]) {
SULog(@"Potential Installation Error: File operation tool path %@ is not found", fileOperationToolPath);
}
[SUInstaller installFromUpdateFolder:self.updateFolderPath
overHost:host
installationPath:installationPath
fileOperationToolPath:fileOperationToolPath
versionComparator:[SUStandardVersionComparator defaultComparator]
completionHandler:^(NSError *error) {
if (error) {
SULog(@"Installation Error: %@", error);
if (self.shouldShowUI) {
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = @"";
alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]];
[alert runModal];
NSError *underlyingError = [error.userInfo objectForKey:NSUnderlyingErrorKey];
if (underlyingError == nil || underlyingError.code != SUInstallationCancelledError) {
SULog(@"Installation Error: %@", error);
if (self.shouldShowUI) {
NSAlert *alert = [[NSAlert alloc] init];
alert.messageText = @"";
alert.informativeText = [NSString stringWithFormat:@"%@", [error localizedDescription]];
[alert runModal];
}
}
exit(EXIT_FAILURE);
} else {
+4
View File
@@ -9,7 +9,11 @@
#ifndef SUAPPCAST_H
#define SUAPPCAST_H
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
@class SUAppcastItem;
+33 -3
View File
@@ -118,6 +118,36 @@
}
}
- (NSDictionary *)attributesOfNode:(NSXMLElement *)node
{
NSEnumerator *attributeEnum = [[node attributes] objectEnumerator];
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
for (NSXMLNode *attribute in attributeEnum) {
NSString *attrName = [self sparkleNamespacedNameOfNode:attribute];
if (!attrName) {
continue;
}
NSString *stringValue = [attribute stringValue];
if (stringValue) {
[dictionary setObject:stringValue forKey:attrName];
}
}
return dictionary;
}
-(NSString *)sparkleNamespacedNameOfNode:(NSXMLNode *)node {
// XML namespace prefix is semantically meaningless, so compare namespace URI
// NS URI isn't used to fetch anything, and must match exactly, so we look for http:// not https://
if ([[node URI] isEqualToString:@"http://www.andymatuschak.org/xml-namespaces/sparkle"]) {
NSString *localName = [node localName];
assert(localName);
return [@"sparkle:" stringByAppendingString:localName];
} else {
return [node name]; // Backwards compatibility
}
}
-(NSArray *)parseAppcastItemsFromXMLFile:(NSURL *)appcastFile error:(NSError *__autoreleasing*)errorp {
if (errorp) {
*errorp = nil;
@@ -150,7 +180,7 @@
if ([[node children] count]) {
node = [node childAtIndex:0];
while (nil != node) {
NSString *name = [node name];
NSString *name = [self sparkleNamespacedNameOfNode:node];
if (name) {
NSMutableArray *nodes = [nodesDict objectForKey:name];
if (nodes == nil) {
@@ -167,7 +197,7 @@
node = [self bestNodeInNodes:[nodesDict objectForKey:name]];
if ([name isEqualToString:SURSSElementEnclosure]) {
// enclosure is flattened as a separate dictionary for some reason
NSDictionary *encDict = [(NSXMLElement *)node attributesAsDictionary];
NSDictionary *encDict = [self attributesOfNode:(NSXMLElement *)node];
[dict setObject:encDict forKey:name];
}
else if ([name isEqualToString:SURSSElementPubDate]) {
@@ -184,7 +214,7 @@
NSEnumerator *childEnum = [[node children] objectEnumerator];
for (NSXMLNode *child in childEnum) {
if ([[child name] isEqualToString:SURSSElementEnclosure]) {
[deltas addObject:[(NSXMLElement *)child attributesAsDictionary]];
[deltas addObject:[self attributesOfNode:(NSXMLElement *)child]];
}
}
[dict setObject:deltas forKey:name];
+4
View File
@@ -9,7 +9,11 @@
#ifndef SUAPPCASTITEM_H
#define SUAPPCASTITEM_H
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
SU_EXPORT @interface SUAppcastItem : NSObject
+38 -21
View File
@@ -317,8 +317,17 @@
SUHost *newHost = [[SUHost alloc] initWithBundle:newBundle];
NSString *newPublicDSAKey = newHost.publicDSAKey;
// Downgrade in DSA security should not be possible
if (publicDSAKey != nil && newPublicDSAKey == nil) {
SULog(@"A public DSA key is found in the old bundle but no public DSA key is found in the new update. For security reasons, the update will be rejected.");
return NO;
}
BOOL dsaKeysMatch = (publicDSAKey == nil || newPublicDSAKey == nil) ? NO : [publicDSAKey isEqualToString:newPublicDSAKey];
// If the new DSA key differs from the old, then this check is not a security measure, because the new key is not trusted.
// In that case, the check ensures that the app author has correctly used DSA keys, so that the app will be updateable in the next version.
// However if the new and old DSA keys are the same, then this is a security measure.
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.",
@@ -507,34 +516,43 @@
// Copy the relauncher into a temporary directory so we can get to it after the new version's installed.
// Only the paranoid survive: if there's already a stray copy of relaunch there, we would have problems.
NSString *const relaunchToolName = @"" SPARKLE_RELAUNCH_TOOL_NAME;
NSString *const relaunchPathToCopy = [sparkleBundle pathForResource:relaunchToolName ofType:@"app"];
if (relaunchPathToCopy != nil) {
NSString *targetPath = [[self appCachePath] stringByAppendingPathComponent:[relaunchPathToCopy lastPathComponent]];
SUFileManager *fileManager = [SUFileManager fileManagerAllowingAuthorization:NO];
NSError *error = nil;
NSURL *relaunchURLToCopy = [NSURL fileURLWithPath:relaunchPathToCopy];
NSURL *targetURL = [NSURL fileURLWithPath:targetPath];
NSString *const relaunchToolSourcePath = [sparkleBundle pathForResource:relaunchToolName ofType:@"app"];
NSString *relaunchCopyTargetPath = nil;
NSError *error = nil;
BOOL copiedRelaunchPath = NO;
if (relaunchToolSourcePath) {
relaunchCopyTargetPath = [[self appCachePath] stringByAppendingPathComponent:[relaunchToolSourcePath lastPathComponent]];
SUFileManager *fileManager = [SUFileManager defaultManager];
NSURL *relaunchToolSourceURL = [NSURL fileURLWithPath:relaunchToolSourcePath];
NSURL *relaunchCopyTargetURL = [NSURL fileURLWithPath:relaunchCopyTargetPath];
// We only need to run our copy of the app by spawning a task
// Since we are copying the app to a directory that is write-accessible, we don't need to muck with owner/group IDs
if ([self preparePathForRelaunchTool:targetPath error:&error] && [fileManager copyItemAtURL:relaunchURLToCopy toURL:targetURL error:&error]) {
if ([self preparePathForRelaunchTool:relaunchCopyTargetPath error:&error] && [fileManager copyItemAtURL:relaunchToolSourceURL toURL:relaunchCopyTargetURL error:&error]) {
copiedRelaunchPath = YES;
// We probably don't need to release the quarantine, but we'll do it just in case it's necessary.
// Perhaps in a sandboxed environment this matters more. Note that this may not be a fatal error.
NSError *quarantineError = nil;
if (![fileManager releaseItemFromQuarantineAtRootURL:targetURL error:&quarantineError]) {
SULog(@"Failed to release quarantine on %@ with error %@", targetPath, quarantineError);
if (![fileManager releaseItemFromQuarantineAtRootURL:relaunchCopyTargetURL error:&quarantineError]) {
SULog(@"Failed to release quarantine on %@ with error %@", relaunchCopyTargetPath, quarantineError);
}
self.relaunchPath = targetPath;
} else {
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while extracting the archive. Please try again later.", nil),
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@", relaunchPathToCopy, targetPath, (error ? [error localizedDescription] : @"")]
}]];
}
}
if (!copiedRelaunchPath) {
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [self.host name]],
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't copy relauncher (%@) to temporary path (%@)! %@",
relaunchToolSourcePath, relaunchCopyTargetPath, (error ? [error localizedDescription] : @"")],
}]];
return;
}
self.relaunchPath = relaunchCopyTargetPath; // Set for backwards compatibility, in case any delegates modify it
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
if ([updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)])
[updaterDelegate updaterWillRelaunchApplication:self.updater];
@@ -544,9 +562,8 @@
// Note that we explicitly use the host app's name here, since updating plugin for Mail relaunches Mail, not just the plugin.
[self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{
NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@.", nil), [self.host name]],
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@)", self.relaunchPath]
NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"Couldn't find the relauncher (expected to find it at %@ and %@)", relaunchToolSourcePath, self.relaunchPath],
}]];
// We intentionally don't abandon the update here so that the host won't initiate another.
return;
}
+1 -1
View File
@@ -221,7 +221,7 @@ BOOL removeTree(NSString *path)
BOOL copyTree(NSString *source, NSString *dest)
{
return [[SUFileManager fileManagerAllowingAuthorization:NO] copyItemAtURL:[NSURL fileURLWithPath:source] toURL:[NSURL fileURLWithPath:dest] error:NULL];
return [[SUFileManager defaultManager] copyItemAtURL:[NSURL fileURLWithPath:source] toURL:[NSURL fileURLWithPath:dest] error:NULL];
}
BOOL modifyPermissions(NSString *path, mode_t desiredPermissions)
+1 -1
View File
@@ -87,7 +87,7 @@ static NSDictionary *infoForFile(FTSENT *ent)
static bool aclExists(const FTSENT *ent)
{
// OS X does not currently support ACLs for symlinks
// macOS does not currently support ACLs for symlinks
if (ent->fts_info == FTS_SL) {
return NO;
}
-1
View File
@@ -12,7 +12,6 @@
#import "SUUnarchiver_Private.h"
#import "SUHost.h"
#import "SULog.h"
#import "NTSynchronousTask.h"
@implementation SUBinaryDeltaUnarchiver
+30 -10
View File
@@ -8,7 +8,6 @@
#import "SUDiskImageUnarchiver.h"
#import "SUUnarchiver_Private.h"
#import "NTSynchronousTask.h"
#import "SULog.h"
#include <CoreServices/CoreServices.h>
@@ -89,12 +88,27 @@
NSInteger taskResult = -1;
@try
{
NTSynchronousTask *task = [[NTSynchronousTask alloc] init];
[task run:@"/usr/bin/hdiutil" directory:@"/" withArgs:arguments input:promptData];
taskResult = [task result];
output = [[task output] copy];
NSTask *task = [[NSTask alloc] init];
task.launchPath = @"/usr/bin/hdiutil";
task.currentDirectoryPath = @"/";
task.arguments = arguments;
NSPipe *inputPipe = [NSPipe pipe];
NSPipe *outputPipe = [NSPipe pipe];
task.standardInput = inputPipe;
task.standardOutput = outputPipe;
[task launch];
[inputPipe.fileHandleForWriting writeData:promptData];
[inputPipe.fileHandleForWriting closeFile];
// Read data to end *before* waiting until the task ends so we don't deadlock if the stdout buffer becomes full if we haven't consumed from it
output = [outputPipe.fileHandleForReading readDataToEndOfFile];
[task waitUntilExit];
taskResult = task.terminationStatus;
}
@catch (NSException *)
{
@@ -144,10 +158,16 @@
dispatch_async(dispatch_get_main_queue(), delegateFailure);
finally:
if (mountedSuccessfully)
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:@[@"detach", mountPoint, @"-force"]];
else
if (mountedSuccessfully) {
@try {
[NSTask launchedTaskWithLaunchPath:@"/usr/bin/hdiutil" arguments:@[@"detach", mountPoint, @"-force"]];
} @catch (NSException *exception) {
SULog(@"Failed to unmount %@", mountPoint);
SULog(@"Exception: %@", exception);
}
} else {
SULog(@"Can't mount DMG %@", self.archivePath);
}
}
}
+5
View File
@@ -9,7 +9,11 @@
#ifndef SUERRORS_H
#define SUERRORS_H
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
/**
@@ -40,6 +44,7 @@ typedef NS_ENUM(OSStatus, SUError) {
SURelaunchError = 4004,
SUInstallationError = 4005,
SUDowngradeError = 4006,
SUInstallationCancelledError = 4007,
// System phase errors
SUSystemPowerOffError = 5000
+37 -9
View File
@@ -9,21 +9,27 @@
#import <Foundation/Foundation.h>
/**
* A class used for performing file operations that may also perform authentication if allowed and if permission is denied when trying to
* A class used for performing file operations that may also perform authorization if allowed and if permission is denied when trying to
* perform them normally as the running user. All operations on this class may be used on thread other than the main thread.
* This class provides basic file operations and stays away from including much application-level logic.
*/
@interface SUFileManager : NSObject
/**
* Creates a file manager that allows or disallows authorizing for file operations
* @param allowsAuthorization Specifies whether operations invoked on this instance are allowed to acquire authorization in order
* to perform file operations when read or write access is denied
* Creates a file manager that will not authorize for file operations
* @return A new file manager instance
*/
+ (instancetype)defaultManager;
/**
* Creates a file manager that allows authorizing for file operations
* @param authorizationToolPath Specifies the path to the tool that can perform file operations and be run as root.
* This tool will be invoked when read or write access is denied when attempting ordinary file operations. See the `fileop` tool included in Sparkle.
* @return A new file manager instance
*
* This method just creates the file manager. It doesn't acquire authorization immediately if allowsAuthorization is YES
*
* This method just creates the file manager. It doesn't acquire authorization immediately or if it doesn't need to.
*/
+ (instancetype)fileManagerAllowingAuthorization:(BOOL)allowsAuthorization;
+ (instancetype)fileManagerWithAuthorizationToolPath:(NSString *)authorizationToolPath;
/**
* Returns a file manager that allows or disallows authorizing for file operations based on the current file manager
@@ -46,6 +52,16 @@
*/
- (NSURL *)makeTemporaryDirectoryWithPreferredName:(NSString *)preferredName appropriateForDirectoryURL:(NSURL *)appropriateURL error:(NSError **)error;
/**
* Creates a directory at the target URL
* @param targetURL A URL pointing to the directory to create. The item at this URL must not exist, and the parent directory of this URL must already exist.
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
* @return YES if the item was created successfully, otherwise NO along with a populated error object
*
* This is an atomic operation.
*/
- (BOOL)makeDirectoryAtURL:(NSURL *)targetURL error:(NSError **)error;
/**
* Moves an item from a source to a destination
* @param sourceURL A URL pointing to the item to move. The item at this URL must exist.
@@ -129,8 +145,8 @@
* @return YES if all the items at the target could be released from quarantine, otherwise NO if any items couldn't along with a populated error object
*
* This method removes quarantine attributes from an item, ideally an application, so that when the user launches a new application themselves, they
* don't have to witness the OS X dialog alerting them that they downloaded an application from the internet and asking if they want to continue.
* Note that this may not exactly mimic OS X's behavior when a user opens an application for the first time (i.e, the xattr isn't deleted),
* don't have to witness the system dialog alerting them that they downloaded an application from the internet and asking if they want to continue.
* Note that this may not exactly mimic the system behavior when a user opens an application for the first time (i.e, the xattr isn't deleted),
* but this should be sufficient enough for our purposes.
*
* This method may return NO even if some items do get released from quarantine if the target URL is pointing to a directory.
@@ -140,4 +156,16 @@
*/
- (BOOL)releaseItemFromQuarantineAtRootURL:(NSURL *)rootURL error:(NSError **)error;
/**
* Runs an installer package (pkg) in a headless mode using /usr/sbin/installer
* @param packageURL A URL pointing to the package to execute. The item at this URL must exist.
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
* @return YES if the installer ran the package successfully, otherwise NO with a populated error object
*
* This method uses the system wide installer tool to run the provided package. This process does not show any UI, except for
* an initial authorization prompt if the calling process does not have root privileges. In other words, root privileges are required to use this method, and the file manager instance must have been created by allowing authorization.
* An error can occur if the package is unable to be ran by the installer, or if the installer reports a non-zero exit status code.
*/
- (BOOL)executePackageAtURL:(NSURL *)packageURL error:(NSError **)error;
@end
+183 -100
View File
@@ -8,6 +8,7 @@
#import "SUFileManager.h"
#import "SUOperatingSystem.h"
#import "SUFileOperationConstants.h"
#include <sys/xattr.h>
#include <sys/errno.h>
@@ -15,30 +16,6 @@
static char SUAppleQuarantineIdentifier[] = "com.apple.quarantine";
// Authorization code based on generous contribution from Allan Odgaard. Thanks, Allan!
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char *executablePath, AuthorizationFlags options, char *const *arguments)
{
sig_t oldSigChildHandler = signal(SIGCHLD, SIG_DFL);
BOOL returnValue = YES;
#pragma clang diagnostic push
// In the future, we may have to look at SMJobBless API to avoid deprecation. See issue #558
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (AuthorizationExecuteWithPrivileges(authorization, executablePath, options, arguments, NULL) == errAuthorizationSuccess)
#pragma clang diagnostic pop
{
int status;
pid_t pid = wait(&status);
if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)
returnValue = NO;
}
else
returnValue = NO;
signal(SIGCHLD, oldSigChildHandler);
return returnValue;
}
static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
char path[PATH_MAX] = {0};
@@ -75,32 +52,37 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
{
AuthorizationRef _auth;
NSFileManager *_fileManager;
BOOL _allowsAuthorization;
NSString *_authorizationToolPath;
}
- (instancetype)initAllowingAuthorization:(BOOL)allowsAuthorization
- (instancetype)initWithAuthorizationToolPath:(NSString *)authorizationToolPath
{
self = [super init];
if (self != nil) {
_fileManager = [[NSFileManager alloc] init];
_allowsAuthorization = allowsAuthorization;
_authorizationToolPath = [authorizationToolPath copy];
}
return self;
}
+ (instancetype)fileManagerAllowingAuthorization:(BOOL)allowsAuthorization
+ (instancetype)defaultManager
{
return [[self alloc] initAllowingAuthorization:allowsAuthorization];
return [[self alloc] initWithAuthorizationToolPath:nil];
}
+ (instancetype)fileManagerWithAuthorizationToolPath:(NSString *)authorizationToolPath
{
return [[self alloc] initWithAuthorizationToolPath:authorizationToolPath];
}
- (instancetype)fileManagerByPreservingAuthorizationRights
{
// Check if we don't allow authorization, or that we haven't needed to authorize yet, to create or re-use a
// file manager instance with these restrictions
return (_allowsAuthorization && _auth != NULL) ? self : [SUFileManager fileManagerAllowingAuthorization:NO];
return (_authorizationToolPath != nil && _auth != NULL) ? self : [SUFileManager defaultManager];
}
// Acquires an authorization reference which is intended to be used for future authorized file operations
// Acquires an authorization reference with root privileges which is intended to be used for authorized file operations
- (BOOL)_acquireAuthorizationWithError:(NSError *__autoreleasing *)error
{
// No need to continue if we already acquired an authorization reference
@@ -108,21 +90,112 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
return YES;
}
if (!_allowsAuthorization) {
if (_authorizationToolPath == nil) {
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: @"Unable to grant authorization to perform action because it is explicitly turned off" }];
}
return NO;
}
OSStatus status = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &_auth);
if (status != errAuthorizationSuccess) {
OSStatus createStatus = AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &_auth);
if (createStatus != errAuthorizationSuccess) {
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed creating authorization reference with status code %d.", status] }];
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed creating authorization reference with status code %d.", createStatus] }];
}
_auth = NULL;
return NO;
}
AuthorizationItem rightItems[] = {
// The right that allows us to run tools as root user
{.name = kAuthorizationRightExecute, .valueLength = 0, .value = NULL, .flags = 0}
};
AuthorizationRights rights = {
.count = sizeof(rightItems) / sizeof(*rightItems),
.items = rightItems
};
AuthorizationFlags flags =
(AuthorizationFlags)(kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights | kAuthorizationFlagPreAuthorize);
// This will test if we can gain authorization for running utlities as root
OSStatus copyStatus = AuthorizationCopyRights(_auth, &rights, kAuthorizationEmptyEnvironment, flags, NULL);
if (copyStatus != errAuthorizationSuccess) {
if (error != NULL) {
if (copyStatus == errAuthorizationCanceled) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationCancelledError userInfo:@{ NSLocalizedDescriptionKey: @"Authorization access was cancelled by the user." }];
} else {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed granting authorization rights with status code %d.", copyStatus] }];
}
}
AuthorizationFree(_auth, kAuthorizationFlagDefaults);
_auth = NULL;
return NO;
}
return YES;
}
- (BOOL)_authorizeAndExecuteCommand:(char *)command sourcePath:(char *)sourcePath destinationPath:(char *)destinationPath error:(NSError * __autoreleasing *)error
{
NSError *acquireError = nil;
if (![self _acquireAuthorizationWithError:&acquireError]) {
if (error != NULL) {
*error = acquireError;
}
return NO;
}
char *arguments[] = { command, sourcePath, destinationPath, NULL };
char toolPath[PATH_MAX] = {0};
if (![_authorizationToolPath getFileSystemRepresentation:toolPath maxLength:sizeof(toolPath)]) {
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Authorization tool (%@) cannot be represented as a valid file name.", _authorizationToolPath.lastPathComponent] }];
}
return NO;
}
FILE *pipe = NULL;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (AuthorizationExecuteWithPrivileges(_auth, toolPath, kAuthorizationFlagDefaults, arguments, &pipe) != errAuthorizationSuccess) {
#pragma clang diagnostic pop
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:@"Failed to run authorization tool." }];
}
return NO;
}
uint32_t pidData = 0;
if (fread(&pidData, sizeof(pidData), 1, pipe) < 1) {
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:@"Failed to retrieve authorized executable process identifier." }];
}
fclose(pipe);
return NO;
}
pid_t childPid = (int32_t)CFSwapInt32LittleToHost(pidData);
int status = 0;
pid_t waitResult;
do {
waitResult = waitpid(childPid, &status, 0);
} while (waitResult == -1 && errno == EINTR);
fclose(pipe);
if (waitResult == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) {
if (error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Failed to execute authorized executable with result %d and status (%d, %d, %d).", waitResult, status, WIFEXITED(status), WEXITSTATUS(status)] }];
}
return NO;
}
return YES;
}
@@ -189,7 +262,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
#define XATTR_UTILITY_PATH "/usr/bin/xattr"
// Recursively remove an xattr at a specified root URL with authentication
- (BOOL)_removeXAttrWithAuthentication:(char *__nonnull)xattrName fromRootURL:(NSURL *)rootURL error:(NSError *__autoreleasing *)error
- (BOOL)_removeQuarantineWithAuthenticationAtRootURL:(NSURL *)rootURL error:(NSError *__autoreleasing *)error
{
// Because this is a system utility, it's fine to follow the symbolic link if one exists
if (![_fileManager fileExistsAtPath:@(XATTR_UTILITY_PATH)]) {
@@ -206,16 +279,11 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
}
return NO;
}
if (![self _acquireAuthorizationWithError:error]) {
return NO;
}
BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, XATTR_UTILITY_PATH, kAuthorizationFlagDefaults, (char *[]){ "-s", "-r", "-d", xattrName, path, NULL });
NSError *executeError = nil;
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpRemoveQuarantineCommand sourcePath:path destinationPath:NULL error:&executeError];
if (!success && error != NULL) {
NSString *errorMessage = [NSString stringWithFormat:@"Authenticated extended attribute deletion for %@ failed on %@.", [NSString stringWithUTF8String:xattrName], rootURL.path.lastPathComponent];
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:errorMessage }];
*error = executeError;
}
return success;
@@ -240,7 +308,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
removedQuarantine = YES;
} else {
if (isAccessError(removalError)) {
removedQuarantine = [self _removeXAttrWithAuthentication:SUAppleQuarantineIdentifier fromRootURL:rootURL error:error];
removedQuarantine = [self _removeQuarantineWithAuthenticationAtRootURL:rootURL error:error];
attemptedAuthentication = YES;
} else {
if (success != NULL) {
@@ -292,7 +360,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
}
// Removes the directory tree rooted at |root| from the file quarantine.
// The quarantine was introduced on OS X 10.5 and is described at:
// The quarantine was introduced on macOS 10.5 and is described at:
//
// http://developer.apple.com/releasenotes/Carbon/RN-LaunchServices/index.html#apple_ref/doc/uid/TP40001369-DontLinkElementID_2
//
@@ -394,11 +462,6 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
return NO;
}
if (![self _acquireAuthorizationWithError:error]) {
return NO;
}
char sourcePath[PATH_MAX] = {0};
if (![sourceURL.path getFileSystemRepresentation:sourcePath maxLength:sizeof(sourcePath)]) {
if (error != NULL) {
@@ -414,11 +477,11 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
}
return NO;
}
if (!AuthorizationExecuteWithPrivilegesAndWait(_auth, "/bin/cp", kAuthorizationFlagDefaults, (char *[]){ "-Rf", "--", sourcePath, destinationPath, NULL })) {
NSError *executeError = nil;
if (![self _authorizeAndExecuteCommand:SUFileOpCopyCommand sourcePath:sourcePath destinationPath:destinationPath error:&executeError]) {
if (error != NULL) {
NSString *errorMessage = [NSString stringWithFormat:@"Failed to perform authenticated file copy for %@.", sourceURL.lastPathComponent];
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:errorMessage }];
*error = executeError;
}
return NO;
}
@@ -507,10 +570,6 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
return NO;
}
if (![self _acquireAuthorizationWithError:error]) {
return NO;
}
char sourcePath[PATH_MAX] = {0};
if (![sourceURL.path getFileSystemRepresentation:sourcePath maxLength:sizeof(sourcePath)]) {
if (error != NULL) {
@@ -526,11 +585,12 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
}
return NO;
}
if (!AuthorizationExecuteWithPrivilegesAndWait(_auth, "/bin/mv", kAuthorizationFlagDefaults, (char *[]){ "-f", "--", sourcePath, destinationPath, NULL })) {
NSError *executeError = nil;
if (![self _authorizeAndExecuteCommand:SUFileOpMoveCommand sourcePath:sourcePath destinationPath:destinationPath error:&executeError]) {
if (error != NULL) {
NSString *errorMessage = [NSString stringWithFormat:@"Failed to perform authenticated file move for %@.", sourceURL.lastPathComponent];
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:errorMessage }];
NSString *errorMessage = [NSString stringWithFormat:@"Failed to perform authorized file move for %@.", sourceURL.lastPathComponent];
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey:errorMessage, NSUnderlyingErrorKey: executeError }];
}
return NO;
}
@@ -670,21 +730,20 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
}
return NO;
}
char userAndGroup[100];
int written = snprintf(userAndGroup, sizeof(userAndGroup), "%u:%u", ownerID.unsignedIntValue, groupID.unsignedIntValue);
if (written < 0 || written >= 100) {
return NO; // No custom error, because it's too unlikely to ever happen
}
if (![self _acquireAuthorizationWithError:error]) {
char matchPath[PATH_MAX] = {0};
if (![matchURLPath getFileSystemRepresentation:matchPath maxLength:sizeof(matchPath)]) {
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Match file (%@) cannot be represented as a valid file name.", matchURL.path.lastPathComponent] }];
}
return NO;
}
BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, "/usr/sbin/chown", kAuthorizationFlagDefaults, (char *[]){ "-R", userAndGroup, targetPath, NULL });
NSError *executeError = nil;
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpChangeOwnerAndGroupCommand sourcePath:targetPath destinationPath:matchPath error:&executeError];
if (!success && error != NULL) {
NSString *errorMessage = [NSString stringWithFormat:@"Failed to change owner:group %@ on %@ with authentication.", [NSString stringWithUTF8String:userAndGroup], targetURL.path.lastPathComponent];
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
NSString *errorMessage = [NSString stringWithFormat:@"Failed to change owner & group on %@ to match %@ with authorization.", targetURL.path.lastPathComponent, matchURLPath.lastPathComponent];
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage, NSUnderlyingErrorKey: executeError }];
}
return success;
@@ -736,15 +795,12 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
}
return NO;
}
if (![self _acquireAuthorizationWithError:error]) {
return NO;
}
BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, "/usr/bin/touch", kAuthorizationFlagDefaults, (char *[]){ "-h", "--", path, NULL });
NSError *executeError = nil;
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpUpdateModificationAndAccessTimeCommand sourcePath:path destinationPath:NULL error:&executeError];
if (!success && error != NULL) {
NSString *errorMessage = [NSString stringWithFormat:@"Failed to update modification & access time on %@ with authentication.", targetURL.path.lastPathComponent];
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
NSString *errorMessage = [NSString stringWithFormat:@"Failed to update modification & access time on %@ with authorization.", targetURL.path.lastPathComponent];
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage, NSUnderlyingErrorKey: executeError }];
}
return success;
@@ -752,7 +808,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
// Creates a directory at the item pointed by url
// An item cannot already exist at the url, but the parent must be a directory that exists
- (BOOL)_makeDirectoryAtURL:(NSURL *)url error:(NSError * __autoreleasing *)error
- (BOOL)makeDirectoryAtURL:(NSURL *)url error:(NSError * __autoreleasing *)error
{
if ([self _itemExistsAtURL:url]) {
if (error != NULL) {
@@ -789,16 +845,16 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
}
return NO;
}
if (![self _acquireAuthorizationWithError:error]) {
return NO;
}
BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, "/bin/mkdir", kAuthorizationFlagDefaults, (char *[]){ "--", path, NULL });
if (!success && error != NULL) {
NSString *errorMessage = [NSString stringWithFormat:@"Failed to make directory %@ with authentication.", url.path.lastPathComponent];
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage }];
NSError *executeError = nil;
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpMakeDirectoryCommand sourcePath:path destinationPath:NULL error:&executeError];
if (!success) {
if (error != NULL) {
NSString *errorMessage = [NSString stringWithFormat:@"Failed to make directory %@ with authorization.", url.path.lastPathComponent];
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: errorMessage, NSUnderlyingErrorKey: executeError }];
}
}
return success;
}
@@ -820,7 +876,7 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
desiredURL = [directoryURL URLByAppendingPathComponent:[preferredName stringByAppendingFormat:@" (%lu)", (unsigned long)++tagIndex]];
}
return [self _makeDirectoryAtURL:desiredURL error:error] ? desiredURL : nil;
return [self makeDirectoryAtURL:desiredURL error:error] ? desiredURL : nil;
}
- (BOOL)removeItemAtURL:(NSURL *)url error:(NSError * __autoreleasing *)error
@@ -844,10 +900,6 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
return NO;
}
if (![self _acquireAuthorizationWithError:error]) {
return NO;
}
char path[PATH_MAX] = {0};
if (![url.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
if (error != NULL) {
@@ -855,11 +907,14 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
}
return NO;
}
NSError *executeError = nil;
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpRemoveCommand sourcePath:path destinationPath:NULL error:&executeError];
BOOL success = AuthorizationExecuteWithPrivilegesAndWait(_auth, "/bin/rm", kAuthorizationFlagDefaults, (char *[]){ "-rf", "--", path, NULL });
if (!success && error != NULL) {
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove %@ with authentication.", url.path.lastPathComponent] }];
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUAuthenticationFailure userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to remove %@ with authentication.", url.path.lastPathComponent], NSUnderlyingErrorKey: executeError }];
}
return success;
}
@@ -948,6 +1003,34 @@ static BOOL SUMakeRefFromURL(NSURL *url, FSRef *ref, NSError **error) {
return success;
}
// Unlike other methods, authorization is required to execute this method successfully
- (BOOL)executePackageAtURL:(NSURL *)packageURL error:(NSError * __autoreleasing *)error
{
if (![self _itemExistsAtURL:packageURL]) {
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileNoSuchFileError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Failed to execute package %@ because the file does not exist.", packageURL.path.lastPathComponent] }];
}
return NO;
}
char path[PATH_MAX] = {0};
if (![packageURL.path getFileSystemRepresentation:path maxLength:sizeof(path)]) {
if (error != NULL) {
*error = [NSError errorWithDomain:NSCocoaErrorDomain code:NSFileReadInvalidFileNameError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Package to execute (%@) cannot be represented as a valid file name.", packageURL.path.lastPathComponent] }];
}
return NO;
}
NSError *executeError = nil;
BOOL success = [self _authorizeAndExecuteCommand:SUFileOpInstallCommand sourcePath:path destinationPath:NULL error:&executeError];
if (!success && error != NULL) {
NSString* errorMessage = @"Failed to execute package installer.";
*error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{NSLocalizedDescriptionKey: errorMessage, NSUnderlyingErrorKey: executeError}];
}
return success;
}
@end
#pragma clang diagnostic pop
+2 -2
View File
@@ -11,7 +11,7 @@
A guided installation allows Sparkle to download and install a package (pkg) or multi-package (mpkg) without user interaction.
The installer package is installed using Mac OS X's built-in command line installer, `/usr/sbin/installer`. No installation interface is shown to the user.
The installer package is installed using macOS's built-in command line installer, `/usr/sbin/installer`. No installation interface is shown to the user.
A guided installation can be started by applications other than the application being replaced. This is particularly useful where helper applications or agents are used.
@@ -29,7 +29,7 @@ A guided installation can be started by applications other than the application
@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;
+ (void)performInstallationToPath:(NSString *)path fromPath:(NSString *)installerGuide host:(SUHost *)host fileOperationToolPath:(NSString *)fileOperationToolPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
@end
#endif
+9 -119
View File
@@ -6,137 +6,27 @@
// Copyright 2010 Dragon Systems Software Limited. All rights reserved.
//
#import <sys/stat.h>
#import <Security/Security.h>
#import "SUGuidedPackageInstaller.h"
static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authorization, const char* executablePath, AuthorizationFlags options, char* const* arguments)
{
sig_t oldSigChildHandler = signal(SIGCHLD, SIG_DFL);
BOOL returnValue = YES;
#pragma clang diagnostic push
#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, arguments, NULL) == errAuthorizationSuccess)
#pragma clang diagnostic pop
{
int status = 0;
pid_t pid = wait(&status);
if (pid == -1 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)
returnValue = NO;
}
else
returnValue = NO;
signal(SIGCHLD, oldSigChildHandler);
return returnValue;
}
@implementation SUGuidedPackageInstaller (SUGuidedPackageInstallerAuthentication)
+ (AuthorizationRef)authorizationForExecutable:(NSString*)executablePath
{
SUParameterAssert(executablePath);
// Get authorization using advice in Apple's Technical Q&A1172
// ...create authorization without specific rights
AuthorizationRef auth = NULL;
OSStatus validAuth = AuthorizationCreate(NULL,
kAuthorizationEmptyEnvironment,
kAuthorizationFlagDefaults,
&auth);
// ...then extend authorization with desired rights
if ((validAuth == errAuthorizationSuccess) &&
(auth != NULL))
{
char executableFileSystemRepresentation[PATH_MAX];
[executablePath getFileSystemRepresentation:executableFileSystemRepresentation maxLength:sizeof(executableFileSystemRepresentation)];
// Prepare a right allowing script to execute with privileges
AuthorizationItem right = {
.name = kAuthorizationRightExecute,
.value = executableFileSystemRepresentation,
.valueLength = strlen(executableFileSystemRepresentation),
};
// Package up the single right
AuthorizationRights rights;
memset(&rights,0,sizeof(rights));
rights.count = 1;
rights.items = &right;
// Extend rights to run script
validAuth = AuthorizationCopyRights(auth,
&rights,
kAuthorizationEmptyEnvironment,
(AuthorizationFlags)
(kAuthorizationFlagPreAuthorize |
kAuthorizationFlagExtendRights |
kAuthorizationFlagInteractionAllowed),
NULL);
if (validAuth != errAuthorizationSuccess)
{
// Error, clean up authorization
(void) AuthorizationFree(auth,kAuthorizationFlagDefaults);
auth = NULL;
}
}
return auth;
}
@end
#import "SUFileManager.h"
@implementation SUGuidedPackageInstaller
+ (void)performInstallationToPath:(NSString *)destinationPath fromPath:(NSString *)packagePath host:(SUHost *)__unused host versionComparator:(id<SUVersionComparison>)__unused comparator completionHandler:(void (^)(NSError *))completionHandler
+ (void)performInstallationToPath:(NSString *)destinationPath fromPath:(NSString *)packagePath host:(SUHost *)__unused host fileOperationToolPath:(NSString *)fileOperationToolPath versionComparator:(id<SUVersionComparison>)__unused comparator completionHandler:(void (^)(NSError *))completionHandler
{
SUParameterAssert(packagePath);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Preflight
NSString* installerPath = @"/usr/sbin/installer"; // Mac OS X 10.2+ command line installer tool
NSError* error = nil;
// Create authorization for installer executable
BOOL validInstallation = NO;
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
char * const arguments[] = {
"-pkg",
pathBuffer,
"-target",
"/",
NULL
};
validInstallation = AuthorizationExecuteWithPrivilegesAndWait(auth,
[installerPath fileSystemRepresentation],
kAuthorizationFlagDefaults,
arguments);
// TODO: wait for communications pipe to close via fileno & CFSocketCreateWithNative
AuthorizationFree(auth,kAuthorizationFlagDefaults);
}
else
{
NSString* errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Script authorization denied."];
error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:[NSDictionary dictionaryWithObject:errorMessage forKey:NSLocalizedDescriptionKey]];
}
SUFileManager *fileManager = [SUFileManager fileManagerWithAuthorizationToolPath:fileOperationToolPath];
NSError *error = nil;
BOOL validInstallation = [fileManager executePackageAtURL:[NSURL fileURLWithPath:packagePath] error:&error];
dispatch_async(dispatch_get_main_queue(), ^{
[self finishInstallationToPath:destinationPath
withResult:validInstallation
error:error
completionHandler:completionHandler];
});
});
}
+1
View File
@@ -34,6 +34,7 @@ typedef struct {
@property (getter=isRunningOnReadOnlyVolume, readonly) BOOL runningOnReadOnlyVolume;
@property (getter=isBackgroundApplication, readonly) BOOL backgroundApplication;
@property (readonly, copy) NSString *publicDSAKey;
@property (readonly, nonatomic, copy) NSString *publicDSAKeyFileKey;
@property (readonly, copy) NSArray *systemProfile;
- (id)objectForInfoDictionaryKey:(NSString *)key;
+8 -3
View File
@@ -128,11 +128,11 @@
{
// Cache the application icon.
NSString *iconPath = [self.bundle pathForResource:[self.bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:@"icns"];
// According to the OS X docs, "CFBundleIconFile - This key identifies the file containing
// According to the macOS docs, "CFBundleIconFile - This key identifies the file containing
// the icon for the bundle. The filename you specify does not need to include the .icns
// extension, although it may."
//
// However, if it *does* include the '.icns' the above method fails (tested on OS X 10.3.9) so we'll also try:
// However, if it *does* include the '.icns' the above method fails (tested on macOS 10.3.9) so we'll also try:
if (!iconPath) {
iconPath = [self.bundle pathForResource:[self.bundle objectForInfoDictionaryKey:@"CFBundleIconFile"] ofType:nil];
}
@@ -168,7 +168,7 @@
}
// More likely, we've got a reference to a Resources file by filename:
NSString *keyFilename = [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
NSString *keyFilename = [self publicDSAKeyFileKey];
if (!keyFilename) {
return nil;
}
@@ -180,6 +180,11 @@
return [NSString stringWithContentsOfFile:keyPath encoding:NSASCIIStringEncoding error:nil];
}
- (NSString * __nullable)publicDSAKeyFileKey
{
return [self objectForInfoDictionaryKey:SUPublicDSAKeyFileKey];
}
- (NSArray *)systemProfile
{
return [[SUSystemProfiler sharedSystemProfiler] systemProfileArrayForHost:self];
+1 -1
View File
@@ -16,7 +16,7 @@
@interface SUInstaller : NSObject
+ (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)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath fileOperationToolPath:(NSString *)fileOperationToolPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler;
@end
+4 -4
View File
@@ -103,7 +103,7 @@
return newAppDownloadPath;
}
+ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler
+ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath fileOperationToolPath:(NSString *)fileOperationToolPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler
{
BOOL isPackage = NO;
BOOL isGuided = NO;
@@ -113,11 +113,11 @@
[self finishInstallationToPath:installationPath withResult:NO error:[NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingUpdateError userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't find an appropriate update in the downloaded package." }] completionHandler:completionHandler];
} else {
if (isPackage && isGuided) {
[SUGuidedPackageInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host versionComparator:comparator completionHandler:completionHandler];
[SUGuidedPackageInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host fileOperationToolPath:fileOperationToolPath versionComparator:comparator completionHandler:completionHandler];
} else if (isPackage) {
[SUPackageInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host versionComparator:comparator completionHandler:completionHandler];
[SUPackageInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host fileOperationToolPath:fileOperationToolPath versionComparator:comparator completionHandler:completionHandler];
} else {
[SUPlainInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host versionComparator:comparator completionHandler:completionHandler];
[SUPlainInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host fileOperationToolPath:fileOperationToolPath versionComparator:comparator completionHandler:completionHandler];
}
}
}
+3 -1
View File
@@ -20,7 +20,9 @@
{
NSOperatingSystemVersion version = { 0, 0, 0 };
NSURL *coreServices = [[NSFileManager defaultManager] URLForDirectory:NSCoreServiceDirectory inDomain:NSSystemDomainMask appropriateForURL:nil create:NO error:nil];
NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfURL:[coreServices URLByAppendingPathComponent:@"SystemVersion.plist"]];
NSURL *url = [coreServices URLByAppendingPathComponent:@"SystemVersion.plist"];
assert(url != nil);
NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfURL:url];
NSArray *components = [ [dictionary objectForKey: @"ProductVersion"] componentsSeparatedByString:@"."];
version.majorVersion = components.count > 0 ? [ [components objectAtIndex:0] integerValue] : 0;
version.minorVersion = components.count > 1 ? [ [components objectAtIndex:1] integerValue] : 0;
+1 -1
View File
@@ -12,7 +12,7 @@
@implementation SUPackageInstaller
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)__unused host versionComparator:(id<SUVersionComparison>)__unused comparator completionHandler:(void (^)(NSError *))completionHandler
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)__unused host fileOperationToolPath:(NSString *)__unused fileOperationToolPath versionComparator:(id<SUVersionComparison>)__unused comparator completionHandler:(void (^)(NSError *))completionHandler
{
// Run installer using the "open" command to ensure it is launched in front of current application.
// -W = wait until the app has quit.
+1 -1
View File
@@ -23,7 +23,7 @@
@interface SUPlainInstaller : SUInstaller
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host fileOperationToolPath:(NSString *)fileOperationToolPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler;
@end
+4 -4
View File
@@ -31,7 +31,7 @@
return trimmedVersion.length > 0 ? trimmedVersion : nil;
}
+ (BOOL)performInstallationToURL:(NSURL *)installationURL fromUpdateAtURL:(NSURL *)newURL withHost:(SUHost *)host error:(NSError * __autoreleasing *)error
+ (BOOL)performInstallationToURL:(NSURL *)installationURL fromUpdateAtURL:(NSURL *)newURL withHost:(SUHost *)host fileOperationToolPath:(NSString *)fileOperationToolPath error:(NSError * __autoreleasing *)error
{
if (installationURL == nil || newURL == nil) {
// this really shouldn't happen but just in case
@@ -42,7 +42,7 @@
return NO;
}
SUFileManager *fileManager = [SUFileManager fileManagerAllowingAuthorization:YES];
SUFileManager *fileManager = [SUFileManager fileManagerWithAuthorizationToolPath:fileOperationToolPath];
// Create a temporary directory for our new app that resides on our destination's volume
NSURL *tempNewDirectoryURL = [fileManager makeTemporaryDirectoryWithPreferredName:[installationURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingString:@" (Incomplete Update)"] appropriateForDirectoryURL:installationURL.URLByDeletingLastPathComponent error:error];
@@ -155,7 +155,7 @@
return YES;
}
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler
+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host fileOperationToolPath:(NSString *)fileOperationToolPath versionComparator:(id<SUVersionComparison>)comparator completionHandler:(void (^)(NSError *))completionHandler
{
SUParameterAssert(host);
@@ -173,7 +173,7 @@
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
NSError *error = nil;
BOOL result = [self performInstallationToURL:[NSURL fileURLWithPath:installationPath] fromUpdateAtURL:[NSURL fileURLWithPath:path] withHost:host error:&error];
BOOL result = [self performInstallationToURL:[NSURL fileURLWithPath:installationPath] fromUpdateAtURL:[NSURL fileURLWithPath:path] withHost:host fileOperationToolPath:fileOperationToolPath error:&error];
dispatch_async(dispatch_get_main_queue(), ^{
[self finishInstallationToPath:installationPath withResult:result error:error completionHandler:completionHandler];
+4
View File
@@ -9,7 +9,11 @@
#ifndef SUSTANDARDVERSIONCOMPARATOR_H
#define SUSTANDARDVERSIONCOMPARATOR_H
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
#import "SUVersionComparisonProtocol.h"
+2 -2
View File
@@ -128,7 +128,7 @@
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.
// "-apple-system-font" is a reference to the system UI font. "-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];
@@ -260,7 +260,7 @@
{
NSURL *requestURL = request.URL;
NSString *scheme = requestURL.scheme;
BOOL whitelistedSafe = [@"http" isEqualToString:scheme] || [@"https" isEqualToString:scheme] || [@"about:blank" isEqualToString:requestURL.absoluteString];
BOOL whitelistedSafe = [scheme isEqualToString:@"http"] || [scheme isEqualToString:@"https"] || [requestURL.absoluteString isEqualToString:@"about:blank"];
// Do not allow redirects to dangerous protocols such as file://
if (!whitelistedSafe) {
+11 -2
View File
@@ -9,7 +9,11 @@
#ifndef SUUPDATER_H
#define SUUPDATER_H
#if __has_feature(modules)
@import Foundation;
#else
#import <Foundation/Foundation.h>
#endif
#import "SUExport.h"
#import "SUVersionComparisonProtocol.h"
#import "SUVersionDisplayProtocol.h"
@@ -66,6 +70,11 @@ SU_EXPORT @interface SUUpdater : NSObject
*/
- (IBAction)checkForUpdates:(id)sender;
/*!
The menu item validation used for the -checkForUpdates: action
*/
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
/*!
Checks for updates, but does not display any UI unless an update is found.
@@ -83,7 +92,7 @@ SU_EXPORT @interface SUUpdater : NSObject
Checks for updates and, if available, immediately downloads and installs them.
A progress dialog is shown but the user will never be prompted to read the
release notes.
You may want to respond to the userDidCancelDownload delegate method in case
the user clicks the "Cancel" button while the update is downloading.
*/
@@ -263,7 +272,7 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey;
\param updater The SUUpdater instance.
\param item The appcast item corresponding to the update that is proposed to be installed.
\param invocation The invocation that must be completed before continuing with the relaunch.
\param invocation The invocation that must be completed with `[invocation invoke]` before continuing with the relaunch.
\return \c YES to delay the relaunch until \p invocation is invoked.
*/
+33 -85
View File
@@ -125,25 +125,38 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
BOOL hostIsCodeSigned = [SUCodeSigningVerifier hostApplicationIsCodeSigned];
NSURL *feedURL = [self feedURL];
BOOL servingOverHttps = [[[feedURL scheme] lowercaseString] isEqualToString:@"https"];
if (!isMainBundle && !hasPublicDSAKey) {
[self showAlertText:@"Insecure update error!"
informativeText:@"For security reasons, you need to sign your updates with a DSA key. See Sparkle's documentation for more information."];
} else if (isMainBundle && !(hasPublicDSAKey || hostIsCodeSigned)) {
[self showAlertText:@"Insecure update error!"
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."];
} else if (isMainBundle && !hasPublicDSAKey && !servingOverHttps) {
[self showAlertText:@"Insecure update error!"
informativeText:@"For security reasons, you need to serve your updates over https and/or sign your updates with a DSA key. See Sparkle's documentation for more information."];
if (!hasPublicDSAKey) {
// If we failed to retrieve a DSA key but the bundle specifies a path to one, we should consider this a configuration failure
NSString *publicDSAKeyFileKey = [self.host publicDSAKeyFileKey];
if (publicDSAKeyFileKey != nil) {
[self showAlertText:SULocalizedString(@"Insecure update error!", nil)
informativeText:[NSString stringWithFormat:SULocalizedString(@"For security reasons, the file (%@) indicated by the '%@' key needs to exist in the bundle's Resources.", nil), publicDSAKeyFileKey, SUPublicDSAKeyFileKey]];
} else {
if (!isMainBundle) {
[self showAlertText:SULocalizedString(@"Insecure update error!", nil)
informativeText:SULocalizedString(@"For security reasons, you need to sign your updates with a DSA key. See Sparkle's documentation for more information.", nil)];
} else {
if (!hostIsCodeSigned) {
[self showAlertText:SULocalizedString(@"Insecure update error!", nil)
informativeText:SULocalizedString(@"For security reasons, you need to code sign your application or sign your updates with a DSA key. See https://sparkle-project.org/documentation/ for more information.", nil)];
} else if (!servingOverHttps) {
[self showAlertText:SULocalizedString(@"Insecure update error!", nil)
informativeText:SULocalizedString(@"For security reasons, you need to serve your updates over HTTPS and/or sign your updates with a DSA key. See https://sparkle-project.org/documentation/ for more information.", nil)];
}
}
}
}
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101100
BOOL atsExceptionsExist = nil != [self.host objectForInfoDictionaryKey:@"NSAppTransportSecurity"];
if (isMainBundle && !servingOverHttps && !atsExceptionsExist) {
[self showAlertText:@"Insecure feed URL is blocked in OS X 10.11"
informativeText:[NSString stringWithFormat:@"You must change the feed URL (%@) to use HTTPS or disable App Transport Security.\n\nFor more information:\nhttp://sparkle-project.org/documentation/app-transport-security/", [feedURL absoluteString]]];
}
if (!isMainBundle && !servingOverHttps) {
SULog(@"WARNING: Serving updates over HTTP may be blocked in OS X 10.11. Please change the feed URL (%@) to use HTTPS. For more information:\nhttp://sparkle-project.org/documentation/app-transport-security/", feedURL);
if (!servingOverHttps) {
BOOL atsExceptionsExist = nil != [self.host objectForInfoDictionaryKey:@"NSAppTransportSecurity"];
if (isMainBundle && !atsExceptionsExist) {
[self showAlertText:SULocalizedString(@"Insecure feed URL is blocked in macOS 10.11", nil)
informativeText:[NSString stringWithFormat:SULocalizedString(@"You must change the feed URL (%@) to use HTTPS or disable App Transport Security.\n\nFor more information:\nhttps://sparkle-project.org/documentation/app-transport-security/", nil), [feedURL absoluteString]]];
} else if (!isMainBundle) {
SULog(@"WARNING: Serving updates over HTTP may be blocked in macOS 10.11. Please change the feed URL (%@) to use HTTPS. For more information:\nhttps://sparkle-project.org/documentation/app-transport-security/", feedURL);
}
}
#endif
}
@@ -249,79 +262,14 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
self.checkTimer = [NSTimer scheduledTimerWithTimeInterval:delayUntilCheck target:self selector:@selector(checkForUpdatesInBackground) userInfo:nil repeats:NO]; // Timer is non-repeating, may have invalidated itself, so we had to retain it.
}
- (void)putFeedURLIntoDictionary:(NSMutableDictionary *)theDict // You release this.
{
NSURL *feedURL = [self feedURL];
if (feedURL != nil) {
[theDict setObject:feedURL forKey:@"feedURL"];
}
}
- (void)checkForUpdatesInBgReachabilityCheckWithDriver:(SUUpdateDriver *)inDriver /* RUNS ON ITS OWN THREAD */
{
@try {
// This method *must* be called on its own thread. SCNetworkReachabilityCheckByName
// can block, and it can be waiting a long time on slow networks, and we
// wouldn't want to beachball the main thread for a background operation.
// We could use asynchronous reachability callbacks, but those aren't
// reliable enough and can 'get lost' sometimes, which we don't want.
@autoreleasepool {
SCNetworkConnectionFlags flags = 0;
BOOL isNetworkReachable = YES;
// Don't perform automatic checks on unconnected laptops or dial-up connections that aren't online:
NSMutableDictionary *theDict = [NSMutableDictionary dictionary];
dispatch_sync(dispatch_get_main_queue(), ^{
[self putFeedURLIntoDictionary:theDict]; // Get feed URL on main thread, it's not safe to call elsewhere.
});
const char *hostname = [[(NSURL *)[theDict objectForKey:@"feedURL"] host] cStringUsingEncoding:NSUTF8StringEncoding];
SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, hostname);
Boolean reachabilityResult = NO;
// If the feed's using a file:// URL, we won't be able to use reachability.
if (reachability != NULL) {
SCNetworkReachabilityGetFlags(reachability, &flags);
CFRelease(reachability);
}
if( reachabilityResult )
{
BOOL reachable = (flags & kSCNetworkFlagsReachable) == kSCNetworkFlagsReachable;
BOOL automatic = (flags & kSCNetworkFlagsConnectionAutomatic) == kSCNetworkFlagsConnectionAutomatic;
BOOL local = (flags & kSCNetworkFlagsIsLocalAddress) == kSCNetworkFlagsIsLocalAddress;
if (!(reachable || automatic || local))
isNetworkReachable = NO;
}
// If the network's not reachable, we pass a nil driver into checkForUpdatesWithDriver, which will then reschedule the next update so we try again later.
dispatch_async(dispatch_get_main_queue(), ^{
[self checkForUpdatesWithDriver: isNetworkReachable ? inDriver : nil];
});
}
} @catch (NSException *localException) {
SULog(@"UNCAUGHT EXCEPTION IN UPDATE CHECK TIMER: %@", [localException reason]);
// Don't propagate the exception beyond here. In Carbon apps that would trash the stack.
}
}
- (void)checkForUpdatesInBackground
{
// Background update checks should only happen if we have a network connection.
// Wouldn't want to annoy users on dial-up by establishing a connection every
// hour or so:
// Do not use reachability for a preflight check. This can be deceptive and a bad idea. Apple does not recommend doing it.
SUUpdateDriver *theUpdateDriver = [[([self automaticallyDownloadsUpdates] ? [SUAutomaticUpdateDriver class] : [SUScheduledUpdateDriver class])alloc] initWithUpdater:self];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[self checkForUpdatesInBgReachabilityCheckWithDriver:theUpdateDriver];
});
[self checkForUpdatesWithDriver:theUpdateDriver];
}
- (BOOL)mayUpdateAndRestart
{
return (!self.delegate || ![self.delegate respondsToSelector:@selector(updaterShouldRelaunchApplication:)] || [self.delegate updaterShouldRelaunchApplication:self]);
@@ -585,7 +533,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults
- (BOOL)validateMenuItem:(NSMenuItem *)item
{
if ([item action] == @selector(checkForUpdates:)) {
return ![self updateInProgress];
return ![self updateInProgress] || [self.driver isInterruptible];
}
return YES;
}
+4
View File
@@ -9,7 +9,11 @@
#ifndef SUVERSIONCOMPARISONPROTOCOL_H
#define SUVERSIONCOMPARISONPROTOCOL_H
#if __has_feature(modules)
@import Cocoa;
#else
#import <Cocoa/Cocoa.h>
#endif
#import "SUExport.h"
/*!
+4
View File
@@ -6,7 +6,11 @@
// Copyright 2009 Elgato Systems GmbH. All rights reserved.
//
#if __has_feature(modules)
@import Cocoa;
#else
#import <Cocoa/Cocoa.h>
#endif
#import "SUExport.h"
/*!
+4
View File
@@ -9,7 +9,11 @@
#ifndef SPARKLE_H
#define SPARKLE_H
#if __has_feature(modules)
@import Cocoa;
#else
#import <Cocoa/Cocoa.h>
#endif
// 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:
+1 -1
View File
@@ -39,7 +39,7 @@ static NSString * const UPDATED_VERSION = @"2.0";
[[NSApplication sharedApplication] terminate:nil];
}
SUFileManager *fileManager = [SUFileManager fileManagerAllowingAuthorization:NO];
SUFileManager *fileManager = [SUFileManager defaultManager];
// Locate user's cache directory
NSError *cacheError = nil;
@@ -29,4 +29,12 @@
[self.updater checkForUpdates:nil];
}
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
if (menuItem.action == @selector(checkForUpdates:)) {
return [self.updater validateMenuItem:menuItem];
}
return YES;
}
@end
+18
View File
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:customNS="http://www.andymatuschak.org/xml-namespaces/sparkle">
<channel>
<title>For unit test only</title>
<item>
<title>Version 3.0</title>
<pubDate>Sat, 26 Jul 2014 15:20:12 +0000</pubDate>
<customNS:releaseNotesLink>https://sparkle-project.org/#works</customNS:releaseNotesLink>
<enclosure url="http://0.0.0.0:1337/Sparkle_Test_App.zip" customNS:version="3.0" />
</item>
<item>
<title>Version 2.0</title>
<description>desc</description>
<pubDate>Sat, 26 Jul 2014 15:20:11 +0000</pubDate>
<enclosure url="http://0.0.0.0:1337/Sparkle_Test_App.zip" customNS:version="2.0" />
</item>
</channel>
</rss>
+23 -1
View File
@@ -11,7 +11,7 @@ import Sparkle;
class SUAppcastTest: XCTestCase {
func testExample() {
func testParseAppcast() {
let appcast = SUAppcast();
let testFile = NSBundle(forClass: SUAppcastTest.self).pathForResource("testappcast", ofType: "xml")!;
let testFileUrl = NSURL(fileURLWithPath: testFile);
@@ -62,4 +62,26 @@ class SUAppcastTest: XCTestCase {
XCTFail(err.localizedDescription);
}
}
func testNamespaces() {
let appcast = SUAppcast();
let testFile = NSBundle(forClass: SUAppcastTest.self).pathForResource("testnamespaces", ofType: "xml")!;
let testFileUrl = NSURL(fileURLWithPath: testFile);
XCTAssertNotNil(testFileUrl);
do {
let items = try appcast.parseAppcastItemsFromXMLFile(testFileUrl) as! [SUAppcastItem];
XCTAssertEqual(2, items.count);
XCTAssertEqual("Version 2.0", items[1].title);
XCTAssertEqual("desc", items[1].itemDescription);
XCTAssertNotNil(items[0].releaseNotesURL);
XCTAssertEqual("https://sparkle-project.org/#works", items[0].releaseNotesURL!.absoluteString);
} catch let err as NSError {
NSLog("%@", err);
XCTFail(err.localizedDescription);
}
}
}
+12 -9
View File
@@ -8,7 +8,6 @@
#import <Cocoa/Cocoa.h>
#import <XCTest/XCTest.h>
#import "NTSynchronousTask.h"
#import "SUCodeSigningVerifier.h"
#import "SUFileManager.h"
@@ -34,7 +33,7 @@
NSString *unitTestBundleIdentifier = unitTestBundle.bundleIdentifier;
NSString *zippedAppPath = [unitTestBundle pathForResource:@"SparkleTestCodeSignApp" ofType:@"zip"];
SUFileManager *fileManager = [SUFileManager fileManagerAllowingAuthorization:NO];
SUFileManager *fileManager = [SUFileManager defaultManager];
NSError *tempError = nil;
NSURL *tempDir = [fileManager makeTemporaryDirectoryWithPreferredName:unitTestBundleIdentifier appropriateForDirectoryURL:[NSURL fileURLWithPath:zippedAppPath] error:&tempError];
@@ -124,10 +123,14 @@
BOOL success = NO;
@try
{
NTSynchronousTask *task = [[NTSynchronousTask alloc] init];
NSArray *arguments = @[ zipPath ];
[task run:@"/usr/bin/unzip" directory:destPath withArgs:arguments input:nil];
success = ([task result] == 0);
NSTask *task = [[NSTask alloc] init];
task.launchPath = @"/usr/bin/unzip";
task.currentDirectoryPath = destPath;
task.arguments = @[zipPath];
[task launch];
[task waitUntilExit];
success = (task.terminationStatus == 0);
}
@catch (NSException *exception)
{
@@ -143,9 +146,9 @@
{
// ad-hoc signing with the dash
NSArray *arguments = @[ @"--force", @"--deep", @"--sign", @"-", appPath ];
NTSynchronousTask *task = [[NTSynchronousTask alloc] init];
[task run:@"/usr/bin/codesign" directory:nil withArgs:arguments input:nil];
success = ([task result] == 0);
NSTask *task = [NSTask launchedTaskWithLaunchPath:@"/usr/bin/codesign" arguments:arguments];
[task waitUntilExit];
success = (task.terminationStatus == 0);
}
@catch (NSException *exception)
{
+8 -15
View File
@@ -12,7 +12,7 @@ class SUFileManagerTest: XCTestCase
{
func makeTempFiles(testBlock: (SUFileManager, NSURL, NSURL, NSURL, NSURL, NSURL, NSURL) -> Void)
{
let fileManager = SUFileManager(allowingAuthorization: false)
let fileManager = SUFileManager.defaultManager()
let tempDirectoryURL = try! fileManager.makeTemporaryDirectoryWithPreferredName("Sparkle Unit Test Data", appropriateForDirectoryURL: NSURL(fileURLWithPath: NSHomeDirectory()))
@@ -167,7 +167,7 @@ class SUFileManagerTest: XCTestCase
XCTAssertEqual(0, setxattr(fileInDirectoryURL.path!, SUAppleQuarantineIdentifier, quarantineData, quarantineDataLength, 0, XATTR_CREATE))
XCTAssertGreaterThan(getxattr(fileInDirectoryURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
// Extended attributes can't be set on symbolic links in OS X, currently
// Extended attributes can't be set on symbolic links currently
try! fileManager.releaseItemFromQuarantineAtRootURL(validSymlinkURL)
XCTAssertGreaterThan(getxattr(directoryURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW), 0)
XCTAssertEqual(-1, getxattr(validSymlinkURL.path!, SUAppleQuarantineIdentifier, nil, 0, 0, XATTR_NOFOLLOW))
@@ -291,33 +291,26 @@ class SUFileManagerTest: XCTestCase
func testMakeDirectory()
{
makeTempFiles() { fileManager, rootURL, ordinaryFileURL, directoryURL, fileInDirectoryURL, validSymlinkURL, invalidSymlinkURL in
XCTAssertNil(try? fileManager._makeDirectoryAtURL(ordinaryFileURL))
XCTAssertNil(try? fileManager._makeDirectoryAtURL(directoryURL))
XCTAssertNil(try? fileManager.makeDirectoryAtURL(ordinaryFileURL))
XCTAssertNil(try? fileManager.makeDirectoryAtURL(directoryURL))
XCTAssertNil(try? fileManager._makeDirectoryAtURL(rootURL.URLByAppendingPathComponent("this should").URLByAppendingPathComponent("be a failure")))
XCTAssertNil(try? fileManager.makeDirectoryAtURL(rootURL.URLByAppendingPathComponent("this should").URLByAppendingPathComponent("be a failure")))
let newDirectoryURL = rootURL.URLByAppendingPathComponent("new test directory")
XCTAssertFalse(fileManager._itemExistsAtURL(newDirectoryURL))
try! fileManager._makeDirectoryAtURL(newDirectoryURL)
try! fileManager.makeDirectoryAtURL(newDirectoryURL)
var isDirectory: ObjCBool = false
XCTAssertTrue(fileManager._itemExistsAtURL(newDirectoryURL, isDirectory: &isDirectory))
try! fileManager.removeItemAtURL(directoryURL)
XCTAssertNil(try? fileManager._makeDirectoryAtURL(validSymlinkURL))
XCTAssertNil(try? fileManager.makeDirectoryAtURL(validSymlinkURL))
}
}
// This alone shouldn't prompt a password dialog and should always succeed
func testAcquireAuthorization()
{
let fileManager = SUFileManager(allowingAuthorization: true)
try! fileManager._acquireAuthorization()
}
func testAcquireBadAuthorization()
{
let fileManager = SUFileManager(allowingAuthorization: false)
let fileManager = SUFileManager.defaultManager()
XCTAssertNil(try? fileManager._acquireAuthorization())
}
}
+7 -1
View File
@@ -53,7 +53,13 @@
SUHost *host = [[SUHost alloc] initWithBundle:bundle];
[SUInstaller installFromUpdateFolder:[path stringByDeletingLastPathComponent] overHost:host installationPath:@"/tmp" versionComparator:nil completionHandler:^(NSError *error) {
NSString *fileOperationToolPath = [bundle pathForResource:@""SPARKLE_FILEOP_TOOL_NAME ofType:@""];
XCTAssertNotNil(fileOperationToolPath);
[SUInstaller installFromUpdateFolder:[path stringByDeletingLastPathComponent] overHost:host installationPath:@"/tmp" fileOperationToolPath:fileOperationToolPath versionComparator:nil completionHandler:^(NSError *error) {
if (error != nil) {
NSLog(@"Underlying error: %@", [error.userInfo objectForKey:NSUnderlyingErrorKey]);
}
XCTAssertNil(error);
XCTAssertTrue([fm fileExistsAtPath:expectedDestination isDirectory:nil]);
[done fulfill];
@@ -22,8 +22,6 @@ static const char *SUAppleQuarantineIdentifier = "com.apple.quarantine";
- (BOOL)_itemExistsAtURL:(NSURL *)fileURL;
- (BOOL)_itemExistsAtURL:(NSURL *)fileURL isDirectory:(BOOL *)isDirectory;
- (BOOL)_makeDirectoryAtURL:(NSURL *)url error:(NSError * __autoreleasing *)error;
@end
@interface SUBasicUpdateDriver (Private)
-26
View File
@@ -1,26 +0,0 @@
//
// NTSynchronousTask.h
// CocoatechCore
//
// Created by Steve Gehrman on 9/29/05.
// Copyright 2005 Steve Gehrman. All rights reserved.
//
#ifndef NTSYNCHRONOUSTASK_H
#define NTSYNCHRONOUSTASK_H
@interface NTSynchronousTask : NSObject
@property (readonly, strong) NSData *output;
@property (readonly) int result;
// pass nil for directory if not needed
// returns the result
+(int) task:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input output: (NSData**)outData;
+(NSData*)task:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input;
- (void)run:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input;
@end
#endif
-169
View File
@@ -1,169 +0,0 @@
//
// NTSynchronousTask.m
// CocoatechCore
//
// Created by Steve Gehrman on 9/29/05.
// Copyright 2005 Steve Gehrman. All rights reserved.
//
#import "NTSynchronousTask.h"
@interface NTSynchronousTask ()
@property (strong) NSTask *task;
@property (strong) NSPipe *outputPipe;
@property (strong) NSPipe *inputPipe;
@property (readwrite, strong) NSData *output;
@property (getter = isDone) BOOL done;
@property (readwrite) int result;
@end
@implementation NTSynchronousTask
@synthesize output = mv_output;
@synthesize result = mv_result;
@synthesize task = mv_task;
@synthesize outputPipe = mv_outputPipe;
@synthesize inputPipe = mv_inputPipe;
@synthesize done = mv_done;
- (void)taskOutputAvailable:(NSNotification*)note
{
self.output = [[note userInfo] objectForKey:NSFileHandleNotificationDataItem];
self.done = YES;
}
- (void)taskDidTerminate:(NSNotification *) __unused note
{
self.result = [self.task terminationStatus];
}
- (instancetype)init
{
self = [super init];
if (self)
{
self.task = [[NSTask alloc] init];
self.outputPipe = [[NSPipe alloc] init];
self.inputPipe = [[NSPipe alloc] init];
self.task.standardInput = self.inputPipe;
self.task.standardOutput = self.outputPipe;
self.task.standardError = self.outputPipe;
}
return self;
}
//----------------------------------------------------------
// dealloc
//----------------------------------------------------------
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
- (void)run:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input
{
BOOL success = NO;
if (currentDirectory) {
self.task.currentDirectoryPath = currentDirectory;
}
self.task.launchPath = toolPath;
self.task.arguments = args;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(taskOutputAvailable:)
name:NSFileHandleReadToEndOfFileCompletionNotification
object:[[self outputPipe] fileHandleForReading]];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(taskDidTerminate:)
name:NSTaskDidTerminateNotification
object:[self task]];
[[[self outputPipe] fileHandleForReading] readToEndOfFileInBackgroundAndNotifyForModes:@[NSDefaultRunLoopMode, NSModalPanelRunLoopMode, NSEventTrackingRunLoopMode]];
@try
{
[self.task launch];
success = YES;
}
@catch (NSException *) { }
if (success)
{
if (input)
{
// feed the running task our input
[[self.inputPipe fileHandleForWriting] writeData:input];
[[self.inputPipe fileHandleForWriting] closeFile];
}
// loop until we are done receiving the data
if (!self.done)
{
double resolution = 1;
BOOL isRunning;
NSDate* next;
do {
next = [NSDate dateWithTimeIntervalSinceNow:resolution];
isRunning = [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode
beforeDate:next];
} while (isRunning && !self.done);
}
}
}
+ (NSData*)task:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input
{
@autoreleasepool {
NSData* result = nil;
// we need this wacky pool here, otherwise we run out of pipes, the pipes are internally autoreleased
@try {
NTSynchronousTask* task = [[NTSynchronousTask alloc] init];
[task run:toolPath directory:currentDirectory withArgs:args input:input];
if ([task result] == 0) {
result = [task output];
}
}
@catch (NSException *) { }
return result;
}
}
+(int) task:(NSString*)toolPath directory:(NSString*)currentDirectory withArgs:(NSArray*)args input:(NSData*)input output: (NSData*__autoreleasing *)outData
{
// we need this wacky pool here, otherwise we run out of pipes, the pipes are internally autoreleased
@autoreleasepool {
int taskResult = 0;
if (outData) {
*outData = nil;
}
@try {
NTSynchronousTask* task = [[NTSynchronousTask alloc] init];
[task run:toolPath directory:currentDirectory withArgs:args input:input];
taskResult = [task result];
if (outData) {
*outData = [task output];
}
} @catch (NSException *) {
taskResult = errCppGeneral;
}
return taskResult;
}
}
@end
+62
View File
@@ -0,0 +1,62 @@
/*
* bscommon.c
* Sparkle
*
* Created by Mayur Pawashe on 5/16/16.
*/
#include "bscommon.h"
#include <stdlib.h>
u_char *readfile(const char *filename, off_t *outSize)
{
int success = -1;
u_char *buffer = NULL;
FILE *file = fopen(filename, "r");
if (file == NULL) {
goto cleanup;
}
if (fseek(file, 0L, SEEK_END) != 0) {
goto cleanup;
}
long offset = ftell(file);
if (offset == -1) {
goto cleanup;
}
size_t size = (size_t)offset;
if (outSize != NULL) {
*outSize = (off_t)size;
}
/* Allocate size + 1 bytes instead of newsize bytes to ensure
that we never try to malloc(0) and get a NULL pointer */
buffer = malloc(size + 1);
if (buffer == NULL) {
goto cleanup;
}
if (fseek(file, 0L, SEEK_SET) != 0) {
goto cleanup;
}
if (fread(buffer, 1, size, file) < size) {
goto cleanup;
}
success = 0;
cleanup:
if (success == -1) {
free(buffer);
buffer = NULL;
}
if (file != NULL) {
fclose(file);
}
return buffer;
}
+16
View File
@@ -0,0 +1,16 @@
/*
* bscommon.h
* Sparkle
*
* Created by Mayur Pawashe on 5/16/16.
*/
#ifndef BS_COMMON_H
#define BS_COMMON_H
#include <sys/types.h>
#include <stdio.h>
u_char *readfile(const char *filename, off_t *outSize);
#endif
+116 -80
View File
@@ -38,6 +38,8 @@ __FBSDID("$FreeBSD: src/usr.bin/bsdiff/bsdiff/bsdiff.c, v 1.1 2005/08/06 01:59:0
#include <string.h>
#include <unistd.h>
#include "bscommon.h"
#define MIN(x, y) (((x)<(y)) ? (x) : (y))
/* matchlen(old, oldsize, new, newsize)
@@ -82,7 +84,7 @@ static off_t search(off_t *I, u_char *old, off_t oldsize,
}
x = st + (en - st)/2;
if (memcmp(old + I[x], new, MIN(oldsize - I[x], newsize)) < 0) {
if (memcmp(old + I[x], new, (size_t)(MIN(oldsize - I[x], newsize))) < 0) {
return search(I, old, oldsize, new, newsize, x, en, pos);
} else {
return search(I, old, oldsize, new, newsize, st, x, pos);
@@ -101,15 +103,15 @@ static void offtout(off_t x, u_char *buf)
else
y = x;
buf[0] = y % 256;
buf[0] = (u_char)(y % 256);
y -= buf[0];
y = y/256; buf[1] = y%256; y -= buf[1];
y = y/256; buf[2] = y%256; y -= buf[2];
y = y/256; buf[3] = y%256; y -= buf[3];
y = y/256; buf[4] = y%256; y -= buf[4];
y = y/256; buf[5] = y%256; y -= buf[5];
y = y/256; buf[6] = y%256; y -= buf[6];
y = y/256; buf[7] = y%256;
y = y/256; buf[1] = (u_char)(y%256); y -= buf[1];
y = y/256; buf[2] = (u_char)(y%256); y -= buf[2];
y = y/256; buf[3] = (u_char)(y%256); y -= buf[3];
y = y/256; buf[4] = (u_char)(y%256); y -= buf[4];
y = y/256; buf[5] = (u_char)(y%256); y -= buf[5];
y = y/256; buf[6] = (u_char)(y%256); y -= buf[6];
y = y/256; buf[7] = (u_char)(y%256);
if (x < 0)
buf[7] |= 0x80;
@@ -119,67 +121,69 @@ int bsdiff(int argc, char *argv[]); // Added by AMM: suppresses a warning about
int bsdiff(int argc, char *argv[])
{
int fd;
u_char *old,*new; /* contents of old, new files */
off_t oldsize, newsize; /* length of old, new files */
off_t *I,*V; /* arrays used for suffix sort; I is ordering */
off_t scan; /* position of current match in old file */
u_char *old = NULL,*new = NULL; /* contents of old, new files */
off_t oldsize = 0, newsize = 0; /* length of old, new files */
off_t *I = NULL,*V = NULL; /* arrays used for suffix sort; I is ordering */
off_t scan = 0; /* position of current match in old file */
off_t pos = 0; /* position of current match in new file */
off_t len; /* length of current match */
off_t lastscan; /* position of previous match in old file */
off_t lastpos; /* position of previous match in new file */
off_t lastoffset; /* lastpos - lastscan */
off_t oldscore, scsc; /* temp variables in match search */
off_t s, Sf, lenf, Sb, lenb; /* temp vars in match extension */
off_t overlap, Ss, lens;
off_t i;
off_t dblen, eblen; /* length of diff, extra sections */
u_char *db,*eb; /* contents of diff, extra sections */
u_char buf[8];
u_char header[32];
FILE * pf;
off_t len = 0; /* length of current match */
off_t lastscan = 0; /* position of previous match in old file */
off_t lastpos = 0; /* position of previous match in new file */
off_t lastoffset = 0; /* lastpos - lastscan */
off_t oldscore = 0, scsc = 0; /* temp variables in match search */
off_t s = 0, Sf = 0, lenf = 0, Sb = 0, lenb = 0; /* temp vars in match extension */
off_t overlap = 0, Ss = 0, lens = 0;
off_t i = 0;
off_t dblen = 0, eblen = 0; /* length of diff, extra sections */
u_char *db = NULL,*eb = NULL; /* contents of diff, extra sections */
u_char buf[8] = {0};
u_char header[32] = {0};
FILE * pf = NULL;
int exitstatus = -1;
if (argc != 4)
errx(1,"usage: %s oldfile newfile patchfile\n", argv[0]);
if (argc != 4) {
warnx("usage: %s oldfile newfile patchfile\n", argv[0]);
goto cleanup;
}
/* Allocate oldsize + 1 bytes instead of oldsize bytes to ensure
that we never try to malloc(0) and get a NULL pointer */
if (((fd = open(argv[1], O_RDONLY, 0)) < 0) ||
((oldsize = lseek(fd, 0, SEEK_END)) == -1) ||
((old = malloc(oldsize + 1)) == NULL) ||
(lseek(fd, 0, SEEK_SET) != 0) ||
(read(fd, old, oldsize) != oldsize) ||
(close(fd) == -1))
err(1,"%s", argv[1]);
old = readfile(argv[1], &oldsize);
if (old == NULL) {
warn("old file error: %s", argv[1]);
goto cleanup;
}
if (((I = malloc((oldsize + 1) * sizeof(off_t))) == NULL) ||
((V = malloc((oldsize + 1) * sizeof(off_t))) == NULL))
err(1, NULL);
if (((I = malloc(((size_t)oldsize + 1) * sizeof(off_t))) == NULL) ||
((V = malloc(((size_t)oldsize + 1) * sizeof(off_t))) == NULL)) {
warn("Failed to allocate memory for I or V");
goto cleanup;
}
/* Do a suffix sort on the old file. */
I[0] = oldsize; sais(old, I+1, oldsize);
I[0] = oldsize;
sais(old, I+1, (int)oldsize);
free(V);
V = NULL;
new = readfile(argv[2], &newsize);
if (new == NULL) {
warn("new file error: %s", argv[2]);
goto cleanup;
}
/* Allocate newsize + 1 bytes instead of newsize bytes to ensure
that we never try to malloc(0) and get a NULL pointer */
if (((fd = open(argv[2], O_RDONLY, 0)) < 0) ||
((newsize = lseek(fd, 0, SEEK_END)) == -1) ||
((new = malloc(newsize + 1)) == NULL) ||
(lseek(fd, 0, SEEK_SET) != 0) ||
(read(fd, new, newsize) != newsize) ||
(close(fd) == -1))
err(1,"%s", argv[2]);
if (((db = malloc(newsize + 1)) == NULL) ||
((eb = malloc(newsize + 1)) == NULL))
err(1, NULL);
if (((db = malloc((size_t)newsize + 1)) == NULL) ||
((eb = malloc((size_t)newsize + 1)) == NULL)) {
warn("Failed to allocate memory for db or eb");
goto cleanup;
}
dblen = 0;
eblen = 0;
/* Create the patch file */
if ((pf = fopen(argv[3], "w")) == NULL)
err(1, "%s", argv[3]);
if ((pf = fopen(argv[3], "w")) == NULL) {
warn("%s", argv[3]);
goto cleanup;
}
/* Header is
0 8 "BSDIFN40"
@@ -195,8 +199,10 @@ int bsdiff(int argc, char *argv[])
offtout(0, header + 8);
offtout(0, header + 16);
offtout(newsize, header + 24);
if (fwrite(header, 32, 1, pf) != 1)
err(1, "fwrite(%s)", argv[3]);
if (fwrite(header, 32, 1, pf) != 1) {
warn("fwrite(%s)", argv[3]);
goto cleanup;
}
/* Compute the differences, writing ctrl as we go */
scan = 0;
@@ -312,16 +318,22 @@ int bsdiff(int argc, char *argv[])
* diff, in the old file
*/
offtout(lenf, buf);
if (fwrite(buf, 8, 1, pf) != 1)
errx(1, "fwrite");
if (fwrite(buf, 8, 1, pf) != 1) {
warnx("fwrite");
goto cleanup;
}
offtout((scan - lenb) - (lastscan + lenf), buf);
if (fwrite(buf, 8, 1, pf) != 1)
err(1, "fwrite");
if (fwrite(buf, 8, 1, pf) != 1) {
warn("fwrite");
goto cleanup;
}
offtout((pos - lenb) - (lastpos + lenf), buf);
if (fwrite(buf, 8, 1, pf) != 1)
err(1, "fwrite");
if (fwrite(buf, 8, 1, pf) != 1) {
warn("fwrite");
goto cleanup;
}
/* Update the variables describing the last match. Note that
* 'lastscan' is set to the start of the current match _after_ the
@@ -334,37 +346,61 @@ int bsdiff(int argc, char *argv[])
}
/* Compute size of compressed ctrl data */
if ((len = ftello(pf)) == -1)
err(1, "ftello");
if ((len = ftello(pf)) == -1) {
warn("ftello");
goto cleanup;
}
offtout(len - 32, header + 8);
/* Write diff data */
if (dblen && fwrite(db, dblen, 1, pf) != 1)
err(1, "fwrite");
if (dblen && fwrite(db, (size_t)dblen, 1, pf) != 1) {
warn("fwrite");
goto cleanup;
}
/* Compute size of compressed diff data */
if ((newsize = ftello(pf)) == -1)
err(1, "ftello");
if ((newsize = ftello(pf)) == -1) {
warn("ftello");
goto cleanup;
}
offtout(newsize - len, header + 16);
/* Write extra data */
if (eblen && fwrite(eb, eblen, 1, pf) != 1)
err(1, "fwrite");
if (eblen && fwrite(eb, (size_t)eblen, 1, pf) != 1) {
warn("fwrite");
goto cleanup;
}
/* Seek to the beginning, write the header, and close the file */
if (fseeko(pf, 0, SEEK_SET))
err(1, "fseeko");
if (fwrite(header, 32, 1, pf) != 1)
err(1, "fwrite(%s)", argv[3]);
if (fclose(pf))
err(1, "fclose");
if (fseeko(pf, 0, SEEK_SET)) {
warn("fseeko");
goto cleanup;
}
if (fwrite(header, 32, 1, pf) != 1) {
warn("fwrite(%s)", argv[3]);
goto cleanup;
}
if (fclose(pf)) {
warn("fclose");
pf = NULL;
goto cleanup;
}
pf = NULL;
exitstatus = 0;
cleanup:
if (pf != NULL) {
fclose(pf);
}
/* Free the memory we used */
free(db);
free(eb);
free(I);
free(V);
free(old);
free(new);
return 0;
return exitstatus;
}
+289 -162
View File
@@ -37,6 +37,8 @@ __FBSDID("$FreeBSD: src/usr.bin/bsdiff/bspatch/bspatch.c,v 1.1 2005/08/06 01:59:
#include <unistd.h>
#include <fcntl.h>
#include "bscommon.h"
/* Compatibility layer for reading either the old BSDIFF40 or the new BSDIFN40
patch formats: */
@@ -44,60 +46,63 @@ typedef void* stream_t;
typedef struct
{
stream_t (*open)(FILE*);
void (*close)(stream_t);
int (*read)(stream_t, void*, int);
stream_t (*open)(FILE*);
void (*close)(stream_t);
off_t (*read)(stream_t, void*, off_t);
} io_funcs_t;
static stream_t BSDIFF40_open(FILE *f)
{
int bzerr;
BZFILE *s;
if ((s = BZ2_bzReadOpen(&bzerr, f, 0, 0, NULL, 0)) == NULL)
errx(1, "BZ2_bzReadOpen, bz2err = %d", bzerr);
return s;
int bzerr = 0;
BZFILE *s = NULL;
if ((s = BZ2_bzReadOpen(&bzerr, f, 0, 0, NULL, 0)) == NULL) {
warnx("BZ2_bzReadOpen, bz2err = %d", bzerr);
}
return s;
}
static void BSDIFF40_close(stream_t s)
{
int bzerr;
BZ2_bzReadClose(&bzerr, (BZFILE*)s);
int bzerr;
BZ2_bzReadClose(&bzerr, (BZFILE*)s);
}
static int BSDIFF40_read(stream_t s, void *buf, int len)
static off_t BSDIFF40_read(stream_t s, void *buf, off_t len)
{
int bzerr, lenread;
lenread = BZ2_bzRead(&bzerr, (BZFILE*)s, buf, len);
if (bzerr != BZ_OK && bzerr != BZ_STREAM_END)
errx(1, "Corrupt patch\n");
return lenread;
int bzerr = 0, lenread = 0;
lenread = BZ2_bzRead(&bzerr, (BZFILE*)s, buf, (int)len);
if (bzerr != BZ_OK && bzerr != BZ_STREAM_END) {
warnx("Corrupt patch\n");
lenread = -1;
}
return lenread;
}
static io_funcs_t BSDIFF40_funcs = {
BSDIFF40_open,
BSDIFF40_close,
BSDIFF40_read
BSDIFF40_open,
BSDIFF40_close,
BSDIFF40_read
};
static stream_t BSDIFN40_open(FILE *f)
{
return f;
return f;
}
static void BSDIFN40_close(stream_t s)
static void BSDIFN40_close(stream_t __unused s)
{
}
static int BSDIFN40_read(stream_t s, void *buf, int len)
static off_t BSDIFN40_read(stream_t s, void *buf, off_t len)
{
return fread(buf, 1, len, (FILE*)s);
return (off_t)fread(buf, 1, (size_t)len, (FILE*)s);
}
static io_funcs_t BSDIFN40_funcs = {
BSDIFN40_open,
BSDIFN40_close,
BSDIFN40_read
BSDIFN40_open,
BSDIFN40_close,
BSDIFN40_read
};
@@ -107,165 +112,287 @@ typedef unsigned char u_char;
static off_t offtin(u_char *buf)
{
off_t y;
off_t y;
y=buf[7]&0x7F;
y=y*256;y+=buf[6];
y=y*256;y+=buf[5];
y=y*256;y+=buf[4];
y=y*256;y+=buf[3];
y=y*256;y+=buf[2];
y=y*256;y+=buf[1];
y=y*256;y+=buf[0];
y=buf[7]&0x7F;
y=y*256;y+=buf[6];
y=y*256;y+=buf[5];
y=y*256;y+=buf[4];
y=y*256;y+=buf[3];
y=y*256;y+=buf[2];
y=y*256;y+=buf[1];
y=y*256;y+=buf[0];
if(buf[7]&0x80) y=-y;
if(buf[7]&0x80) y=-y;
return y;
return y;
}
int bspatch(int argc,const char * const argv[])
{
FILE * f, * cpf, * dpf, * epf;
stream_t cstream, dstream, estream;
int fd;
ssize_t oldsize,newsize;
ssize_t bzctrllen,bzdatalen;
u_char header[32],buf[8];
u_char *old, *new;
off_t oldpos,newpos;
off_t ctrl[3];
off_t lenread;
off_t i;
io_funcs_t * io;
FILE * f = NULL, * cpf = NULL, * dpf = NULL, * epf = NULL;
stream_t cstream = NULL, dstream = NULL, estream = NULL;
ssize_t oldsize = 0,newsize = 0;
ssize_t bzctrllen = 0,bzdatalen = 0;
u_char header[32] = {0},buf[8] = {0};
u_char *old = NULL, *new = NULL;
off_t oldpos = 0,newpos = 0;
off_t ctrl[3] = {0};
off_t lenread = 0;
off_t i = 0;
io_funcs_t * io = NULL;
int exitstatus = -1;
if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]);
if(argc!=4) {
warnx("usage: %s oldfile newfile patchfile\n",argv[0]);
goto cleanup;
}
/* Open patch file */
if ((f = fopen(argv[3], "r")) == NULL)
err(1, "fopen(%s)", argv[3]);
/* Open patch file */
if ((f = fopen(argv[3], "r")) == NULL) {
warn("fopen(%s)", argv[3]);
goto cleanup;
}
/*
File format:
0 8 "BSDIFF40" (bzip2) or "BSDIFN40" (raw)
8 8 X
16 8 Y
24 8 sizeof(newfile)
32 X bzip2(control block)
32+X Y bzip2(diff block)
32+X+Y ??? bzip2(extra block)
with control block a set of triples (x,y,z) meaning "add x bytes
from oldfile to x bytes from the diff block; copy y bytes from the
extra block; seek forwards in oldfile by z bytes".
*/
/*
File format:
0 8 "BSDIFF40" (bzip2) or "BSDIFN40" (raw)
8 8 X
16 8 Y
24 8 sizeof(newfile)
32 X bzip2(control block)
32+X Y bzip2(diff block)
32+X+Y ??? bzip2(extra block)
with control block a set of triples (x,y,z) meaning "add x bytes
from oldfile to x bytes from the diff block; copy y bytes from the
extra block; seek forwards in oldfile by z bytes".
*/
/* Read header */
if (fread(header, 1, 32, f) < 32) {
if (feof(f))
errx(1, "Corrupt patch\n");
err(1, "fread(%s)", argv[3]);
}
/* Read header */
if (fread(header, 1, 32, f) < 32) {
if (feof(f)) {
warnx("Corrupt patch\n");
} else {
warn("fread(%s)", argv[3]);
}
goto cleanup;
}
/* Check for appropriate magic */
if (memcmp(header, "BSDIFF40", 8) == 0)
io = &BSDIFF40_funcs;
else if (memcmp(header, "BSDIFN40", 8) == 0)
io = &BSDIFN40_funcs;
else
errx(1, "Corrupt patch\n");
/* Check for appropriate magic */
if (memcmp(header, "BSDIFF40", 8) == 0)
io = &BSDIFF40_funcs;
else if (memcmp(header, "BSDIFN40", 8) == 0)
io = &BSDIFN40_funcs;
else {
warnx("Corrupt patch\n");
goto cleanup;
}
/* Read lengths from header */
bzctrllen=offtin(header+8);
bzdatalen=offtin(header+16);
newsize=offtin(header+24);
if((bzctrllen<0) || (bzdatalen<0) || (newsize<0))
errx(1,"Corrupt patch\n");
/* Read lengths from header */
bzctrllen=offtin(header+8);
bzdatalen=offtin(header+16);
newsize=offtin(header+24);
if((bzctrllen<0) || (bzdatalen<0) || (newsize<0)) {
warnx("Corrupt patch\n");
goto cleanup;
}
/* Close patch file and re-open it via libbzip2 at the right places */
if (fclose(f))
err(1, "fclose(%s)", argv[3]);
if ((cpf = fopen(argv[3], "r")) == NULL)
err(1, "fopen(%s)", argv[3]);
if (fseeko(cpf, 32, SEEK_SET))
err(1, "fseeko(%s, %lld)", argv[3],
(long long)32);
cstream = io->open(cpf);
if ((dpf = fopen(argv[3], "r")) == NULL)
err(1, "fopen(%s)", argv[3]);
if (fseeko(dpf, 32 + bzctrllen, SEEK_SET))
err(1, "fseeko(%s, %lld)", argv[3],
(long long)(32 + bzctrllen));
dstream = io->open(dpf);
if ((epf = fopen(argv[3], "r")) == NULL)
err(1, "fopen(%s)", argv[3]);
if (fseeko(epf, 32 + bzctrllen + bzdatalen, SEEK_SET))
err(1, "fseeko(%s, %lld)", argv[3],
(long long)(32 + bzctrllen + bzdatalen));
estream = io->open(epf);
/* Close patch file and re-open it via libbzip2 at the right places */
if (fclose(f)) {
warn("fclose(%s)", argv[3]);
f = NULL;
goto cleanup;
}
f = NULL;
if ((cpf = fopen(argv[3], "r")) == NULL) {
warn("fopen(%s)", argv[3]);
goto cleanup;
}
if (fseeko(cpf, 32, SEEK_SET)) {
warn("fseeko(%s, %lld)", argv[3],
(long long)32);
goto cleanup;
}
cstream = io->open(cpf);
if (cstream == NULL) {
warn("cstream open");
goto cleanup;
}
if ((dpf = fopen(argv[3], "r")) == NULL) {
warn("fopen(%s)", argv[3]);
goto cleanup;
}
if (fseeko(dpf, 32 + bzctrllen, SEEK_SET)) {
warn("fseeko(%s, %lld)", argv[3],
(long long)(32 + bzctrllen));
goto cleanup;
}
dstream = io->open(dpf);
if (dstream == NULL) {
warn("dstream open");
goto cleanup;
}
if ((epf = fopen(argv[3], "r")) == NULL) {
warn("fopen(%s)", argv[3]);
goto cleanup;
}
if (fseeko(epf, 32 + bzctrllen + bzdatalen, SEEK_SET)) {
warn("fseeko(%s, %lld)", argv[3],
(long long)(32 + bzctrllen + bzdatalen));
goto cleanup;
}
estream = io->open(epf);
if (estream == NULL) {
warn("estream open");
goto cleanup;
}
off_t size = 0;
old = readfile(argv[1], &size);
if (old == NULL) {
warn("old file: %s", argv[1]);
goto cleanup;
}
oldsize = size;
if((new=malloc((size_t)newsize+1))==NULL) {
warn("Failed to allocate memory for new");
goto cleanup;
}
if(((fd=open(argv[1],O_RDONLY,0))<0) ||
((oldsize=lseek(fd,0,SEEK_END))==-1) ||
((old=malloc(oldsize+1))==NULL) ||
(lseek(fd,0,SEEK_SET)!=0) ||
(read(fd,old,oldsize)!=oldsize) ||
(close(fd)==-1)) err(1,"%s",argv[1]);
if((new=malloc(newsize+1))==NULL) err(1,NULL);
oldpos=0;newpos=0;
while(newpos<newsize) {
/* Read control data */
for(i=0;i<=2;i++) {
lenread = io->read(cstream, buf, 8);
if (lenread < 8) {
warnx("Corrupt patch\n");
goto cleanup;
}
ctrl[i]=offtin(buf);
};
oldpos=0;newpos=0;
while(newpos<newsize) {
/* Read control data */
for(i=0;i<=2;i++) {
lenread = io->read(cstream, buf, 8);
if (lenread < 8)
errx(1, "Corrupt patch\n");
ctrl[i]=offtin(buf);
};
/* Sanity-check */
if(newpos+ctrl[0]>newsize) {
warnx("Corrupt patch\n");
goto cleanup;
}
/* Sanity-check */
if(newpos+ctrl[0]>newsize)
errx(1,"Corrupt patch\n");
/* Read diff string */
lenread = io->read(dstream, new + newpos, ctrl[0]);
if (lenread < 0 || lenread < ctrl[0]) {
warnx("Corrupt patch\n");
goto cleanup;
}
/* Read diff string */
lenread = io->read(dstream, new + newpos, ctrl[0]);
if (lenread < ctrl[0])
errx(1, "Corrupt patch\n");
/* Add old data to diff string */
for(i=0;i<ctrl[0];i++)
if((oldpos+i>=0) && (oldpos+i<oldsize))
new[newpos+i]+=old[oldpos+i];
/* Add old data to diff string */
for(i=0;i<ctrl[0];i++)
if((oldpos+i>=0) && (oldpos+i<oldsize))
new[newpos+i]+=old[oldpos+i];
/* Adjust pointers */
newpos+=ctrl[0];
oldpos+=ctrl[0];
/* Adjust pointers */
newpos+=ctrl[0];
oldpos+=ctrl[0];
/* Sanity-check */
if(newpos+ctrl[1]>newsize) {
warnx("Corrupt patch\n");
goto cleanup;
}
/* Sanity-check */
if(newpos+ctrl[1]>newsize)
errx(1,"Corrupt patch\n");
/* Read extra string */
lenread = io->read(estream, new + newpos, ctrl[1]);
if (lenread < 0 || lenread < ctrl[1]) {
warnx("Corrupt patch\n");
goto cleanup;
}
/* Read extra string */
lenread = io->read(estream, new + newpos, ctrl[1]);
if (lenread < ctrl[1])
errx(1, "Corrupt patch\n");
/* Adjust pointers */
newpos+=ctrl[1];
oldpos+=ctrl[2];
};
/* Adjust pointers */
newpos+=ctrl[1];
oldpos+=ctrl[2];
};
/* Clean up the bzip2 reads */
io->close(cstream);
cstream = NULL;
io->close(dstream);
dstream = NULL;
io->close(estream);
estream = NULL;
if (fclose(cpf) != 0) {
warn("fclose cpf(%s)", argv[3]);
cpf = NULL;
goto cleanup;
}
cpf = NULL;
if (fclose(dpf) != 0) {
warn("fclose dpf(%s)", argv[3]);
dpf = NULL;
goto cleanup;
}
dpf = NULL;
if (fclose(epf) != 0) {
warn("fclose epf(%s)", argv[3]);
epf = NULL;
goto cleanup;
}
epf = NULL;
/* Clean up the bzip2 reads */
io->close(cstream);
io->close(dstream);
io->close(estream);
if (fclose(cpf) || fclose(dpf) || fclose(epf))
err(1, "fclose(%s)", argv[3]);
/* Write the new file */
f = fopen(argv[2], "w");
if (f == NULL) {
warn("failed to write new file: %s", argv[2]);
goto cleanup;
}
if (fwrite(new, 1, (size_t)newsize, f) < (size_t)newsize) {
warn("failed to write to new file: %s", argv[2]);
goto cleanup;
}
if (fclose(f) != 0) {
warn("failed to close new file: %s", argv[2]);
f = NULL;
goto cleanup;
}
f = NULL;
exitstatus = 0;
cleanup:
free(new);
free(old);
if (f != NULL) {
fclose(f);
}
if (estream != NULL) {
io->close(estream);
}
if (epf != NULL) {
fclose(epf);
}
if (dstream != NULL) {
io->close(dstream);
}
if (dpf != NULL) {
fclose(dpf);
}
if (cstream != NULL) {
io->close(cstream);
}
if (cpf != NULL) {
fclose(cpf);
}
/* Write the new file */
if(((fd=open(argv[2],O_CREAT|O_TRUNC|O_WRONLY,0666))<0) ||
(write(fd,new,newsize)!=newsize) || (close(fd)==-1))
err(1,"%s",argv[2]);
free(new);
free(old);
return 0;
return exitstatus;
}
+1 -1
View File
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
set -e
set -o pipefail
if [ "$#" -ne 2 ]; then
+16
View File
@@ -0,0 +1,16 @@
//
// SUFileOperationConstants.h
// Sparkle
//
// Created by Mayur Pawashe on 6/5/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
extern char * const SUFileOpRemoveQuarantineCommand;
extern char * const SUFileOpCopyCommand;
extern char * const SUFileOpMoveCommand;
extern char * const SUFileOpChangeOwnerAndGroupCommand;
extern char * const SUFileOpUpdateModificationAndAccessTimeCommand;
extern char * const SUFileOpMakeDirectoryCommand;
extern char * const SUFileOpRemoveCommand;
extern char * const SUFileOpInstallCommand;
+18
View File
@@ -0,0 +1,18 @@
//
// SUFileOperationConstants.m
// Sparkle
//
// Created by Mayur Pawashe on 6/5/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import "SUFileOperationConstants.h"
char * const SUFileOpRemoveQuarantineCommand = "xattr-d-apple-quarantine";
char * const SUFileOpCopyCommand = "cp";
char * const SUFileOpMoveCommand = "mv";
char * const SUFileOpChangeOwnerAndGroupCommand = "chown";
char * const SUFileOpUpdateModificationAndAccessTimeCommand = "touch";
char * const SUFileOpMakeDirectoryCommand = "mkdir";
char * const SUFileOpRemoveCommand = "rm";
char * const SUFileOpInstallCommand = "installer";
+151
View File
@@ -0,0 +1,151 @@
//
// fileop.m
// fileop
//
// Created by Mayur Pawashe on 6/5/16.
// Copyright © 2016 Sparkle Project. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "SUFileManager.h"
#import "SUFileOperationConstants.h"
// If we fail, we exit with a unique status code
// We don't try to NSLog because the logs can't be seen anywhere,
// and we don't want to log to a file irresponsibly (especially as root),
// nor want to communicate to the parent forcing the parent to read from the stdout pipe
// (allowing us to avoid any sort of potential blocking issues?)
typedef NS_ENUM(uint8_t, SUFileOpError)
{
SUWritePIDFailure = 0x02,
SUFlushFailure = 0x03,
SUInsufficientNumberOfArguments = 0x04,
SUCommandNameUTF8ParseFailure = 0x05,
SUPathUTF8ParseFailure = 0x06,
SUQuarantineRemovalFailure = 0x07,
SUCopyFailure = 0x08,
SUMoveFailure = 0x09,
SUChangeOwnerAndGroupFailure = 0x0A,
SUTouchFailure = 0x0B,
SUMakeDirectoryFailure = 0x0C,
SURemoveFailure = 0x0D,
SUPackageFailureStatusCode = 0x0E,
SUPackageRaisedExceptionFailure = 0x0F,
SUInvalidCommandFailure = 0x10,
// This code can be OR'd with another one to produce a unique combination
SUInvalidOrNoDestination = 0x80
};
int main(int argc, const char *argv[])
{
@autoreleasepool {
// Before we do anything, we should let the parent know our pid so they can wait() on us
// We do this because AuthorizationExecuteWithPrivileges() has no way of reporting back the child pid,
// but it does give us a communication pipe
uint32_t pid = CFSwapInt32HostToLittle((uint32_t)getpid());
if (fwrite(&pid, sizeof(pid), 1, stdout) < 1) {
exit(SUWritePIDFailure);
}
if (fflush(stdout) != 0) {
exit(SUFlushFailure);
}
// At least we need the command name and file path arguments
if (argc < 3) {
exit(SUInsufficientNumberOfArguments);
}
NSString *command = [[NSString alloc] initWithUTF8String:argv[1]];
if (command == nil) {
exit(SUCommandNameUTF8ParseFailure);
}
NSString *filepath = [[NSString alloc] initWithUTF8String:argv[2]];
if (filepath == nil) {
exit(SUPathUTF8ParseFailure);
}
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
if (fileURL == nil) {
exit(SUPathUTF8ParseFailure);
}
NSURL *destinationURL = nil;
if (argc >= 4) {
NSString *destinationPath = [[NSString alloc] initWithUTF8String:argv[3]];
if (destinationPath != nil) {
destinationURL = [NSURL fileURLWithPath:destinationPath];
}
}
// This tool should be executed as root, so we should not try to authorize
SUFileManager *fileManager = [SUFileManager defaultManager];
if ([command isEqualToString:@(SUFileOpRemoveQuarantineCommand)]) {
if (![fileManager releaseItemFromQuarantineAtRootURL:fileURL error:NULL]) {
exit(SUQuarantineRemovalFailure);
}
} else if ([command isEqualToString:@(SUFileOpCopyCommand)]) {
if (destinationURL != nil) {
if (![fileManager copyItemAtURL:fileURL toURL:destinationURL error:NULL]) {
exit(SUCopyFailure);
}
} else {
exit(SUInvalidOrNoDestination | SUCopyFailure);
}
} else if ([command isEqualToString:@(SUFileOpMoveCommand)]) {
if (destinationURL != nil) {
if (![fileManager moveItemAtURL:fileURL toURL:destinationURL error:NULL]) {
exit(SUMoveFailure);
}
} else {
exit(SUInvalidOrNoDestination | SUMoveFailure);
}
} else if ([command isEqualToString:@(SUFileOpChangeOwnerAndGroupCommand)]) {
if (destinationURL != nil) {
if (![fileManager changeOwnerAndGroupOfItemAtRootURL:fileURL toMatchURL:destinationURL error:NULL]) {
exit(SUChangeOwnerAndGroupFailure);
}
} else {
exit(SUInvalidOrNoDestination | SUChangeOwnerAndGroupFailure);
}
} else if ([command isEqualToString:@(SUFileOpUpdateModificationAndAccessTimeCommand)]) {
if (![fileManager updateModificationAndAccessTimeOfItemAtURL:fileURL error:NULL]) {
exit(SUTouchFailure);
}
} else if ([command isEqualToString:@(SUFileOpMakeDirectoryCommand)]) {
if (![fileManager makeDirectoryAtURL:fileURL error:NULL]) {
exit(SUMakeDirectoryFailure);
}
} else if ([command isEqualToString:@(SUFileOpRemoveCommand)]) {
if (![fileManager removeItemAtURL:fileURL error:NULL]) {
exit(SURemoveFailure);
}
} else if ([command isEqualToString:@(SUFileOpInstallCommand)]) {
// The one command that can *only* be run as the root user
NSString *installerPath = @"/usr/sbin/installer";
NSTask *task = [[NSTask alloc] init];
task.launchPath = installerPath;
task.arguments = @[@"-pkg", filepath, @"-target", @"/"];
// Output won't show up anyway, so we may as well ignore it
task.standardError = [NSPipe pipe];
task.standardOutput = [NSPipe pipe];
@try {
[task launch];
[task waitUntilExit];
if (task.terminationStatus != EXIT_SUCCESS) {
exit(SUPackageFailureStatusCode);
}
} @catch (NSException *) {
exit(SUPackageRaisedExceptionFailure);
}
} else {
exit(SUInvalidCommandFailure);
}
return EXIT_SUCCESS;
}
}