Use a different app cache directory if bundle ID ends with ".app" so that the cache directory Sparkle writes into does not look like an app bundle and cause other systematic issues. This can occur if a developer uses an ill-formed bundle identifier rather than conventional reverse-DNS one.
Changes include:
- 'corriendo' -> 'ejecutando'
- '¿Quisieras' -> '¿Querrías' (two strings)
- add accent in 'sólo' (read-only)
- 'Ready to Install' translation adjusted to feminine 'Lista para instalarse'
- 'póngase en contacto' -> 'ponte en contacto'. No English source keys were modified.
When the update alert was recently re-designed (along with Tahoe support) it was decided not to show a window title, however we can still set a window title that is hidden for accessibility / discoverability reasons.
Fix: call completionHandler before probe to prevent race with installer messages
sendInstallationData kicks off the installer process, but completionHandler
was deferred until the probe callback fired. Installer messages like
SPUExtractionStarted could arrive on the main queue in the gap, triggering
installerDidStartExtracting -> clearDownloadedUpdate before the caller set
_downloadedUpdateForRemoval. A subsequent clearDownloadedUpdate (e.g. from
installerDidFailToApplyDeltaUpdate) then found both ivars nil and hit the
assertion.
The probe result is only logged, so completing before the probe is safe.
In most scenarios, they were skipped because INSTALL_PATH is unset.
In XQuartz, we build Sparkle using `xcodebuild install INSTALL_PATH=...`,
so these XPCServices would get installed into the frameworks path of our
app bundle. This change fixes that by explicitly setting SKIP_INSTALL.
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
A developer can set ARCHS to arm64 only if they want to exclude Intel, or add arm64e if they want to build for arm64e.
The ARCHS_COMMAND_LINE_TOOLS (for BinaryDelta, generate_appcast, sign_update) should however not include arm64e yet (as SPM dependencies aren't happy with that).
* Change desired with to Automatic
* Increase content compression resistance priority to required (1000)
This matches the sizing layout of the status text next to the action button.
We don't force pretty print when writing new XML data now when we insert a signing warning. This may mean the signing warning prefix may start on the same line as the first XML element, but I think this is alright since the rest of the warning starts on its own line.
If Sparkle.framework isn't in Contents/Frameworks/ then we do a deep scan in the app bundle (but ignore Contents/Resources/). Sparkle may be placed in a plug-in or other parent framework.
Also remove legacy SparkleCore lookup which is no longer needed.
This strips the beginning sparkle sign warning comment (if present) in the release notes downloader driver rather than the user driver. The comment is also stripped (if present) in generate_appcast when inserting embedded release notes.
Also improve markdown compatibility with sparkle-cli and alternative user driver in Sparkle Test App.
This provides enhanced opt-in security preventing informational attacks that for example suggest the user the auto-updater is broken and an update needs to be installed from a compromised website (assuming the developer's website is hijacked).
To opt in, developers need to add SURequireSignedFeed Info.plist key to their bundle.
generate_appcast and sign_update have been updated to support signing appcast feeds and release note files (both need to be signed). By default, they embed a HTML comment warning in the files that further modifications will invalidate previously signed signatures. Signed appcasts include a signing block comment at the end of the XML file describing the signature of the content preceding it. Signed release notes will have their signatures annotated in the <sparkle:releaseNotesLink> element with a sparkle:edSignature attribute (and optionally a sparkle:length attribute for diagnostic purposes).
A signingValidationStatus property is also now added to SUAppcast and SUAppcastItem indicating the signing status (skipped, succeeded, failed).
The standard user driver's release notes HTML web view rejects external file references when appcasts are signed. A bug has also been fixed where the update alert would not provide errors when loading external release note files fails. These changes also introduce a showing new error / localizable strings when the release notes is not signed correctly or fails to load.
As a hardening policy, we also enforce SUVerifyUpdateBeforeExtraction when opting into signed feeds, so key rotation is only possible with Developer ID code signed dmg archives.
A fallback feed signing failure expiration policy has also been added. When a signed feed has failed validation for more than a configurable period of time (by default SUSignedFeedFailureExpirationInterval is set to 20 days), Sparkle will allow appcast items to be shown to the user. However, these items operate in a safe mode that strip abusable information like release notes / descriptions / links, sanitize the version strings, and they cannot be marked critical or informational, nor be installed automatically. After this policy expires, this allows users installing updates as long as the updates are signed correctly, or be aware that the updater has not been functioning correctly.
Fixes#971.
* Supports Markdown ordered/unordered lists, paragraphs, headers, code blocks, inline styling. Block quotes and thematic breaks are handled in simple manner through indentation and extra newline respectively. Tables are not supported. HTML isn't supported.
* Requires macOS 12 or later due to leveraging Foundation / presentation intents for markdown processing. Older OS's and older Sparkle versions >= 2.4.0 will fall back to plain-text interpretation. Additionally, TextKit 2 is now adopted for macOS 12+, and TextKit 1 only code is to be avoided.
* Adds delegate method to allow formatting / modifying the presented text before it will be shown for plain-text and markdown release notes. This, for example, can be used to adapting release notes based on currently installed version, but it could also open up styling release notes in other ways.
* Adds sparkle:format="markdown" option to <description> element for embedded release notes (in addition to already existingsparkle:format="plain-text" option)
* Adds support for generate_appcast to handle markdown release note files and embedded release notes.
* Adds a MARKDOWN test mode to Sparkle Test App.
This allows specifying a minimum version the host bundle needs to be on before upgrading. This may be useful for new appcast features where this requirement can be used instead of switching to a new appcast.
This allows us to determine if automatic downloading/installing of updates option (typically a checkbox) should be enabled or not. This property is based on whether or not automatically checking of updates is enabled, or the SUAllowsAutomaticUpdates option (if specified by developer for custom needs).
The update alert now updates hiding/unhiding the automatic downloading checkbox if the automatic update checking option changes.
The test application is now updated to use -[SPUUpdater allowsAutomaticUpdates] for enabling/disabling the automatic downloads update checkbox.
The Sparkle Test App will opt into a private setting that changes some of the default and minimum values for Debug builds.
This also removes the "WARNING: This is running a Debug build of Sparkle 2; don't use this in production!" log in Debug builds, and removes some unused constants internal to Sparkle.
This is the update check interval used after an update has been downloaded/staged to be installed automatically in the background. By default this is 1 week (in seconds) but this change now allows it to be configured.
The first requirement we support is arm64 which allows updates to mark themselves as Apple silicon only.
The message that shows up when users check for updates tells them their Mac is too old and a newer Apple silicon Mac is required for new updates. This introduces a new localizable string.
This requirement is also inferred if the minimum system version is >= 27.0
generate_appcast is also updated to handle a new branch for hardwareRequirements element, and for automatically populating it if needed.
Fixes#2796
Overriding KeepAlive before actually implies RunAtLoad is true but we were setting RunAtLoad to false which is conflicting. In any case we don't want to restart the job if it crashes, and we want to run Updater when the job is loaded.
These warnings are logged after failing to connect to XPC and launchd helpers and indicate the helpers likely did not launch at all.
This error happens when developers incorrectly copy Sparkle framework not preserving executable permissions, and is sadly somewhat common.
The localizations for this are stale now, but I don't consider it a huge issue as ideally this message should not occur in production (unless the user corrupted an app or developer didn't test their app).
Not all references are removed, just minimal changes are made for now. This installer type has been deprecated for a while and now it's time to act on removing it. It's not a well tested path and not a path we want to support going forward.
* For the Installer and Downloader XPC Services, if these executables are code signed with an Apple issued Team ID, then the connecting client must also be code signed with a matching Team ID.
* For the Downloader XPC Service, the request URL must be http/https
* For Autoupdate, if stage 1 of installation hasn't been completed yet and this executable is code signed with an Apple issued Team ID, then the connecting client must also be code signed with a matching Team ID. As before, multiple simultaneous connections are still disallowed.
* For Autoupdate, if it's not signed with Apple issued certificate, when installing package updates the bundle being updated must be itself and owned by root on disk (as one expects from a PKG installation)
* The authorization prompt message in the Installer Service is more computed inside the service so the client can't pass a completely arbitrary message
* Add extra nullable checking of parameters coming from XPC endpoints
* Add more thread-safe synchronization for Autoupdate installer
* Add logs for more failure points
This changes the UI for the update alert to have the app icon be more stacked / inlined with the UI, refines the box view for release notes, and removes some title labels that aren't strictly needed. For Tahoe, we opt into using large size buttons which get a capsule shape.
Also this changes adds a new app icon, which is squircle shaped, for the Sparkle test when running on Tahoe.
The old logic had some inconsistencies with picking the right icon on Tahoe. Using NSImageNameApplicationIcon should also work when the color style of the icon changes in System Settings.
Remove trailing constraint from automatically download & install updates checkbox. This caused an issue that prevented the window from being resized smaller (so the window could only grow bigger).
Remove redundant >= width constraint on Remind Me Later button since Install Update button already had such a constraint.
* Port bsdiff optimizations for diffing large blocks that only differ by less than 8 bytes
* Retrigger CI
* Bump the minor version for major 2, 3, and 4
* Comments for ChromiumOS ported commits
The release workflow on GitHub uploads files that match "Sparkle-*" which apparently now includes sparkle-dist.tar.xz even though it's not capitalized. Rename the file to sparkle_dist to work around this.
Adds an opt-in option (SUVerifyUpdateBeforeExtraction) to enforce verifying updates before extracting them for stronger security. EdDSA signing is required to use this option. As fallback in case EdDSA keys are lost, disk image archives's code signatures are validated assuming it's Developer ID signed. Key rotation is still possible.
Apple Archives (aar, yaa) now require using this option.
* Don't allow removal of (Ed)DSA keys for pre-validated updates (delta updates, .aar updates)
* Don't allow removal of code signing identity in new update (at minimum, an adhoc signature can be used)
This will preserve the file creation date of the new app bundle, but not the file creation date of any of the files inside the new app bundle because tracking those changes is complex/undesirable.
This bumps the major binary delta version to 4. A new test has been added for testing that the new bundle creation date is also preserved.
* Handle failing to extract password protected disk images even when a decryption password isn't provided.
* Propagate error with more information when hdiutil attach fails.
* Wait for detaching disk images for unit tests (fixes not being able to run tests repeatably).
The delegate method is not called if SUEnableAutomaticChecks is specified in the Info.plist (now) or if the user has responded to a permission prompt request.
Also fixes a respondsToSelector check in legacy SUUpdater adaptor (fixes#2618).
Check `man aa` and https://developer.apple.com/documentation/applearchive for more details. This is an efficient Apple custom archive format available since versions of macOS 10.15.
In macOS 10.15, this utility used to be called yaa.
Make sure we don't perform a background update check when a user update check was initiated. This may have regressed from #2295.
Also replaces an assert with an error log if the _driver already exists.
Fixes#2560
This restores how the code used to work in 2.6.0 except we don't create a link to the archive file, and remove the temp directory before starting. I had removed too much of the prior code in 2.6.1 which included creating the extraction directory in generate_appcast.
adaptReleaseNotesAppearance was over-engineered to update the transparent background state of the web view (which was causing the issue) and the background NSBox view when the system changes to dark or light mode. This is because when dark mode support was originally written, it used to use a stylesheet that was only specific to dark aqua. However this code has changed some time ago to use a universal stylesheet for both light/dark mode.
So now when the WebKit view is created, we just opt into a transparent background and set up a background NSBox view once and don't do anything when the effectiveAppearance of the views change. This fixes visual issues on current and older OS systems when changing system appearance.
SULocalizedStringFromTableInBundle() should only fail in the abnormal situation where the app bundle may have been moved while it was running. Technically the app is running in an unsupported state but I suppose we can guard against it here.
These entitlements are not easy to configure properly and most developers should not be using these services.
Also simplify how to opt into enabling sandboxing entitlements for the Downloader XPC Service.
This avoids users being a "Verifying..." Dialog when the installed update is (re-)launched.
This scan is only done for macOS 14.4+ onwards (gktool was introduced in macOS 14.0 but had issues).
Also this scan is only done if Autoupdate's team identifier matches the new update's team identifier. Otherwise the OS may think Autoupdate is modifying a bundle which it shouldn't be permitted to (this is a bug).
If we detect the wrong archive is being served (i.e, expected content length differs from archive length) we log this out to developers. If the app version in the archive (if available) also differs, we report this discrepancy as well. If the update archive looks the same but signing validation fails, we tell the developer the update may have not been signed correctly.
I'm not changing the generic error that is reported to users about the update being improperly signed (that would involve propagating this information there and updating bunch of localizations). The extra info is more for the developer than it is for the user.
Fixes#2468
* Update `actions/checkout` and `actions/upload-artifact`
This removes the warning about the deprecated `node12` runtime used by existing actions.
* Update `mshick/add-pr-comment`
The v2 action uses `node16` runtime
Workflow will use the `GITHUB_TOKEN` with `pull-requests: write` permission instead of PAT
This only applies when multiple XML nodes are present with the same name. E.g. multiple description or releaseNoteLink elements with different xml:lang's specified.
Also generate a warning if an language has to be interpreted implicitly when there is no xml:lang explicitly specified and there are multiple node items.
This may occur for example when you run sparkle-cli as root or use Sparkle.framework in a root process. This is not typically a common use case, but could be used from daemons.
The issue is that Sonoma doesn't like starting our Updater app in the user domain when intermediate directories containing it are root owned (due to lack of file permission access that wasn't present in Ventura). So now we try to create intermediate directories in the standard user's home directory.
For some reason, the default BUILDDIR that was set was problematic. We are now defaulting BUILDDIR inside of ./build which resolves this issue. This also means by default, builds are not placed inside of system temp directories anymore.
I do not know when this stopped working or why.
Move a lot of the installation work to be done during the first phase of installation (when possible), before the target app needs to be terminated. For the common case where the old and new bundles are on the same volume, the final phase of installation requiring a restart is now just an atomic swap.
Also move the termination listener to the agent app which resolves some launch/CI failures we've been seeing.
KVO was not set up properly when trying to retrieve the updater from the updater controller, especially when the updater controller hasn't been fully initialized yet.
Minimum OS preprocessor checks should only be used when compiler may generate compile warnings for deprecated APIs when the deployment target is raised.
This also allows embedded release notes to be plain text using sparkle:format="plain-text" attribute.
Also, Catalyst apps only support plain text release notes (compared to before where release notes weren't supported for Catalyst apps).
* Add deprecations/warnings for incorrect feed & update checking usage
This change deprecates -[SPUUpdater setFeedURL:] and logs warnings when the updater detects that feed URLs from user defaults are still being used.
This change also logs a warning when checkForUpdatesInBackground is used incorrectly if Sparkle is configured to ask the user's permission to check for updates but a check is done when automatic update checking is NO.
This change adjusts the layout constraints between the title and message text to be more proper.
This issue is only noticeable in Russian, Spanish, Ukrainian, and Slovenian on my machine.
Issue has been present in Sparkle 1 as well.
By default, if the SUAllowsAutomaticUpdates Info.plist key is not specified, the update alert option to allow automatic downloading/installing of updates will only be shown if automatic checking of updates is enabled. However, the developer can now override this by setting SUAllowsAutomaticUpdates to true in Info.plist which indicates the option should be available even if automatic checking of updates is not enabled.
If the app termination request is delayed or canceled, the user can check for updates again with the standard user driver and try installing/relaunching again, which will trigger the installer to send another quit event to the running application.
Before the install/relaunch window would close but the check for updates option would still be present but not functional.
In the installer progress agent, when we find all potential running applications for a host bundle, we should also consider any translocated running apps that look-alike the host bundle.
This matters when updating external bundles. For example if sparkle-cli tries to update an app on disk in ~/Downloads/ but a running instance of the app is translocated, sparkle-cli should terminate the translocated instance of the app before installing the update.
It's possible this could generate a false positive but we err on the side of safety here. We only use running translocated apps if we find no regular matching apps.
We fix the validation check for using the output option when multiple feeds are present, fix not generating new feeds when no prior feed is available, and fix incorrect logic with cleaning up delta files when multiple feeds are present.
Document --versions in generate_appcast better and add comments to explain why certain policies were made.
Add separate option to automatically pruned old update files. Now we only automatically move old update files aside. If the user passes --auto-prune-update-files we will also remove the old update files automatically.
Move old release notes files too.
Don't make old-updates directory hidden.
We preserve a batch of updates for each branch point (defined by an update's {majorVersion, minSystemVersion, maxSystemVersion, channel}). The latest for each branch point is used for generating delta updates.
We prune older update items that are no longer needed in the feed or needed for generating delta updates from newer items. We move pruned update files into a separate hidden directory, which is later garbage collected after a couple weeks based on each file's last modification date.
To insert new update items that are older than the latest update in the feed, --version flag needs to be used.
The overall goal is to have the feed only keep a small window of updates to serve to the user. This will also ease future processing generate_appcast needs to do and ensure the cache's directory doesn't blow up by pruning old updates.
Wait for appcast item registration before finishing automatic update driver.
This fixes a potential race issue where sometimes the automatic update driver on completion would sometimes not trigger to prompt an update alert immediately for critical updates. Note in this case, the update would still be installed on app termination and would still be scheduled to alert the user on the regular update check interval, so this issue is not severe.
* Set layout constraint constant between buttons and description to 20
* Disable update alert resizing when no release notes are available
* Fix layout constraint warning
* Set alert autosave frame name only when release notes are shown
The one exception is an updater that is targeted to update another / non-main bundle.
Note we still allow configuration of not using DSA or EdDSA with the deprecation warning in tact.
We fix one memory leak when calculating sha's, one memory leak in the xar delta applying path, and avoid creating Bundles for reading the Sparkle framework version.
There are some other small leaks with the xar delta creation/applying code but since it's a legacy implementation and the APIs are undocumented I don't want to touch it too much.
The biggest culprit here is the leak when calculating sha's I believe, if you have many archive items.
Reset opportune time for showing update notice when updater starts as well.
Also update updater header API documentation and add private protocol for gentle scheduled reminder APIs that the updater uses.
On macOS 13 (Ventura) and later, installation could fail if Gatekeeper blocks app modifications. Note this is only applicable for external updaters like sparkle-cli where the updater and target bundle to update have different team identifiers.
We set the status window's collection behavior to full screen auxiliary. This is how the collection behavior for the update alerts and permission prompts are set up, but we never applied it to the status window.
With this change, bringing the status window up front (e.g, for downloading an update) does not push the other app's windows back into the stage manager tiles.
In the UI driver, this is when the user chooses to Install & Relaunch.
In the automatic download based driver, this is when Sparkle hands off responsibility to its delegate to install the update and they trigger the callback to relaunch the app.
Even if the updater is set to not automatically check for updates.
This fixes a bug where an update cycle may not complete if the automatic update driver first started, and the update should have been resumed but automatic update checks were disabled by the developer.
The developer would have had to disable automatic update checks, check updates in the background themselves, have updates set to download automatically/silently, and be in a situation where the update would be deferred to non-silent update (for example, user requiring authorization to install, critical update being presented, info-only update being presented).
* Log warning if gentle reminders aren't implemented for background app
* Don't let background running app steal focus from other apps except at launch
* Don't set update alert window level to floating for background apps
* Show update alert in back for currently active background apps
* Disable warnings for direct ivar access
* Center update status window to last update alert window shown
* Activate app from user initiated checks if it's not active
* Set systemHasBeenIdle to YES only if the app isn't preventing display sleep
* Don't make status window key if update alert wasn't key window
Don't allow status window to be minimizable for non-app bundle updates due to atomicity concerns.
Add delegate method to allow developer to configure if they want the status window to be minimizable.
We wait until a more opportune time when the app becomes re-activated, but if too much time has passed we will show the update anyway. A few exceptions are:
* App just launched
* User has been idle on their machine
* User initiates update check themselves
When the framework or sparkle-cli is run as root, we always launch the installer (Autoupdate) in the system domain.
For the progress tool agent, we chown() the copied Updater.app so the Updater app has proper ownership of it (and clean it up later). The progress tool app may not be able to clean up the parent directory, but that's okay and will be garbage collected on a later run.
To get the username and home directory for the user session when running the framework as root, we use the SecurityConfiguration framework. Sparkle needs and depends on an active GUI user login session. If a user ssh's in to install an update, that user must be the same as the active logged in user.
Installing interactive based package updates as root is not supported. For sparkle-cli, we disallow using --interactive when running as root.
An additional error exit code is added for sparkle-cli when ran as root and trying to install a interactive based package update, which is unsupported.
Also log out the download failure when a delta update fails to download (such as a 404 error for example).
Additionally, add a check to make sure that top-level appcast items cannot be delta update items.
* Use UniformTypeIdentifiers framework to replace deprecated types
kUTType* constants are deprecated since macOS 12. The UniformTypeIdentifiers framework is available since the macOS 11 SDK.
* Replace renamed constants
* Use API_AVAILABLE macro instead of __OSX_AVAILABLE
We don't support applying delta updates on these systems (due to lack of permission support), so we shouldn't even try downloading delta updates in this case.
For creation, we will disallow creating delta updates if a custom resource fork icon data is found in either the old or app bundles.
For applying, we will just ignore the icon data when performing hash verification and continue applying the patch.
* Remove duplicate localization identifiers
Some localizations have multiple identifiers, e.g. Canadian French has "fr-CA", "fr_ca" and "fr_CA" and Norwegian Bokmål has "nb" and "no" (though "no" can include Norwegian Nynorsk, Xcode seems to treat it as Bokmål and therefore a duplicate of "nb"). This commit removes superfluous identifiers and keeps the identifier that Xcode uses by default.
This also removes the no.lproj/ directory which contains either obsolete localized strings or strings that are present in nb.lproj/ too.
Furthermore, this renames the .lproj/ directories for "pt_PT"/"pt_BR" to "pt-PT"/"pt-BR" since the latter identifiers are the default in Xcode.
* Update localizable strings to match the current localizations
Replaces the following characters in the localizable strings:
- ellipses (... → …)
- curly apostrophe (' → ’)
- em dashes (-- → —)
- non-breaking spaces
These were already used in the .strings files.
* Regenerate Sparkle.strings
This applies the changes in the previous commit to the strings files of the base localization.
This also removes the following strings, which are no longer present in the source:
- "%1$@ wants permission to update %2$@."
- "%1$@ wants permission to update."
- "An error occurred while downloading the update feed."
- "An error occurred while installing the update. Please try again later."
- "An error occurred while relaunching %1$@, but the new version will be available next time you run %1$@."
- "Are you sure you want to skip this upgrade?"
- "Don't Skip"
- "Skip Upgrade"
- "The update is improperly signed."
- "You already have the newest version of %@."
- "B", "GB", "KB" and "MB"
* Update localized Sparkle.strings
This applies the changes in the previous commits to the strings files of the localizations.
* Re-import localizations
This updates the .strings files using xcodebuild to:
- remove obsolete localizable strings,
- incorporate (changed) localization comments and
- replace UTF-16 encoded .strings files with UTF-8.
* Update Dutch localization
* Update French localization
This replaces single quotes and spaces with apostrophes and non-breaking spaces.
Sparkle currently requires at least Xcode 12 (or the macOS 11 SDK), therefore fallbacks for older versions are no longer needed.
* Remove +isOperatingSystemAtLeastVersion: method
* Remove +operatingSystemVersion accessor method
* Remove SUTouchBarForwardDeclarations header
* Don't activate app when bringing up update alert errors
* Don't set status window level to floating
* Make status window minimize-able after checking for updates
* Allow install button to have focus when app has just launched
* Reset install button focus when app becomes active again
They should not be bundle IDs because they may surface up in the UI.
Particularly, the Installer XPC Service may show up in the authorization prompt when authorization is required to install an update.
The update code uses the compareFiles function to determine the sort order of file names in a directory, which is then compared with a list of files in the Sparkle update info. If the list of files of a directory from Sparkle's update is different than what is on disk, the Sparkle abandons the update and does a full download. This bug would prevent Sparkle from updating properly when the file lists are calculated on an English language system, but then checked on a destination Japanese system.
The fix is to use strcoll_l(), which is locale-independent, when comparing file names for sorting. This will ignore any locale changes the host application has made that could potentially affect Sparkle's sort order.
Normally when a major upgrade is skipped, subsequent updates for that major release are skipped. This element however allows publishing updates that ignore the user skipping the major version before a specific sub-release.
This allows marking all updates below a specific version as informational only.
A new element (sparkle:belowVersion) was introduced this over a new attribute for sparkle:version due to compatibility reasons.
This allows marking all updates below a specific version as informational only.
A new element (sparkle:belowVersion) was introduced this over a new attribute for sparkle:version due to compatibility reasons.
In generate_appcast we:
* Validate code signing integrity of new updates
* Add hidden flag to disable checking for nested code during validation
* Warn if new and old apps have differing signing identities when generating deltas
Accounts are intended to be used for when working on products that belong to different organizations. This way multiple keys related to Sparkle can be stored in the keychain.
We also add a --verify option to sign_update which allows verifying that updates are signed correctly.
* Only track 0755 permissions for symbolic links
Also warn the user when encountering symbolic links that have a non-standard permission mode.
* Warn users when bad or irregular permissions are encountered
We have one heuristic for when a .framework version changes, and another for when a file with the same name moves to another location.
To support this, we added a clone + binary diff command.
Also document and improve the format.
This new format introduces:
* A new container format which stores metadata in a way that is more efficient for compression, decompression, and size. Creation time can be 2x faster, apply time can be a few seconds faster, size savings can be 500 KB - couple of MB due to metadata alone.
* An array of supported compression formats including lzma, bzip2, zlib and more. We now default to lzma which is as competitive as bzip2 (which we were using in version 2 format) in applying/creation times, but can save several MB on size.
* Tracking of files from an old app being replicated in different locations in the new app. This can track unchanged files being renamed and can result in significant savings if the files are large.
Version 2 format is still the default. To use version 3, pass --version=3 to BinaryDelta when creating a patch. We will switch the default to version 3 later. generate_appcast support is upcoming.
For development we should include task-get-allow entitlements. For distribution if people use custom workflows, they need to properly re-sign the app without preserving this entitlement
When we don't have any information for existing items, we have been appending new items below the existing ones. We should insert new items such that new items are inserted in order of version descending.
This removes the com.apple.security.get-task-allow entitlement on helper executable tools and XPC Services. While this is not a big deal, I don't think we should distribute executables with this entitlement which allows debugging them (with SIP / hardened runtime on). Note notarization ought to reject this entitlement with library validation enabled, so people must be getting around this anyway (either by using Xcode's Archive / Export which automatically strips this entitlement, or re-signing Sparkle tools without preserving entitlements).
* Make canCheckForUpdates property KVO compliant/observable
Also set updater session in progress when probing for update check interval to use.
* Add assert that driver must be nil in checkForUpdatesWithDriver:..
* Fix init'ing updater delegates in standard updater controller in nibs
* Convert updaterDelegate/userDriverDelegate properties to ivars
This should allow connecting outlets in IB while disallowing setting them programmatically.
* Update author to Sparkle Project when generating documentation
* Sync change log from 1.27.0
* Add recommendation to not call checkForUpdatesInBackground directly
* Add testing documentation for latsUpdateCheckDate
* Fix formatting with user driver header documentation
This fixes a minor bug where canCheckForUpdates returned NO on a user initiated update check that shows an update that was already downloaded / begun installing. Now that it returns YES, the update can be shown in utmost focus by the user again.
This bot has owner access to the repo and should be able to push changes to protected branches, as long as the workflows are being ran from trusted branches / remotes.
Also extract changelog and use it for the draft.
The workflow assumes changelog and version information have been updated and the tag has not been created yet before running it. When the workflow finishes, it should take you to a release page with the uploaded binaries, where you can verify the final details and publish a tag officially.
Also the following improvements were made:
* Change CURRENT_PROJECT_VERSION to represent a monotonically increasing bundle version (starting at 2000)
* Add MARKETING_VERSION to represent marketing version of Sparkle, comprised of SPARKLE_VERSION_MAJOR, SPARKLE_VERSION_MINOR, SPARKLE_VERSION_PATCH, and the new SPARKLE_VERSION_SUFFIX for pre-releases.
* Verify code signing signatures of extracted SPM zip file in make release and CI
* Generate changes to Sparkle podspec, just like the Package.swift file, based on current marketing version
* Improve format of Info.plist version strings when appending git hash info, eliminating unnecessary whitespace
* Simplify validating that XPC Service versions align with framework version
* Handle lightweight tags in addition to annotated tags in release-move-tag.sh
* Don't expose SPUDownloadData initializer publicly
* Make SUAppcast -init unavailable
* Fix documented default user agent string
* Improve header documentation for SUAppcast(Item) and comparators
* Update more API documentation headers
Also allow returning nil in -allowedSystemProfileKeysForUpdater:
* Clarify documentation on -allowedSystemProfileKeysForUpdater:
* Rename willIdleScheduling -> notSchedule for delegate method
* Make minor correctness fix for reading info URL
Add generate_appcast options for appcast selection features
We can now supply for new update items:
* Link
* Channel name
* Last major version / minimum autoupdate version
* Phased rollout interval
* Last critical update version
* Originating informational update versions
We can also specify the maximum number of delta items to generate.
Lastly we can specify which versions to create new items for now. This allows applying flags for only specific versions, or for exceptional cases allows adding old versions that do not meet the most recent updates threshold (maxNewVersionsInFeed) -- think for updates for a prior OS or for a prior major version.
We do not override the minimum system version element on already existing items now, if the element already exists. Apps don't strictly need to specify LSMinimumSystemVersion and this allows users specifying it themselves in the feed.
The help page for generate_appcast was expanded with how the archive directory looks like, how release notes work, that old entries are kept in tact, and how extracted archives are cached..
We now write out the number of new updates written and the number of existing items updated, to make the generated result be less confusing.
Bug fixes:
* The scheme now builds for Debug so I can properly debug generate_appcast from within Xcode (distribution builds are still in Release)
* Newly generated items were appended at the end of the appcast and not necessarily inserted in the correct order (on top). As a workaround when we process existing items, we remove them, and re-add them.
* Fixed an off-by-one error for maximum number of delta files we can generate.
Fixes#1903
It doesn't make much sense to call this method programmatically due to it checking a specific selector. A client should set the menu item's target/action to the controller/checkForUpdates: action or call SPUUpdater methods directly.
* Update changelog for Sparkle 2
* Add more updates about appcast elements/attributes
* Clarify bestValidUpdateInAppcast method is discouraged for some cases
* Re-order changelog bullets
* Use https:// in sample links
* Don't ignore -Wcompletion-handler if compiler doesn't understand it
Older Xcode versions threw a warning at not recognizing this warning.
* Silence WKWebView warning too
If EdDSA verification passes we don't need to have DSA verification pass, and don't need to require the new update to contain a DSA signature or keys.
Also reject updates if app has EdDSA but no EdDSA signature is provided
Set $USER and $HOME variables when running guided pkg installers
This allows pre/post install scripts to reference the user's environment correctly. The standard pkg installer GUI preserves these two variables.
* Allow delegate to pick no valid items
We now allow returning SUAppcastItem.emptyAppcastItem in -bestValidUpdateInAppcast:forUpdater: to indicate no update should be picked.
We preserve returning nil to indicate Sparkle handles the best appcast selection instead.
People have expressed needs for both of these decisions (and deprecated SUUpdater relies on the nil behavior).
This allows developers to post updates to specific channels like for beta updates. Updaters only get notifications from channels they're allowed to be on.
We should recommend using sparkle:version and sparkle:shortVersionString elements inside the appcast item instead of inside the enclosure for consistency.
Delta updates do not need to specify sparkle:version, and can inherit the top level element. This clears up some confusion and reduces duplication (and reduces error proneness / saves me work when testing delta / info-only features).
This is also consistent with informational updates. Regardless whether you want to make an update informational only or not, the sparkle:version stays in the same top-level place.
This is a backwards compatible change. Very old versions of Sparkle (possibly up to a decade or more ago) have supported specifying sparkle:version as a top level item. Winsparkle supports it as well because it's needed for info-only updates.
This is only changing what we recommend / standardize. The attribute variants are still usable.
External tools relying on Sparkle's feed format may have to adapt to this standardization (they have always needed to support info-only updates with a missing enclosure which apps do leverage anyway).
I updated generate_appcast to prefer the element variants and updated the tool so it understands them (this was a bug).
When user is on version >= latest appcast feed item, we give them an option to view version history.
When user can't update because of a min/max OS requirement, we give them an option to view product's website.
* Make updater/userDriver properties non-null
* Expose starting the updater and allowing it to be done later instead of at instantiation (so clients in some cases will not need to make their controller declared as an optional)
* Make sender in checkForUpdates: nullable
Example:
<sparkle:informationalUpdate>
<sparkle:version>1.5.0</sparkle:version>
<sparkle:version>1.5.1</sparkle:version>
</sparkle:informationalUpdate>
Means that updating only from versions 1.5.0 and 1.5.1 are shown an informational update (provided there is an info link).
<sparkle:informationalUpdate></sparkle:informationalUpdate>
Means that updating from any version gets an informational update (provided there is an info link).
No presence of this new element falls back to current behavior in Sparkle where an informational update is shown if an enclosure is missing but an info link is provided.
In some cases for shared headers in downloader XPC Service or generate_appcast / sign_update tools, I had to do a little dance for using double quote imports.
This version indicates the version that was first marked critical. So versions below this specified version will treat the update as critical while versions >= the specified version will not.
Also move sparkle:criticalUpdate to root level element instead of it being a tag. The tagged version is now deprecated and doesn't support the version field.
We unify the user driver method showing the update to take a generic state object now. The current fields of the state object are its current stage, if it's user initiated, and if the update is a major one.
We also remove deprecated code paths that were complex to support and will otherwise generate in compile errors if people adopt the new API.
* Prefer using the latest update that passes minimumAutoupdateVersion
When an update is not found:
* Find latest appcast item that may fail min/max OS
* Report that user cannot install an update due to unsupported OS
We should enforce update session is in progress before checking for new updates. I've tested checking for updates regularly, in background, and informational updates.
An update check could have been made while the permission request was in flight, which we don't want to happen.
The message string gets cached and I don't think this is the proper way to localize the auth dialog (which I think has some other mechanism). So I am removing localization here for now until this can possibly be done properly.
All the top level appcast items are non-delta items. The client needs to give us back a non-delta update item. We then fetch the appropriate delta item ourselves.
We don't have a dismiss method for every transition state and we don't want to. This should be up to the UI to determine how to transition from one UI state to another UI state.
When the update is shown to the user, the menu item for checking for updates is no longer disabled. Instead it is enabled, and when invoked, will bring the update to utmost focus back to the user again.
This is consistent with other options (eg Preferences...) that bring up windows. Improved user experience here is that updates are now less "lost".
We (re)define properties on SPUUpdater:
canCheckForUpdates - to mean that the user can check for updates (start a new update check or show the already present update frontmost)
sessionInProgress - to mean if Sparkle's internal driver / scheduler is running (i.e, downloading appcast or update, showing update, starting installation).
Add entitlements to InstallerConnection and InstallerStatus services and add option to specify bundle id in the now renamed codesign_xpc_service.py script.
Testing WebKit2 is more important than testing sandboxed downloader service.
More people should be adding entitlements to their app for connection services, so we will do that in the test app too.
Deprecate the "done" statuses for user initiated update checks and downloading updates because they really did nothing but burden implementor (there was a relic of an XPC reason back in the day that no longer applies).
This is useful for plug-ins that may want Sparkle to open eg a .prefpane or .saver instead of re-launching System Preferences (which is the app used to wait for termination; normally we only relaunch an app that was proven to be alive).
In a plug-in world, it may not be possible to tell which is more desirable so we provide both options. In 1.x, there was a delegate -pathToRelaunchForUpdater: method to pick between these, however in 2.x for hardening sake, there isn't an API to open any arbitrary bundle path so we provide explicit options.
And remove logic in SPUStandardUpdaterController and SUUpdater that defers starting the updater one cycle later, because that logic is now in SPUUpdater which they invoke.
It is too easy to start the updater "too soon" (if not using SPUStandardUpdaterController or SUUpdater) and I had some weird approach before that allowed the developer to check for updates before starting the updater and it would get deferred until the updater was started (without showing a permission prompt). Instead, defer the update cycle check allowing developer to check for updates immediately after starting the updater if needed (sparkle-cli needs to do this in one case).
Errors are now logged when checking for updates without having started the updater.
This fixes edge cases of UI being shown too early.
Sometimes when the app is re-activated, the window is ordered back behind other applications. Also it may be useful to eg read the release notes when browsing another application. We still preserve the logic that defers showing the update alert when the application isn't initially frontmost.
With these changes, it should not be possible for neither an old or new bundle to be at the destination.
We also perform temporary directory cleanup after final installation stage is and relaunching an app is performed because we can save some time (150 ms+ in one of my cases).
Only check and update tag in Package.swift when not running a CI build. As long as GitHub actions are reserved for tests, this should be ok as this is a "fake" update of Package.swift anyway. If you ever use GitHub actions for releases, you'll probably have to rethink the tagging logic once again
Improves prompt asking to force move tag (default is NO, but can be triggered after `make release`). Fixes issues with single quotes in make-release-package.sh.
In 2.x, updates can be downloaded automatically and presented later even if they can't be installed automatically without user intervention. Users need to in control and be able to disable automatic downloads regardless of developer's Info.plist intention.
The custom headers added in #489 only applied to the appcast download.
This makes them apply to the app download as well for the case when both are hosted behind authentication.
With these changes, modern pkg's should no longer need to be archived.
Only guided package installations are supported for flat packages. Specifying an interactive package installation type will result in a rejection. If the file URL has a ".pkg" suffix it is by default assumed to be a guided pkg installation now, which relieves the burden of needing to previously specify sparkle:installationType in the app cast item enclosure, in this case (for 2.x). Moreover, this relieves the burden of developers needing to archive their pkg for Sparkle.
If user opts-out of automatic downloads (eg via app pref), they should be able to skip.
This logic for detecting minimumAutoupdateVersion present isn't sufficient and consistent enough, chooses to have skip visible in cases updates aren't prevented.
Masked sysctl hw.cputype value when evaluating the CPU type.
Used macros from mach/machine.h instead of magic numbers.
Added support for ARM in evaluation of hw.cpusubtype.
When changing the name of an app, there's a couple things to do in order
to ensure auto-updates still work:
1. set SUBundle Name. This basically tells Sparkle "ey, expect an app
of {SUBundleName}.(app|pkg) instead of the normal name."
2. set `SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME` in
commonConfig.xccconfig to reset the name of the app.
in (2), we always used the host's bundle name, instead of checking to
see if SUBundleName was set, which means normalization doesn't work as
expected during app name changes.
• Updated error dialog code in SUBasicUpdateDriver, and created a local variable to reuse `[aHost name]`.
• Updated content of Sparkle.strings files, splitting existing affected translations into 2 chunks each.
• Fixed the Catalan translation, which was using an old string key.
• Removed a few unnecessary comments in the Polish translation.
The install description currently fails to notify the user that they should install the git submodule(s) present in the repo.
This causes `make release` to fail.
We fallback to legacy WebView in two cases:
* On systems prior to macOS 10.11 (it may be possible to support WKWebView in 10.10, but due to an 10.11+ only API I didn't bother putting in the effort)
* For apps using the downloader XPC service which are most likely sandboxed apps without an outgoing network entitlement. WKWebView doesn't function in that case (FB6993802 - https://github.com/feedback-assistant/reports/issues/1)
Additional notes:
* Added an abstraction for using WebView or WKWebView
* Web view is created and inserted programmatically rather than from the nib which has previously caused issues (and is not allowed for WKWebView prior to 10.12 due to some NSCoding bug).
* We need to rely on WKWebView private API for drawing transparent background (FB7539179 - https://github.com/feedback-assistant/reports/issues/81). Additional notes in the code.
* We always inject a custom stylesheet for dark mode colors and default font family/size (for WKWebView).
* This should also improve the Catalyst support story (#1482)
This reduces friction in creating a SPUUserDriver. This assumption that the calls could be made from any thread is a relic of the past of separating the user driver into a different process from the updater/scheduler, which is no longer sane or supported.
This should speed up things very slightly too.
When archives are stored as symlinks e.g. due to storing binary files in a
git-annex repository, everything works file except file size in the generate
feed xml file. This patch makes generate_appcast correctly determine file size
by following the symlink
(cherry picked from commit 7233bb93e7)
Previously, generate_appcast could only add or remove the release notes element for an update. This was probably fine, because it was unlikely to change: the release notes URL was determined by the SUFeedURL.
However, now that —release-notes-url-prefix was added, the release notes element CAN change. So, with this commit, if the release notes element is present for an update, the URL will be set correctly.
(cherry picked from commit 7c7e924ed4)
This keeps it from running when nothing's changed, which keeps Xcode
from re-signing the framework when nothing's changed, which keeps
downstream clients from re-copying the framework when nothing's
changed.
Rather than using a valid-but-incorrect public key or signature to
make sure a failure to parse turns into a failure to validate, only
return a public key / signature when it is both present and at least
minimally valid. Syntactically invalid public keys / signatures are
also logged explicitly.
Avoids "Class SUCodeSigningVerifier is implemented in both
Sparkle.framework/Versions/A/Sparkle and
Sparkle Unit Tests.xctest/Contents/MacOS/Sparkle Unit Tests.
One of the two will be used. Which one is undefined."
This gets more complicated, since binaries can be just code-signed, or
use both code signing and DSA keys, or be rotating keys for one or the
other.
The code signing test cases emulate certificate rotation by changing
the "identifier" for the bundle; the script used to sign each bundle
(with ad hoc signing) is included to support future expansion of
testing.
The actual tests here are the same as pre-validation; things only get
complicated when validating with code signing. The setup's a little
more involved though, since we need a supposedly-downloaded bundle to
do anything.
Also test invalid signatures, which are not always the same as absent
signatures.
You have to remember to invoke prevalidation anyway, so it doesn't
gain much for post-validation to check whether prevalidation failed.
Also, remove a no-longer correct comment from the corresponding
header.
-cleanup is only called when the task has finished, so it's safe to do this.
This silences a spurious warning logged by NSURLSession (or somewhere else internal):
Task <BB2AE4EF-8E93-44D7-9AB3-6EE9A9E3ACF8>.<1> load failed with error Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://example.com/appcast.xml, NSErrorFailingURLKey=https://example.com/appcast.xml, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDownloadTask <BB2AE4EF-8E93-44D7-9AB3-6EE9A9E3ACF8>.<1>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDownloadTask <BB2AE4EF-8E93-44D7-9AB3-6EE9A9E3ACF8>.<1>, NSLocalizedDescription=cancelled} [-999]
* tag '1.20.0': (28 commits)
Bump
Fix binary delta creation on network drives
New Spanish localisation
Fix compilation issues on Xcode 10 with new build system
Bump
Updated readme to indicate that the 10.11 SDK is required to compile Xcode 7 was released with 10.11, the reference to the 10.8 SDK is out of date.
Explicitly specify types to silence "Messaging unqualified id" warning that's new in Xcode 10. Removed __has_feature(objc_generics) check and use generisc to help silence the warnings.
Updated Finnish language resources
Remove executable bit on distributed source files.
Fix potential hang with dispatch_sync to main thread
Deliver SPUDownloaderSession delegate messages on the main queue
add tips for user to install doxygen
add delegate callbacks for fininshed download and extraction related events
Restored legacy CLI for backward compatibility
Fixed index out of bounds
More complex argument parsing to support both inputs
Function to load the private key directly from the keychain
Minor naming improvement
Bump
Explain why auth is requested
...
* tag '1.19.0': (44 commits)
Ensure cocoapods is installed before performing the release “sanity check” (#860)
Silence ‘This block declaration is not a prototype’ Xcode warning
Silence ‘decodeObjectOfClass:forKey: is only available on macOS 10.8’ Xcode warnings, similar to commit ea94969188
10.7 compatibility
Avoid invalid use of main thread
Update wording of read-only error
Improve 'read-only' error message (#1192)
"all" target
Hidden verbose flag
Outdated comment
Amend to avoid gender issue
Changelog
Bump
move Xcode 9.2 automatic changes from project to xcconfig files
Bring project up to Xcode 9.2 settings
silence 10.9 availability and other warnings and use modules when available
Ensure UI is changed only on the main thread
nil checks
Fix typo in expectation description
Finish tests for persistent download
...
* Quiet warnings from Swift compiler: "Using '!' here is deprecated and will be removed in a future release"
* Ignore diagnostics that yield 'messaging unqualified id' warnings when calling XCTAssertNotEqualObjects. I have filed a bug with Apple, Radar #45968630, requesting that they quiet the warning internally to the macro implementation.
* When setting the access time on a directory and its contents, set the access time on the directory last so that it will be guaranteed to match the expected value. There is a side-effect of calling getFileSystemRepresentation that it sets the access time of its container folder, presumably because of an implementatiton detail of how Foundation builds up the path. Note there is another problem here that the order of items from NSDirectoryEnumerator is undefined, so some of the interior items of a directory will undoubtedly end up getting slightly varying access times set upon them. However, for the purposes of Sparkle's use of this method to "keep things alive" in /tmp, I don't think there is an issue. This fix addresses a failing unit test testUpdateFileAccessTime, which was failing because of very slight differences in access time created by the problem described.
This is done by applying a user stylesheet, making the background of the WebView transparent, and using a NSBox to display the dynamic dark background color. The appearance of the release notes will unfortunately not adapt if the theme is changed while the release notes window is open.
* Improver read-only error message German
Updated the "read-only volume" error to reflect the real-world scenarios users run into.
It's almost never a CD, it's nearly always running from ~/Downloads or the .dmg if you still ship your app that way.
I personally have my projects on iCloud Drive which contains a space in the path (`~/Library/Mobile Documents/...`) and the build fails running these two scripts.
Amend to avoid gender issue
Victor committed
a01979c
1 changed file
Instead of addressing the user, which might cause gender issues, string has been adapted to include “app” (masculine, in accordance with Apple's terminology).
Would translate back as “The app is up-to-date!”
The SULastCheckTimeKey preference (a/k/a "default"), which is stored
in ~/Library/Preferences/….plist, was used to store the date of the
last update check.
That causes a problem if the storage is read-only (for example, if the
.plist file is “locked” (has the uchg or schg flag set) or if the
SULastCheckTimeKey key "exists in a domain that precedes the
application domain the search list"). The date would never be modified,
and the old date would cause a new update check to be queued at the end
of an update check. If application or bundle was up-to-date, or the
user had chosen to skip the update that was available, this would cause
update checks to happen as often as the computer and network would
allow, many times each second.
The new code uses an instance variable to store the value. The variable
is initially loaded from the “SULastCheckTimeKey” preference, and each
time the variable is modified its new value is stored to that
preference. However, the variable, not the preference, is used when
calculating whether enough time has passed since the last update check
to warrant another check. The variable will always (after the first
update check) have the "correct" value, and update checks will not be
done more frequently than desired.
10.11 SDK does not contain the os_log API yet. Code is modified
in such a way that it compiles with older SDKs, and falls back
to the old implementation even if it runs on 10.12.
* origin/master: (21 commits)
Bump
Update Xcode version for Travis CI
Fix for the timing issue of termination detection.
Add optional updaterDidRelaunchApplication: method on SUUpdaterDelegate (#1115)
Better error message
Warning
Update to Xcode 9/Swift 4
Revert "Ensure UI code always runs on the main thread"
Update German localization with some terminology changes
Update German localization for informal style
Update Dutch localization for informal style
Update Dutch localization with some style changes
Include bin files in CocoaPods installation
Simplified check
Rename OSX macOS
[BasicUpdateDriver] - extend hostSupportsItem method to also check the sparkle:os attribute from the enclosure element to decide if an update item is valid for the host
[AppcastItem] - parse and save the sparkle:os attribute of the enclosure element and add isOsxUpdate method to item class
Updated Japanese translation to reflect change on 55be13c
Updated translation to reflect change on “Update error message to mention temp folders rather than optical drives”.
Changelog
...
The scheduleNextUpdateCheckFiringImmediately: method includes an asynchronous callback. It invalidates the timer before invoking the method with the callback (retrieveNextUpdateCheckInterval:), but doesn’t not invalidate again inside the callback block.
The problem with this is that it is possible the timer is started during the delay. In release versions of an app, crashes have been seen due to an assertion that the NSTimer be nil when scheduling.
The proposed fix is to invalidate the timer in the callback, ensuring the NSTimer is nil before scheduling.
This updates the podspec to include the bin scripts in Pods directory
when using CocoaPods. This way users don't also have to download the
Sparkle repo out of band to sign releases.
* origin/master:
Don't assume that the progress block exists (the parameter is nullable)
Prepend app name to Autoupdate.app name
Error message tweak
Update error message to mention temp folders rather than optical drives
1.18.0
Log more errors
Unify handling of aborted updates
* commit '60727bffa53ebfbfaf701575904847827bc1656a':
Log key read failure
Formatting
Escape + as well
Escape profile URLs better
Special case for .tar.gz extension
Inline release notes if they don't look like a standalone HTML document
Simplify release notes link check
Feed formatting
* origin/master: (39 commits)
%s is deliberate in this format string
Unused
Make generate_appcast available as a shared scheme
Shush Xcode
Link straight to docs from the readme
ignore .html files when scanning for archives
Missing strings translation.
Updated swift
Warn against abusing installUpdatesIfAvailable
when generating the appcast, if an .html file exists of the same name as the archive, then it will be linked in as the releaseNotesLink
Revert "Fix pt_BR translations"
Revert "Fix pt_BR translations (#1039)"
Fix Japanse localization
Add more info to auth tool run failure
Fix pt_BR translations (#1039)
Fix pt_BR translations
Disable the keyboard shortcut for the install button for scheduled updates to avoid accidental installs.
added `sparkle:shortVersionString` to the enclosure, #1032
Changelog
percent encode the filename used in the delta url
...
Generalize message to user as the previous setence was more like "Anonymous system profile information is used to help **our company** plan future development work."
While this may or may not be perfect, this should improve code quality by preventing new code that is introduced that creates tight coupling. This test is performed when make test is executed.
I avoided retrieving objc_dep in a way that make test would require an internet connection. I also added the executable bit to the objc_dep script, and a source.txt file indicating where the source came from.
PlistBuddy always touches its output file, even if the value written is
identical to the value already there. In such case, Xcode sees
Info.plist as modified, therefore sees the entire target as modified and
re-runs potentially expensive operations like copying frameworks or
signing.
Avoid unnecessary build operations by checking the previous
CFBundleShortVersionString if Info.plist already exists and only
updating it if necessary.
Before our TerminationListener didn't handle a process that has already been terminated. In my fork this is unlikely to be an actual issue but in master, the application can very well be dead before the termination listener initiates.
* origin/master:
Explain why I'm not relying on the compiler to throw linkage errors
Add AppKitPrevention header to reduce redundancy.
Add AppKit prevention guards to modules that shouldn't import it
Add Obj-C generics where applicable
Adds test cases for "sparkle:criticalUpdate" tag. (#999)
I don't think I have a great justification anymore for waiting more than 'x' hours. This may just be an artifact when I was initially architecting Sparkle so that the entire framework could be stuffed into an XPC service.
* Adds a test case for the "criticalUpdate" appcast tag (not as a XCTest but simply as an assert inside the test app, because I was lazy and am working on an older Xcode version that does not support the currently needed swift version for the XCTest in SUAppcastTest.swift).
* Tests the "criticalUpdate" appcast tag, using the proper XCTest swift class. I haven't tested this, though, due to the lack of the needed Xcode version.
* Test case for Appcast now checks all 4 items for the correct "criticalUpdate" state.
* Adds a test case for the "criticalUpdate" appcast tag (not as a XCTest but simply as an assert inside the test app, because I was lazy and am working on an older Xcode version that does not support the currently needed swift version for the XCTest in SUAppcastTest.swift). (reverted from commit 3ce1c9790b)
We use the cached host bundle if the host bundle is equal to the main bundle.
Otherwise we read in the latest Info dictionary every time.
The cached case is the most common case. The odd case (updating other bundles) is less common. Thus we have better performance for the common case, and we retain correct code in both cases.
Also we invoke our own implementation of -objectForInfoDictionaryKey: rather than NSBundle's implementation in a few places.
We use the cached host bundle if the host bundle is equal to the main bundle.
Otherwise we read in the latest Info dictionary every time.
The cached case is the most common case. The odd case (updating other bundles) is less common. Thus we have better performance for the common case, and we retain correct code in both cases.
With this change, we ensure distinct per-app, per-process logging.
Note that the global file ~/Library/Logs/SparkleUpdateLog.log is no longer written into.
On 10.12 and above, SULog uses the os_log APIs. You may want to use log(1) to view logs in addition to Console.app. See the WWDC video on the new logging API and how the Console app has changed.
On older systems, this uses ASL (Apple System Log).
We don't want to reinvent logging, or rely on 3rd party libraries, thus we use what the system provides to us.
Two logging levels were added: Default and Error. The code documents their intended purpose. Now when you call SULog you must make a decision which level to use rather than rely on an implicit level.
This will increase the chance of a user driver implementing being able to show informational only updates. Also it's better to use a new method rather than re-use another existing one inappropriately.
The automatic update driver defers the informational only update & aborts, allowing a scheduled UI driver to resume it. The automatic update driver aborts before the point an update would normally be downloaded.
I have been receiving unarchiver test errors lately (after the unarchiver blocks changes) somewhat rarely (it's very hard to reproduce) when running all the tests locally. Thus, hoping this change may make a difference.
Interactive package installs now need to be opted into (foo.sparkle_interactive.pkg or foo.sparkle_interactive.mpkg)
The website documentation may need to be updated later, and this should be noted as an important point in the change log.
Returning nil from these delegate methods is equivalent to not implementing the delegate method. The caller should be able to make this kind of decision when implementing an optional delegate method.
Also create SUUpdaterPrivate protocol to expose as little as possible to the internal update drivers. Ideally this would be minimized and not even exist at all, but I don't want to make the architectural and potential backwards-incompatible changes required to do that.
Fix status text during download (e.g. "10MB of 22MB") so that it no
longer distractingly jumps around and flickers. This was caused by two
things:
1. Flicker on macOS >= 10.8 due to the use of NSByteCountFormatter's
default mode which isn't optimized for stable display and is not
suitable for rapidly updated values.
2. Smaller movements of text on macOS >= 10.11 due to the use of San
Francisco font's default variant, where digits don't have fixed
width.
Fixed by using monospacedDigitSystemFontOfSize for the text field and
enabling NSByteCountFormatter's zeroPadsFractionDigits mode.
This fixes a bug where the status would stay at "Extracting update" after validation from the 1st delta patch failed, and it continued on to a full download.
This is better than the hack in the previous commit. Also, a user driver may very well want to act differently in showing UI if the user initiated the update check.
SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=1 now works properly again. In the progress agent, we don't use the path sent from the installer unless the normalized setting is enabled.
This allows us to remove SPUUserDriverUIComponent and remove a bunch of logic in the user driver regarding termination. The user drivers generally don't need to know about the application bundle anymore, and strictly now only show UI events.
This has another advantage of the agent being able to quit multiple instances of an application even if the application to update is sandboxed.
We enforce the logic that an application can only be relaunched if it was running initially.
We don't import SPUUserDriverUIComponent in SparkleCore because it is an exported class a part of Sparkle framework, which causes issues.
Instead, we import SPUApplicationInfo which is not exported from Sparkle.
This only affects updater delegates that return NO from -updaterShouldAllowInstallerInteraction:
This improves the user experience in sparkle-cli where now the checking can be aborted before even downloading the update feed, if it knows ahead of time that installation will fail.
This is triggered if the update is automatically downloaded and the installer is started in the background, and the updater's delegate decides to handle silent installation and installs the update invoking its immediate installation block. In this scenario, this fixes an issue where the application may not be terminated silently.
Switching between a sandboxed and non-sandboxed app with regards to user defaults has some bugs with saving user defaults.
Confirmed by an Apple engineer.
Until I find a good reason to have them there, they should not be publicly available.
I actually found a couple bugs from code that was accidently referencing them.
This may be useful if user defaults can't be relied on for the feed URL.
For example, if an app is sandboxed, its user defaults may differ from the defaults sparkle-cli looks up.
I think I used to have this when the remote XPC callbacks were in the user driver and I removed them at some point.
These callbacks are now part of the SPUUpdaterDelegate and the logic is simpler now than before.
The command line utility makes use of these callbacks.
This is more consistent with how the last update check logic works.
I changed the value of SUTimeIntervalAtFirstLaunchKey for backwards compatibility purposes.
Although it is interesting to separate the user driver and update scheduler in different processes, this has yet to prove useful. Further, this management should not exist in the user driver protocol since the protocol would be doing double duty. If this separation is useful in the future, it should be separated into another driver altogether. Note that it is also hard to write correct code that separates the user driver and updater. Removing this code should greatly reduce maintenance costs.
This fixes issues where the user driver may not be displaying release notes properly because it doesn't know what kind of data was downloaded (eg: html vs plain text).
New classes will soon be prefixed with "SPU"
I still need to look into adding a compatibility layer for -updater:willInstallUpdateOnQuit:immediateInstallationInvocation: and possibly deprecating no-DSA instead of outright rejecting it.
If we download a package type installation or a delta update, we should validate the update before trying to unarchive it.
We can't do this with ordinary updates because we handle changing of DSA keys for that particular case.
We first create a directory with respect to the app's bundle ID being updated, sparkle's bundle ID, and a directory inside for a specific purpose. Then we remove all old directories inside there, and create a new unique temporary directory.
This is to avoid conflicts with eg: multiple updaters running against each other around the same time, or files for one function interfering with files from another purpose, while still having a way to clean up old files.
Create distinct subdirectories in our cache directory so files for different purposes won't conflict.
For the installer, move the download archive to the installer's cache location. If the installer is running as root, this moves it to a place only root can access I believe. This is also to prevent other functionality from touching these files.
This is only for debug builds. Release products aren't signed. This allows the updater agent app to be placed in the installer launcher service's MacOS directory, which is more convenient for developers to sign.
The InstallerLauncher code now tries to locate these tools inside Contents/MacOS/ or inside the Resources directory. The installer launcher XPC service now has a copy of the tools included in its bundle.
This may seem like wasting space but it enables eg, the XPC service not trusting a sandboxed application. A developer could always remove the tools from the Sparkle framework if necessary (we can't because the XPC services are optional..)
Using the XPC service allows the developer to sign the installer executable (Autoupdate.app). The agent app can be moved and signed into the MacOS executables directory as well. We don't do that automatically because Xcode's tooling doesn't play nice with attempting that, although that could be looked at later.
We now distinguish between the updater delegate allowing interaction and the update driver allowing interaction. We also remove an interaction allowed flag from the AppInstaller, letting shouldShowUI flag suffice.
Assume that the updater will be run as a logged in user.
The command line driver and progress app aren't completely root safe anyway, and running the progress app under a different user could be quite awkward from root
Several reasons:
* The user may not look at the trash anyway, and it would bloat their HD space
* Other sofware updaters don't move old versions to the trash either. Can confuse the user or not be seemly transparent experience.
* Moving app to trash will not work if user has to authenticate anyway
* Unclear how long and expensive this operation *could* take in all scenarios
* App replacements in Apple's new file system can be atomic-safe, but that may only be the case if the old app is no longer needed
Cons:
* Few tech savvy users may not be able to restore an app without re-downloading it. This would still be rarely done even amongst them.
This is now necessary for package type installations so we can know whether or not we should authenticate ahead of time.
Of course, we also verify that the download contains the type of installation we expect (because the appcast is not very trusted).
We now present a better worded dialog (X wants to update. Please type your password to allow this. OK/Cancel)
We still need to set the icon for the dialog window.
I also fixed some issues with canceling the dialog still throwing an error.
This allows automatically downloading updates, and having them prompt up later, so the user can perform authorization later for starting up the installer
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.
I need to at least look at:
* Automatic downloaded / silent updates
* Running updates as root user from beginning
* Status info query service
* Add guided flag in the appcast
This fixes an issue where relative external references could not be loaded from the release notes.
Note this just affects apps that have a 'com.apple.security.network.client' entitlement or apps that aren't sandboxed.
We now use XPC for communication between Sparkle.framework and Autoupdate.
Autoupdate is now ran as a launchd agaent/daemon. (Most of the time, it acts as an agent).
Using XPC can only be done from non-sandboxed processes, so a connection and status service had to be created.
Currently, the GUI progress tool doesn't work properly, but everything else should be behaving like before.
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-reachabilityhttps://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 :)
• 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.
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.
This fixes installation failing when we check for the wrong child and don't let the installer finish. However, this code now ignores the status from the child. I might see if there's a better way around fixing that..
I don't think this feature would be used much, and I don't want to deal with additional maintainability. As it is, the progress app should show up in rare cases.
This way we don't have to include an icon for the installer progress app. There is a minor issue where the dock icon changes back before termination. However, this app should show up in rare cases in the first place, so I still think this is a good trade off.
For most applications, it makes more sense to use the app's icon than Sparkle's. That and we can save some disk space usage.
This allows installation by requesting the user to enter a password when elevated privileges are necessary. This only works if the application is alive before installation begins.
If the file manager is used for authorization, we can now supply an authorization environment.
This allows us to specify a customized prompt message and an icon to use in the authorization dialog window. We no longer need to include an icon for Autoupdate app.
We now also see if we can get authorization rights access right away, rather than lazily when executing a tool.
* 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
...
1. Use Apple's logging system (ASL) - don't invent our own inefficient mechanism.
2. Logging is not dependent on a global file that any process and thread using Sparkle can write to now, which could also be cleared at any point before.
3. Don't write to stderr on non-debug builds. This is ideal for sparkle-cli utility.
We don't export an API for configuring this in SUUpdater.
Messing with the user defaults is not ideal, and we don't use hasLaunchedBefore anymore
For testing this, the user defaults should just be removed manually, and the test app should be relaunched.
This option never used to work for me that well before anyway.
The old behavior used to be to prompt on second launch.
However, applications can be re-launched in a short amount of time, and Sparkle can be loaded multiple times during a single app launch.
So prompting after a certain amount of time after first launch works better.
If an update permission request comes up, this alows us to make a decision.
Also I renamed the defer and checknow flags to defer-install and check-immediately
What is new is that we can now disable checking for updates immediately.
sparkle-cli is not intended to be run for a long time, so if the next update check is not soon, we exit.
A client can now launch sparkle-cli without having to necessarily check for updates, so that they don't check for updates too soon.
The installer can now inherit privileges from the updater, which inherits
privileges from the process that spawns the updater. As such, we can now
run the updater & installer as root, and no authorization dialog can prompt up.
The installer now must abort or install if the target app has terminated.
Zombie processes will no longer stay around.
Because the root user has no trash directory, we ignore logging the error if it was not found.
We also avoid invoking mdimport which fails as root on the installed app.
mdimport may have been used before for updating mdimporter files, however, it should be the developer's
responsibility to ensure their mdimporter files have an updated date stamp, which will work if a user updates an app manually.
Other than that, we already touch the app to register it with LaunchServices, so that should suffice.
For sparkle-cli and out-of-process updaters, I added a did finish installing event.
I also have logic dealing with whether an update can be silently installed or not.
I made closing status windows before app termination a reponsibility for the user driver now, not
the installer drivers.
I improved checking for updates before starting the updater, if Sparle didn't ask the user for permission yet.
Currently, Autoupdate can persist in the background even when the app is terminated,
if we don't have sufficient privilleges to install right away for example, or if an update isn't silent.
After much thinking, I need to ditch this strategy because:
1. An app can be manually replaced and so the installer would have to monitor that
2. We leave a zombie process running
This aims to make it impossible to have download data accumulate inside the caches directory.
We still try to deal with if an intermediate file is created at the path we want.
appCachePath method was also moved away from SUHost into SUBasicUpdateDriver which is the only class that needs it.
This method also has very little to do with host bundles.
appCachePath is also called less when checking for the existence of intermediate file paths.
Lastly, we now create a directory whose name is the sparkle bundle ID instead of just "Sparkle"
This is to improve potential name collision issues.
We want to wipe the caches directory we create for the test app data on launch,
and want to make sure no other data is being inserted into the same directory.
Before, Sparkle was inserting data into the same directory when downloading an update.
I'm hoping this will ease some of the build configuration issues I've been running into.
Apps (eg: unsigned, not-sandboxed) don't need to (although they still can) use the XPC services.
Sandboxed apps naturally should use the XPC services. Although, you can for example, choose not to use the
downloader services if the host app already entitlements to allow network connections.
If you use the downloader services, you must configure ATS exceptions in them. And if you use those services,
you probably want to sign them with the required entitlements.
If you don't use the services, Sparkle will fall back on almost-identical code executed within the framework instead.
There may be other reasons to use the services or not other than for sandboxing, like fault tolerance.
Lastly, XPC services work within an application namespace. They are discoverable as long as they're in the app.
That's why we can have an app incorporate the services and let the framework use them.
Rename the XPC service products so that they start with 'Sparkle'
Make the bundle IDs of the services a part of the build configuration, so we can pass it to the preprocessor.
We have a custom codesign-after-copy script because Xcode's code sign on copy feature is bad when it
comes to frameworks including signable tools. In release build configurations, nothing we build uses
an ad-hoc code signature. This is logical because ad-hoc signatures are only meant to be used for testing purposes.
Only the XPC services need to be ad-hoc signed (else Xcode gets cranky),
or targets with entitlements like our Test Application.
Distributing ad-hoc binaries can be mixed with distributing unsigned apps,
and ad-hoc is no worse than unsigned when it comes to distributing, so we're all good.
Updating without DSA signing the download is simply not secure.
Before, we were keen on allowing no DSA signing as long as https is used.
However, under the separate process security model, the installer can't know or trust
if the download came over from https. We could move downloading into the installer, but
the installer may run with full privileges one day in the future, and this would
complicate the installer & updater interaction. Furthermore, this could disallow us from being able
to silently download the update in the future if the installer runs at full privileges.
An upside is that the validation and configuration checking code is simpler to read through now.
Even if we could validate that an update came over https, it is still not as secure as people may like to believe.
For example, a hijacked server can choose to manipulate the download (within restrictions), even if it's signed by a developer ID, but not with our DSA support.
Changing of DSA keys and Apple code signing identities is still allowed as long as one of these pairs match and are valid.
Hence requiring DSA signing is also safer when it comes to losing one of your keys. It's only a bit less convenient.
In debug mode we always build with arbitrary http loads, but in release mode we
only want to build sparkle-cli and SparkleTestApp with arbitrary http loads.
An ATS error was added back if arbitrary HTTP loads are not allowed and if the feed URL is http://
The "distribution" target/scheme is now not very up to date because it builds everything under Release configuration.
An app can contain a XPC service with restricted entitlements and own ATS exceptions.
Indeed, Sparkle now is a framework that embeds two XPC services that include download entitlements.
If ATS is disabled, it'd have to be disabled in those services, not within the root of the application.
So we can't keep this detection because it will generate false positives. And it's not really our responsibility anyway.
We really want to differentiate between apps and prefpanes/plug-ins.
Using the main bundle is not at all a reliable indicator because an updater could target
any kind of bundle anywhere.
This new method also takes an error object as output, which means we can now
read a bundle in Sparkle without having to abort. If a check for updates action is invoked
before the updater has been started, it becomes a pending scheduled operation.
This fixes issues with updating modification/access time, and changing owner/group
where symbolic links used to be followed. Symbolic link tests are included.
I added an application target but it's really intended to be used as a command line tool. The reason being was that it was the easiest way to bundle the Sparkle framework, I've found.
Note this doesn't work perfectly yet, but it's a good start. Trying to update anything that's not Sparkle based will crash for instance. And it will use the installer progress tool which may be undesirable.
This created more complexity than it was worth and leads to subpar user experience because the user can see the icon switch back to the generic one when the updater terminates. So we now bundle the icon in the install progress tool. If a developer wants to use a custom icon, they can provide their own customized tool.
Following cases where after an update has been automatically downloaded, Sparkle may alert the user right away:
1) Critical updates
2) Insufficient write access to install without being root
3) Package type installations
In addition to alerting the user right away, if they dismiss the update, the schedule timer will be on regular intervals. We also no longer need to care about writability in the updater, only just in the installer.
Duplicated code from SUFileManager and SUGuidedPackageInstaller has been removed.
SUPlainInstaller now tests if it needs authorization rather than by trying to touch the old app.
SUGuidedPackageInstaller now tries to grab authorization during stage 2 of the installation.
This more accurately reflects its intended purpose. From the beginning,
the user cannot check for updates until the updater is ready;
however this doesn't mean that the update is in progress.
If permissions are abnormal during cleanup or somewhere along the lines, it may be
possible to bring up authorization dialog that is not really needed. Prevent this from happening.
We would want to restrict authorization from being possible anyway when not needed.
ATS exceptions now need to be included in the appcast & update downloader services - *shrugs*.
I've a run script configured to disable ATS for release builds.
This allows Sparkle to be used as-is in a sandboxed application,
without needing to place Sparkle into its own XPC service.
Currently the main app may need to set a global mach service lookup exception
and a client download exception, however this can be fixed by creating a couple more
services. Testing for disk writability will need be done in a service too.
If permissions are abnormal during cleanup or somewhere along the lines, it may be
possible to bring up authorization dialog that is not really needed. Prevent this from happening.
We would want to restrict authorization from being possible anyway when not needed.
Just do all installation in 3rd stage at the moment and reconsider this idea..
Doing any work prior to finishing the installation that requires keeping files in
a temporary directory for potentially a long time turns not to probably not be a great idea.
Unfortunately I don't think trying to keep the files up to date every some interval is a _great_ idea.
I will need to rethink this some more.
This is inevitable if we stick to a three stage installation.
The other direction to consider is to defer most installation until after the app terminated,
although that may have disadvantages of its own.
One important addition is touching the new app recursively before moving it in a temp directory.
This is important because archives can preserve modification & access times, but we don't want that.
This is convenient if the updater and app live in separate processes.
No need to use XPC to find out what certain settings are, and it may take too long to find out that way.
Before there were implicit dependencies and unarchivers were globally registered as their classes were loaded.
This flexibilty is unnecessary and comes with a safety (eg: forgetting to link in a class) and harder to read cost
Most of this is removing Obj-C subscripting usage
Some bits are adding pragma ignores to places where we are careful to not use the API at runtime on older OS's
Note that for NSMutableDictionary:
x[y] = z is not the same as [x setObject:z forKey:y]
In particular, z can be nil for subscripting (removing the element if it exists) where it cannot for setObject:forKey:
Personally I like the non-subscripting semantics better. Most cases we were using this we were checking if the object was non-nil anyway
Resumability works by asking the installer for its progress and for the appcast item we've given it before.
If an automatic silent download occurs, we abort it after the installer tool finishes with its basic steps.
Then, a user initiated or scheduled check can resume the update. The scheduled check fires during a longer-than-normal
span since usually the user can install by quitting the app, unless the app has been alive for a very long time.
One exception to this is when the update is marked critical; in that case, the scheduled check is fired immediately after
an automatic update download. Subsequent attempts will be fired using a normal update check interval.
Todo: delta updates probably don't work when they fail and fallback to a regular update
Copy the bytes manually using -[NSData dataWithBytes:length:]
If we use -[NSData copy] instead, we may be using already freed memory
(according to ASAN), which is no good. This may be because the bytes aren't
deep copied.
Also add some @autoreleasepool wrappers because why not.
This removes subclassing usage making the code harder to follow.
Todo: handle resuming an update already waiting to be installed,
adding impatience timer for automatic update scheduling
I added public DSA file, automatic update checking, disabled system profiling
in the unit test's info.plist so that SUUpdater won't complain that DSA is missing,
and it won't prompt for update permission the first time.
I also made SUUpdater use the correct bundle in SUUpdaterTest
We now have a stage where authorization is allowed (when the user intiates a relaunch).
This stage occurs before the user application is terminated (if the operation succeeds).
An install attempt will always be made after the validation is finished now. However, if the
user doesn't explicitly relaunch the app, we don't bug the user about auth prompts which means
updates can fail in this kind of scenario.
This decreases coupling for the updater and updater drivers.
We still pass in the updater because we need it for invoking the updater delegate's methods,
but we now use type 'id' instead of SUUpdater* because we don't want to invoke anything on the object.
Furthermore, we never #import SUUpdater, only forward class declarations.
I added public DSA file, automatic update checking, disabled system profiling
in the unit test's info.plist so that SUUpdater won't complain that DSA is missing,
and it won't prompt for update permission the first time.
This is bad for a number of reasons.
1. Our SUUserDriver protocol wasn't quite the right protocol to pass in.
2. This made the UI/Core components to hold a depedency to the user driver, when it
really was not used for anything other than passing to the delegate. We can now
remove this bidirectional depedency between the components and the user driver.
3. This encourages that the client can handle multiple user drivers within the same class,
which encourages complexity. If they were able to set the delegate, they should have a reference
to the user driver.
Indeed, SUUpdater, SUUpdaterDelegate, and the update drivers all have the same problem.
An unfortunate design decision..
This is to minimize the amount of time the app is left terminated.
App restarts should always be near instantaneous.
More work needs to be done to make authenticated installs more friendly,
and not making installs abortable after validation is done.
The installer (Autoupdate.app) is now responsible for extracting & verifying the update.
It talks to the updater via mach ports. We can't afford to use a XPC service due to
lack of perfoming privileged tasks.
This adds delegate outlets to the updater and to the user driver, so a
developer can hook either of them up. Note we now initialize the updater and
user driver after being awoken from the nib.
We also took this chance to make the delegates to the updater and user driver read only.
This means that the delegates have to be available on initialization, which is good because
changing delegates or setting delegates too late (and missing messages) is bad.
For sandbox testing, we really have to use ad-hoc signing.
Which means we have to sign the "new" app after we alter its info.plist file,
so that our code signing verifier doesn't (rightfully) complain
We should terminate even if the update aborts.
We should also terminate even if the connection is invalidated or interrupted, if we've
already been told to quit
I decided it was less evil to allow SUUpdater to defer cycling and have
a mutable delegate, than it was for SUUpdateController to have a nullable SUUpdater
that could be instantiated an arbitrary time later
I have also changed the delay from 0 to 1, on the safer side.
Also move system shut off handling to the user driver.
Observing system shut off is difficult without AppKit, and
a client may want to observe for varying types of events.
I suppose this is consistent with application termination
notifications though.
This solves several problems:
1) we can't spawn a task reliably from a XPC process
2) we don't want to link to AppKit from SUBasicUpdateDriver
3) spawning a task to invoke open utility is poor with bad inputs
These operations also make incorrect assumptions when called from out of process,
so it makes sense to separate them out. Furthermore, SUHost can now only depend on
Foundation
Yeah, this isn't backwards compatible with older code that uses Sparkle
Few notes:
* Mostly everything from *.pch has been moved out for saner dependency tracking
* 10.7 compatibility has been removed out so I don't import Cocoa when I don't have to
* sharedUpdaters/SUUpdater singletons has been removed out so updaters can actually be deallocated properly
(and since singletons are generally horrible idea anyway)
* SUUpdater doesn't have UI/cocoa/bindings/menu validation code. Its new initializer method takes a user driver
(perhaps in the future I'll create another class that "binds" the UI and core)
This fixes the issue where if an update alert is present for a long time,
and the user dismisses it, they may be prompted with another update alert
immediately after.
In a XPC environment, a delegate may handle update checks by sending a message
to the XPC process that tells it to reset the sparkle updater's check cycle.
If the user driver delegate can do this, the XPC process will not need to wait
for a reply, allowing the system to kill the XPC process when it becomes idle.
These changes are to make XPC environment more friendly. Every reply block must
get a response and is not optional to respond to. For example we can no longer have
a reply block that is just "cancelUpdate()"; it must now take an option whether
we are done now or if we want to cancel, and the receiver should now be aware
when canceling doesn't make sense (i.e, if update already aborted). Furthermore,
a reply block must get exactly *one* response.
non-void/synchronous calls over XPC don't work properly, and
these methods don't seem very proper architecture wise anyway.
A proper solution will be needed for notifying the delegate of modal alerts
If an automatic update needs to be applied at termination,
the app delegate will need to hold responsibility of delaying
termination until Sparkle is ready to relaunch
Note that the protocol API for the user updater driver can still be improved.
applicationWillTerminate: is done from the user driver because that's the only way that will
function across different processes.
Sparkle's past behavior was sorting appcast items by published dates and
picking the first compatible item. However, it makes more sense to pick
the compatible item with the highest version (see issue #31).
The NSDate instance creation & sorting has also been removed from the code.
The methods we were using to parse the string into a NSDate have been deprecated,
and are strongly discouraged. Namely, all methods taking an arbitrary/natural string
have been nuked signaling they were probably a really bad idea. Furthermore, the
date code we had created a NSCalendarDate which has been long deprecated.
So we just don't handle date parsing. Even if there is a proper format for the pubDate,
It is an extra burden on the developer to insert a conforming date.
And we shouldn't want to rely on a potentially error-prone input field.
We support NSSecureCoding for SUAppcastItem and SUHost
Callbacks from XPC <-> Host app now async to main GCD queue.
This is needed for everything to be thread safe.
Todo: NSDate parsing sucks and is temporarily disabled.
In particular, we're using deprecated methods to read the dates,
which don't support NSSecureCoding. The other problem is that the dates are
really useless technically and we shouldn't sort by them.
Everything related to the protocol is intended for showing & dismissing progress,
as well as making UI actions such as canceling, installing, confirming update permissions
This is still incomplete and not perfect yet.
In particular, these delegate methods ought to perhaps be grouped in a separate class.
The UI code that is currently done should be treated the same manner as a custom UI
Relaunching Sparkle should give customization over showing the UI of the autoupdater app
Webview having local file access doesn't seem worse than the app having local file access, but still it seems like a bad idea that relies on files being in predetermined location.
afpAccessDenied can be returned even when not using a AFP mount,
at least according to my testing.
Having an installation do a copy (because of different mounts) and auth
may not be a likely scenario, so this may not be hit often.
This removes run-time warnings that SUFileManager and SUOperatingSystem are
defined in both the test app and the framework, and which one
is used is undefined.
Add the capability to set a decryption password for updating with an
encrypted dmg file.
This enables the the ability to update using an encrypted disk image without having to prompt the user for a password. This is useful when access to the application binaries is only available via distribution or from a location in which authentication is required. This can help prevent an attacker from having unwanted access to application binaries for reverse engineering.
This assists with a defense in depth approach to security.
The move operation now does an explict copy & remove.
We also copy items using FSCopyObjectSync due to issues
existing in copyfile (and NSFileManager).
Both of these fix bugs in some cases where items cannot be moved
from one network drive to another. In my testing before this patch,
I was unable to get the test application to launch and was unable
to move the old installation to the trash.
If we don't do this, Finder may not report the correct file size for the new update.
The system also may not register the new app in its database if we don't do this.
We may have been able to get away with not doing this before because we used to perform a copy
to install the update. However, now updates in some cases can be done with only move operations.
This should also be an alternative way of addressing issue #508
This fixes an issue where the vertical border of the release notes view would sometimes not be visible.
Instead of making the widths of the views equal, we use the trailing property.
This is consistent with leading and bottom being used elsewhere
* Fix uid / gid not being applied to the root path or non-directory inputs
* Remove the code that released quarantines using the NSURL way.
It turned out not to be very reliable and didn't pass the tests.
More explanation is given in the code.
* Prefix private methods with _ and expose some of them to the tests
awakeFromNib should never be used; proper window loading methods
from the window controller should be used instead. awakeFromNib
can also be called multiple times in certain scenarios.
* All supported compression formats are now tested including dmg, which
has a license agreement included
* The hash of the extracted directory is now checked, which encompasses
every file's existence, its contents, and its permissions.
* Re-written using Swift
* Fix issue #608. From the framework, the error is logged via SULog.
From the tool, the error is logged to stderr. Uses NSError handling for
both.
* Move patch version validation for creating a binary diff into the
BinaryDelta tool
* Add parameter assertions to createBinaryDelta and handle if
-getFileSystemRepresentation:maxLength: fails
* 'info-only-updates' of https://github.com/danielpunkass/Sparkle:
Put back some "—" characters that had shifted to "--" in the mix.
Update string formulation to use the new separated localized strings for each case. Also update the code formatting a bit to be at least a little internally consistent. Switch to using dot notation within this method.
Revise approach for localizing the "Would you like to learn more about this update on the web?" case.
Revisions for style as requested.
Remove old localized string which is now superseded by broken-down versions.
Finesse the wording of the message displayed in SUUpdateAlert when the item is "information only."
Declare informationOnlyUpdate as a property of SUAppcastItem.
By not taking account the rare case, we simplify the code by having
less duplication. The tradeoff is that the rare case will be slightly
less efficient.
* Do all the installation work after the runloop is set up (hope this helps #441)
* TerminationListener only does termination listening now..
* Renamed folderpath to updateFolderPath. Likewise with some other variables. Since these are passed by command line arguments, updateFolderPath cannot be nil, so those checks for if folderpath is nil in the old code is removed
* Removed pointless global variable access [SUInstaller updateFolder]
* Old code does not handle if host path is not installation path *and* host path is not desired executable path. This does.
We also add height constraints to the automatically install & download updates button. Since we don't have a custom layout view, we also shouldn't call -[NSView setNeedsLayout:]
Fixes#369
Previously I had broken down the description text into one localizable string for the main clause of the sentence, e.g.: "MyApp 1.1 is available--you have 1.0", and separate localizable strings for the follow-up question about whether to download or get more information. This breakdown didn't work well with some languages e.g. Arabic where the existing localization mixes the placeholder values differently. The new approach is to localize the two complete sentences separately. Unfortunately this means that for the "Would you like to learn more about this update on the web?" case, the localization is missing for all languages except English. But, at least the localization files are properly populated with the expected keys, and await localization updates when possible.
I also spotted a few instances in which an outdated version of the existing localization key was being used (with parens instead of --), so there was no localization occurring in those cases. I fixed those by updating the key to match the current status quo.
* sparkle-project/master:
Use NSByteCountFormatter if available.
Fix a few more easy translation issues.
Fix some simple translation issues.
Delete languages which don't actually have any translations.
Add existing localization files to Xcode project.
Add SparkleLocalizations.swift to the Xcode project.
Use NSXML the whole way through for building the report document.
Remove unused temporaryName: parameter and supporting code.
CheckLocalizations: use swift shebang
CheckLocalizations: use NSUserDefaults to read args
CheckLocalizations: add a helper for error handling
CheckLocalizations: escape HTML
Add script to generate a report comparing the Sparkle.strings files
Previously when an information-only update is displayed to the user, it uses the inappropriate text "Would you like to download it now?" Since the alert is modified in this case to provide a 'Learn More' button, then text should match the action that is being offered. In this commit I break the localized string up into parts such that the notice about the updated version is the same in either case, but the action offered differs depending on the type of update being presented.
Note that this commit only represents changes to the English Sparkle.strings file. Until and unless localized versions of Sparkle.strings add translations for the new broken-up strings, they will display this information in English only.
Declaring a property makes it obvious where changes to the logic about whether an update is "information only" should be made, and leaves the code at the calling point more readable. Instead of inferring that an appast item is information only by the simple omission of a fileURL, require that it also have a infoURL.
The temporaryName: parameter to SUPlainInstaller's copyPathWithAuthentication... method was not being used internally but was still mucking up the (already long) method signature for the method and related methods up the chain. Also remove related, no-longer-used temporaryNameForPath method.
Nothing inside an app/update bundle should be altered anyway, and these permissions will be lost by revision control systems. They also conflict with BinaryDelta's permissions validation
Since it is possible for the user to see these strings, we should not make them seem as 'gibberish' or unfriendly. More detailed error information is logged to the console.
The improvements we want to achieve:
* Stability - No more corrupt / incomplete updates by ensuring atomic move operations
* Efficiency - Faster updates because of reduction of file copies that need to be done
* Separation from Host and Helper - No usage of SUFileManager in the host application
* Cleanness - Minimized deprecated APIs (no FSPathMakeRef, FSGetCatalogInfo, FSFindFolder, etc), use modern Cocoa APIs when possible, robust error handling, strong documentation, easier to read code.
Many other small notes:
* SUFileManager does not have class methods. Methods across an instance share an AuthorizationRef, instead of having to authorize every time a privileged operation needs to be done
* The odd logic of `while (authStat == errAuthorizationDenied)` was removed
* Instead of checking if we have write access, we try to invoke a normal operation first. If that doesn't work, with the right error returned back, we try authorizing, which is what Apple recommends doing
* The trash is not used as a temporary location anymore. Rather we now request for a temporary directory to be created. This is more likely to succeed too (eg: on a drive that has no trash folder)
* The old method for releasing the quarantine did not work until I used the "com.apple.quarantine" key instead of the LS constant that was being used.
* For the old method for releasing the quarantine, we now check if a file has the quarantine xattr bit set before removing it. Just like how the new method works.
* Quarantines can now be removed with authorization
* The result of calling temporaryNameForPath: was never actually used in the old code
* -[NSString fileSystemRepresentation] which can throw an exception is not used. Only getFileSystemRepresentation:maxLength: is used and the error on it is always checked
* The desperate/hopeless check for if the code signature for the update is valid after the installation is complete is removed
Potential issues that still needs to be looked in to:
* Currently the method to move a file to the trash only works on 10.8+
* Appending of version number / picking destination name of app moved to trash
Instead of relying on whether the DSA signature is provided in the appcast (which we can't trust), we rely on detecting if the public key in the new and old app differ. If they differ, then the code signatures from both apps must match. The idea is that code signing is reliable in being able to tell that the Info.plist and public DSA files came from the developer and are intact. This still allows a developer to lose access to their DSA private key, or to their Apple code signature, and be able to push new updates (as long as they didn't lose access to both). The new change, however, is that if the new app has a public DSA key, then the appcast item must have a DSA signature for the app, even if the app is code signed.
appcastDidFinishLoading: was declared in SUUIBasedUpdateDriver, but
defined and used in SUUIBasedUpdateDriver. Move the declaration back to
the base class where it belongs.
If the original app is signed, and the update is not, this is actually fine if the DSA validation goes through. And this may be desirable for people that don't want to pay cash to code sign their application anymore.
If an invalid DSA or invalid code signature is provided, the update will fail, regardless if one of these requirements is valid. The logic before is that the update will succeed if either a valid DSA or matched code signature is provided.
This still allows a code signature to change, be added, or be removed, as long as the DSA and the code signature (if provided) is valid. If no DSA is provided, then this is not possible, and the code signature from the host and update app must match.
Before, an extract was assumed if nothing else matched. This can get quite confusing when adding new properties, so we shouldn't treat any property to be handled if nothing else was handled.
Related: Issue #441
I have no evidence that this is the cause of the issue, but from what we do know from the crash logs submitted, it looks like Sparkle crashes or errors on the main thread. It also looks like it might be from an object release rather than copying (which is done on a different thread) being the issue (see issue #417 also). I'm leaning towards this being an issue after the project was converted to ARC.
Since BinaryDelta can still create patches for older versions, and since I've made fixes recently even for version 1 patches, we should increment this counter.
This will break backwards compatibility with version 1 patches, which generated tree hashes differently and did not handle applying permission changes in some cases.
A version flag is also added to BinaryDelta create for creating patches an older version of BinaryDelta apply can handle. This is only meant for transition purposes.
Rationale: given a before-hash and an after-hash, there should only be one way to create the diff file. It was possible to violate this before, if we let a file differ in a permission bit that wasn't executable.
This should help prevent situations like issue #441 where Sparkle
creates broken app bundles. In this case, the update will just report
as a failure instead of succeeding.
There's a zipped up sample app in the unit test target. This gets unzipped to
a temporary folder and there are three versions of it: the original which is not
code signed at all, another with a valid code signature, and a third which
has had one of its resources removed after code signing to make it invalid.
The API docs say "For bundles, pass a URL to the root directory of the bundle…
If you pass a URL to the main executable of a bundle, the bundle as a whole is generally recognized."
My initial attempt did not work correctly for directories that differed in permissions (since it removed them and all the files inside them). We are now setting a property for permission changes which can happen when a binary diff is created, or when it is skipped. Still have to figure out how backwards compatibility is going to work now..
BinaryDelta can now create proper diffs in the case if a non-executable file becomes an executable file, or vise versa. Currently for simplicit
y and backward-compatibility we delete then extract if an executable difference is found, rather than creating a diff. Files that contain an executable difference are unlikely to be large anyway.
We also change the tree hash function so it can track executable permission differences on files. It also now tracks file types so it is less collision-resistant for example in the case where a regular file becoming a symlink could have resulted in the same hash. Because the tree hash function changed, major & minor versioning to the format was introduced. Older minor versions remain compatible, but older major versions do not. In this case, we've only bumped the minor version. In this case, older versions can apply a patch created by a newer version, and newer versions can apply a patch created by an older version.
More error handling is now checked, some code improvements were made, and some adjustments were made to the tests with regard to the changes above.
Since a function for creating diffs is now exposed, this should make testing easier
This is also consistent with applying diffs being in a separate source file from the delta tool as well
Although #132 is marked as closed, the issue is still real. bsdiff can crash or hang when creating diffs on some files. In particular, bsdiff hangs/crashes in its recursive split function.
As you can see from:
http://stackoverflow.com/a/20305493/871119https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=409664
bsdiff 4.3 uses qsufsort for its suffix sorting algorithm, which has a bug causing the hanging/crashing. Our solution is to change the algorithm to use sais for suffix sorting:
https://sites.google.com/site/yuta256/sais
Notes:
*I had to change sais_index_type #define from int to off_t in sais.h/c and in some other places, to eliminate all warnings. Compiles cleanly with clang's -Weverything
*sais is claimed to be more efficient than other algorithms including qsufsort. If a more efficient (and stable) algorithm comes out, we may be able to swap it out in the future.
This can occur in the following case:
--
original_tree:
A/
Current/
B
new_tree:
A/
B
Current -> A/
--
Because symbolic links are not followed, Current/B can be marked as deleted. If A/B is added before the deletion, then A will end up as an empty directory.
Our fix is to remove all subpaths of a file when it changes from a directory to another type of file. This should also decrease the size of the diff even in harmless cases such as when a directory changes into a regular file.
When a filename changes case, make sure we have the file deleted in the old tree before being extracted into the new one.
Note that we don't try creating a diff if a file is renamed with a different case, just like we don't track file names changing in other ways.
See issue #474
« Automatiquement » before the two verbs is a little akward, not incorrect but unusual. And « à l’avenir » (« in the future » is really not necessary, usually they don’t mention it.
Autoupdate.app can crash in the middle of installing an update, leaving
the user with a broken application. The crash is caused by the status
window’s controller (SUStatusController) being prematurely deallocated
before the window is closed. This change prevents such a crash by
keeping a strong reference to the SUStatusController in
TerminationListener.
Don't delete the log file and log app name to it when only checking for
updates - this is something done frequently, on many apps' startup.
Instead, clear the log before writing the first entry to it, so that it
stays untouched if there's nothing to add to it.
Log the application name before the first "real" log entry, instead of
doing it unconditionally every time checkForUpdatesWithDriver: is called.
This way, we don't rely on automatic scheme creation in Travis, nor do
we have to update the Makefile for Travis if we want to add an
additional test target to the project.
Also, Travis should now build all targets (including BinaryDelta and
Sparkle Test App), giving us better build coverage.
This helps ensure that all code paths are compiled during development, reducing the chance of build errors (especially in CI). Additionally, developers can change these values without having to rebuild Sparkle (but it is still safe because modifying the plist will break the code-signing seal).
Added headless guided installation of pkg and mpkg files. Ported to
using ARC
and inlined documentation. The use of
`AuthorizationExecuteWithPrivileges` should be replaced with an XPC or
assistive external process in a future update. See
https://github.com/sparkle-project/Sparkle/issues/348
I think the test framework saw `setTestFeedURL` as a setter. This change changes it to `testSetTestFeedURL`, which will run as a test.
And for some odd reason, crashes.
* 'ARC' of https://github.com/MaddTheSane/Sparkle:
Fix a release bug.
Force Xcode to use spaces on source code files.
Convert Sparkle to ARC, take three.
They’re faster, even if they’re used outside of ARC.
Use dispatch functions to spin off new threads.
Update the Binary Delta tool's class to be better.
This is only true because we’re targeting x86_64 on OS X. The same is true for all iOS architectures, but not i386 on OS X.
Use CFBridgingRelease in a few places: it acts just like [(id)CFMakeCollectable(obj) autorelease] on non-ARC code, but is a bit cleaner.
Getting rid of unneeded parentheses.
Remove more pre-10.7-only code.
Add comments.
More property declarations.
Make SUUpdatePermissionPromptDelegateInformalProtocol a protocol with the name SUUpdatePermissionPromptDelegateProtocol.
### Version of `Sparkle.framework` in the latest version of your app
### Version of `Sparkle.framework` in the old version of app that your users have (or N/A)
### Sparkle's output from Console.app
```
```
### Steps to reproduce the behavior
[The more information provided and pasted verbatim, the easier it will be to diagnose an issue. If you can provide the affected application/binary and XML feed to reproduce an issue, share them]
SULog(SULogLevelError,@"Error: Rejecting new connection for agent due to failing validation of XPC connection with status %lu and error: %@",validationStatus,validationError.localizedDescription);
SULog(SULogLevelError,@"Error: Rejecting new connection for installer due to failing validation of XPC connection with status %lu and error: %@",status,validationError.localizedDescription);
[strongSelfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:@"Invalidation on remote port being called, and installation is not close enough to completion!"}]];
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:@"Timeout: installation data was never received"}]];
}
if(!self->_agentConnection.connected){
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:@"Timeout: agent connection was never initiated"}]];
prevalidationError=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUUnarchivingErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"No valid unarchiver was found for %@",archivePath]}];
prevalidationError=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUValidationErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Extracting %@ archives require setting %@ to YES in the old app. Please visit https://sparkle-project.org/documentation/customization/ for more information.",archivePath.pathExtension,SUVerifyUpdateBeforeExtractionKey]}];
success=NO;
}else{
// Delta, package updates, and apps with SUVerifyUpdateBeforeExtraction will require validation before extraction
// Otherwise normal application updates are a bit more lenient allowing developers to change one of apple dev ID or EdDSA keys after extraction
[selfunarchiverDidFailWithError:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUUnarchivingErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Failed to unarchive %@",archivePath],NSUnderlyingErrorKey:(NSError*_Nonnull)error}]];
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:@"Update validation was a failure",NSUnderlyingErrorKey:validationError}]];
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:@"Timeout error: failed to retrieve process identifier from agent"}]];
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Error: Failed to match host bundle identifiers %@ and %@",self->_hostBundleIdentifier,bundleIdentifier]}]];
return;
}
// This will be important later
if(installationData.relaunchPath==nil){
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:@"Error: Failed to obtain relaunch path from installation data"}]];
return;
}
// This installation path is specific to sparkle and the bundle identifier
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Error: Failed to create installation cache directory in %@",rootCacheInstallationPath]}]];
return;
}
// Resolve the bookmark data for the downloaded update
// See "Share file access between processes with URL bookmarks" in https://developer.apple.com/documentation/security/app_sandbox/accessing_files_from_the_macos_app_sandbox
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:@"Error: Failed to resolve bookmark data from downloaded update",NSUnderlyingErrorKey:bookmarkError}]];
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:@"Error: Failed to retrieve path components from download URL"}]];
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:@"Error: download URL path components contains '..' which is unsafe"}]];
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:@"Error: download URL path components does not contain PersistentDownloads or "@SPARKLE_BUNDLE_IDENTIFIER}]];
return;
}
}
if(!isStale){
SULog(SULogLevelError,@"Error: bookmark data for update download is stale.. but still continuing.");
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:@"Error: Failed to retrieve download name from download URL"}]];
return;
}
// Randomize the download name if possible
// This adds better security if there are any vulnerabilities in extracting/executing archives
// which allow writing in unexpected locations. For zip/tar/dmg archives we may also extract them before
// performing signing validation (due to key rotation).
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:@"Error: Failed to move download archive to new location",NSUnderlyingErrorKey:moveError}]];
return;
}
// Make sure the downloaded archive we moved over is a regular file and not a symbolic link placed by an attacker
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Error: Failed to retrieve download archive path from %@",downloadDestinationURL]}]];
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Error: Failed to retrieve download archive attributes from %@",downloadDestinationPath]}]];
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Error: Received bad archive file type: %@",archiveAttributes[NSFileType]]}]];
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Error: Failed to create installation extraction directory in %@",cacheInstallationPath]}]];
return;
}
// Carry these properties separately rather than using the SUInstallationInputData object
// Some of our properties may slightly differ than our input and we don't want to make the mistake of using one of those
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:@"Error: Failed to start installer",NSUnderlyingErrorKey:firstStageError}]];
[selfcleanupAndExitWithStatus:EXIT_FAILUREerror:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SPUInstallerErroruserInfo:@{NSLocalizedDescriptionKey:@"Failed to finalize installation",NSUnderlyingErrorKey:thirdStageError}]];
});
return;
}
self->_performedStage3Installation=YES;
dispatch_async(dispatch_get_main_queue(),^{
// Make sure to stop our displayed progress before we move onto cleanup & relaunch
// This will also stop the agent from broadcasting the status info service, which we want to do before
// we relaunch the app because the relaunched app could check the service upon launch..
// Closes file for reading/writing, called in -dealloc if it's not called manually
-(void)close;
// For reading
// Retrieves metadata for the archive including major/minor version and expected bundle hashes
-(nullableSPUDeltaArchiveHeader*)readHeader;
// Enumerate through items in the patch file and read the path, attributes, permissions (if permission attribute is available), and way to stop enumeration
Modern container format for binary delta archives.
Delta archive format has four sections which are the header, the relative file path table, the commands, and the data blobs.
The relative file path table records all the file paths the archive needs to know about.
The commands are the operations to be recorded (eg: extract, clone, binary diff, delete).
The commands may additionally have more metadata such as file permission modes, relative path indexes in the case of clones, or file sizes for the data blobs.
The data blobs contain all file data from extract and binary diff outputs.
The implementation design of this archive is such that we do not seek backwards or skip ahead to fetch data.
We go through the archive when writing or reading from it in a single pass.
-- UNCOMPRESSED --
[ HEADER (part 1) ]
magic (length: 4)
compression (length: 1)
metadata (See format below. length: 1)
-- METADATA --
compressionLevel (bits [0, 4])
(bits [5, 6] reserved)
fileSystemCompression (bit 7)
-- COMPRESSED --
[ HEADER (part 2)]
majorVersion (length: 2)
minorVersion (length: 2)
beforeTreeHash (length: 40)
afterTreeHash (length: 40)
[ RELATIVE_FILE_PATH_TABLE ]
sizeOfRelativeFilePathTable (length: 8 bytes)
List of null terminated path strings joined together (N paths)
[ COMMANDS ]
[ Command ]
Set of command types for entry (length: 1 byte)
Additional metadata for command (see below section)
(M commands where M <= N paths)
(Indexes for commands refer to indexes to relative file path table, excluding extraneous trailing entries in relative path table used for clones)
(Last command must be a ZERO COMMAND (a null terminating command))
[COMMAND METADATA]
[COMMAND: DELETE]
N/A: no additional data
[COMMAND: MODIFY_PERMISSIONS]
fileMode (length: 2)
[COMMAND: CLONE_FILE]
sourceRelativePathIndex (length: 4)
[COMMAND: EXTRACT_FILE]
dataLength (length: 8 for regular files, 2 for symbolic links, 0 for directories)
[COMMAND: BINARY_DIFF_FILE]
dataLength (length: 8)
Note: These command types may be OR'd or combined. In those cases, different commands
that have the same attribute (eg dataLength) are not repeated. This list of metadata is also
in order in what will be encoded/decoded first.
EXTRACT_FILE and BINARY_DIFF_FILE cannot be combined.
CLONE_FILE and EXTRACT_FILE cannot be combined.
MODIFY_PERMISSIONS can be combined with either CLONE_FILE, EXTRACT_FILE, BINARY_DIFF_FILE, or just by itself.
CLONE_FILE can be combined with BINARY_DIFF_FILE or just by itself.
DELETE can be combined with EXTRACT_FILE, or just by itself. It is only combined with EXTRACT_FILE when the file type (regular, directory, or symlink) changes.
[ DATA_BLOBS ]
All raw binary data joined together
(P number of blobs where P <= M commands)
(Indexes for data blobs correspond to indexes for a filtered list of applicable commands (EXTRACT_FILE, BINARY_DIFF_FILE) that have data content)
_error=[NSErrorerrorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAINcode:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_OPEN_FAILUREuserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Failed to xar_open() file for reading: %@",patchFile]}];
_error=[NSErrorerrorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAINcode:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_OPEN_FAILUREuserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Failed to xar_open() file for writing: %@",patchFile]}];
_error=[NSErrorerrorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAINcode:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_UNSUPPORTED_COMPRESSION_FAILUREuserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Version 2 patches only support bzip2 compression."]}];
_error=[NSErrorerrorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAINcode:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_ADD_FAILUREuserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Failed to add xar file entry: %@",relativeFilePath]}];
_error=[NSErrorerrorWithDomain:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_DOMAINcode:SPARKLE_DELTA_XAR_ARCHIVE_ERROR_CODE_EXTRACT_FAILUREuserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Failed to extract xar file entry to %@",item.itemFilePath]}];
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileReadCorruptFileErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Unable to identify diff-version %u in delta. Giving up.",majorDiffVersion]}];
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileReadCorruptFileErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Applying version %u patches is no longer supported.",majorDiffVersion]}];
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileReadUnknownErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"A later version is needed to apply this patch (on major version %u, but patch requests version %u).",SUBinaryDeltaMajorVersionLatest,majorDiffVersion]}];
}
returnNO;
}
// Reject patches that did not generate valid hierarchical xar container paths
// These will not succeed to patch using recent versions of BinaryDelta
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileReadCorruptFileErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"This patch version (%u.%u) is too old and potentially unsafe to apply. Please re-generate the patch using the latest version of BinaryDelta or generate_appcast. New version %u.%u patches will still be compatible with older versions of Sparkle.",majorDiffVersion,minorDiffVersion,majorDiffVersion,latestMinorVersionForMajorVersion(majorDiffVersion)]}];
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileReadCorruptFileErroruserInfo:@{NSLocalizedDescriptionKey:@"Unable to find before-sha1 or after-sha1 metadata in delta. Giving up."}];
}
returnNO;
}
if(verbose){
fprintf(stderr,"Applying version %u.%u patch...\n",majorDiffVersion,minorDiffVersion);
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileReadUnknownErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Unable to calculate hash of tree %@",source]}];
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileWriteUnknownErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Failed to remove %@",destination]}];
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileWriteUnknownErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Failed to copy %@ to %@",source,destination]}];
}
returnNO;
}
// Preserve file creation date only for the root item if the date is recorded
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileWriteUnknownErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Failed to create patch because '%@' cannot be converted to file system path.",cumulativePath]}];
// Directory doesn't exist, so it can't be a symlink - safe to continue
break;
}
if(error!=NULL){
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileWriteUnknownErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Failed to create patch because failed to stat '%@' with error: %d",cumulativePath,errno]}];
}
*stop=YES;
return;
}
if(S_ISLNK(cumulativePathStat.st_mode)){
if(error!=NULL){
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileWriteUnknownErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Failed to create patch because '%@' cannot contain a symbolic link in its intermediate path.",destinationFilePath.stringByDeletingLastPathComponent]}];
// Files that have no property set that we check for will get ignored
// This is important because they aren't part of the delta, just part of the directory structure
SPUDeltaItemCommandscommands=item.commands;
if((commands&SPUDeltaItemCommandDelete)!=0){
if(!removeTree(destinationFilePath)){
if(verbose){
fprintf(stderr,"\n");
}
if(error!=NULL){
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileWriteUnknownErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"delete: failed to remove %@",destination]}];
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileWriteUnknownErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Unable to extract diffed file to %@",tempDiffFile],NSUnderlyingErrorKey:(NSError*_Nonnull)archive.error}];
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileWriteUnknownErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Unable to patch %@ to destination %@",sourceFilePath,destinationFilePath]}];
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileWriteUnknownErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Unable to retrieve stat info from %@",sourceFilePath]}];
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileWriteNoPermissionErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Unable to modify permissions (%u) on file %@",sourceFileInfo.st_mode,destinationFilePath]}];
}elseif((commands&SPUDeltaItemCommandExtract)!=0){// extract and permission modifications don't coexist
item.itemFilePath=destinationFilePath;
if(![archiveextractItem:item]){
if(verbose){
fprintf(stderr,"\n");
}
if(error!=NULL){
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileWriteUnknownErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Unable to extract file to %@",destinationFilePath],NSUnderlyingErrorKey:(NSError*_Nonnull)archive.error}];
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileWriteNoPermissionErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Unable to modify permissions (%u) on file %@",mode,destinationFilePath]}];
*error=[NSErrorerrorWithDomain:NSCocoaErrorDomaincode:NSFileReadUnknownErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Unable to calculate hash of tree %@",finalDestination]}];
// Additional compression methods for version 3 or 4 patches that we have for debugging are zlib, bzip2, none
#define COMPRESSION_METHOD_ARGUMENT_DESCRIPTION @"The compression method to use for generating delta updates. Supported methods for version 3 delta files are 'lzma' (best compression, slowest), 'lzfse' (good compression, fast), 'lz4' (worse compression, fastest), and 'default'. Note that version 2 delta files only support 'bzip2', and 'default' so other methods will be ignored if version 2 files are being generated. The 'default' compression for version 3 or 4 delta files is currently lzma."
//#define COMPRESSION_LEVEL_ARGUMENT_DESCRIPTION @"The compression level to use for generating delta updates. This only applies if the compression method used is bzip2 which accepts values from 1 - 9. A special value of 0 will use the default compression level."
// This is the same as CC_SHA1_DIGEST_LENGTH
// Major versions >= 4 use a crc32 hash (using a subset of these bytes) while older versions use a sha1 hash
NSString*message=@"The host app is signed, but the new version of the app is not signed using Apple Code Signing. Please ensure that the new app is signed and that archiving did not corrupt the signature.";
initialMessage=[NSStringstringWithFormat:@"Code signature of the new version doesn't match the old version: %@. Please ensure that old and new app is signed using exactly the same certificate.",requirementString];
SULog(SULogLevelError,@"%@",initialMessage);
CFRelease(requirementString);
}else{
initialMessage=@"Code signature of new version doesn't match the old version. Please ensure that old and new app is signed using exactly the same certificate.";
SULog(SULogLevelError,@"Failed to get static code %d",result);
if(error!=NULL){
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUInsufficientSigningErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Failed to get static code for verifying code signature: %d",result]}];
}
gotofinally;
}
// See in -codeSignatureIsValidAtBundleURL:andMatchesSignatureAtBundleURL:error: for why kSecCSCheckNestedCode is not always passed
NSString*commonErrorMessage=@"The download archive cannot be validated with Apple Developer ID code signing as fallback (after (Ed)DSA verification has failed)";
resultError=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUInsufficientSigningErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"%@. The team identifier could not be retrieved from the original app: %@",commonErrorMessage,oldBundleURL.path]}];
gotofinally;
}
// Create a designated requirement with developer ID signing with this team ID
// Validate it against code signing check of this archive
// CertificateIssuedByApple = anchor apple generic
requirementString=[NSStringstringWithFormat:@"anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] and certificate leaf[field.1.2.840.113635.100.6.1.13] and certificate leaf[subject.OU] = \"%@\"",teamIdentifier];
resultError=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUInsufficientSigningErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"%@. The designated requirement string with a Developer ID requirement with team identifier '%@' could not be created with error %d",commonErrorMessage,teamIdentifier,result]}];
NSString*message=[NSStringstringWithFormat:@"%@. The static code could not be retrieved from the download archive with error %d. The download archive may not be Apple code signed.",commonErrorMessage,result];
NSString*initialMessage=[NSStringstringWithFormat:@"%@. The Apple code signature of new downloaded archive is either not Developer ID code signed, or doesn't have a Team ID that matches the old app version (%@). Please ensure that the archive and app are signed using the same Developer ID certificate.",commonErrorMessage,teamIdentifier];
userInfo[NSLocalizedDescriptionKey]=[NSStringstringWithFormat:@"%@. The downloaded archive code signing signature failed to validate with an unknown error (%d).",commonErrorMessage,result];
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUInsufficientSigningErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"The client connection could not be validated because SecCodeCopyGuestWithAttributes() failed with error %d",result]}];
}
returnSUValidateConnectionStatusAPIFailure;
}
// Check if the client is code signed with our signing requirement
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUInsufficientSigningErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"The client connection could not be validated because SecRequirementCreateWithString() failed with error %d",result]}];
}
returnSUValidateConnectionStatusAPIFailure;
}
CFErrorRefcfError=NULL;
// This is not a static code, so we don't pass kSecCSCheckAllArchitectures
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUInsufficientSigningErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"The client connection could not be validated because validating the code signature failed with error %d (%@). Does the app meet the designated requirement: %@",result,cfBridgedError.localizedDescription,codeSigningRequirement]}];
SULog(SULogLevelError,@"hdiutil failed with code: %ld data: <<%@>>",(long)taskResult,resultStr);
error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUUnarchivingErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Extraction failed due to hdiutil returning %ld status: %@",(long)taskResult,resultStr]}];
gotoreportError;
}
mountedSuccessfully=YES;
// Mounting can take some time, so increment progress
[notifiernotifyFailureWithError:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUUnarchivingErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Flat package does not have guided installation type but %@ instead",_expectedInstallationType]}]];
[notifiernotifyFailureWithError:[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUUnarchivingErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Flat package does not exist at %@",_flatPackagePath]}]];
}else{
// Copying the flat package should be very fast, especially on APFS
NSMutableDictionary*userInfoDictionary=[NSMutableDictionarydictionaryWithDictionary:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Flat package (%@) cannot be copied to extraction directory (%@)",_flatPackagePath,_extractionDirectory]}];
// Copyright 2010 Dragon Systems Software Limited. All rights reserved.
//
/**
# Sparkle Guided Installations
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 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.
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUInstallationErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Guided package installer returned non-zero exit status (%d)",task.terminationStatus]}];
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUMissingUpdateErroruserInfo:@{NSLocalizedDescriptionKey:@"Couldn't find an appropriate update in the downloaded package."}];
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUMissingUpdateErroruserInfo:@{NSLocalizedDescriptionKey:@"The "@SPARKLE_RELAUNCH_TOOL_NAME" executable path failed to be retrieved, which is an internal error that shouldn't happen. Please try to update using a production build of your app."}];
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUMissingUpdateErroruserInfo:@{NSLocalizedDescriptionKey:@"The host bundle path to update to be retrieved, which is an internal error that shouldn't happen. Please try to update using a production build of your app."}];
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUMissingUpdateErroruserInfo:@{NSLocalizedDescriptionKey:@"File attributes failed to be retrieved from the "@SPARKLE_RELAUNCH_TOOL_NAME" executable, which is an internal error that shouldn't happen. Please try to update using a production build of your app."}];
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUMissingUpdateErroruserInfo:@{NSLocalizedDescriptionKey:@"File owner ID failed to be retrieved from the "@SPARKLE_RELAUNCH_TOOL_NAME" executable, which is an internal error that shouldn't happen. Please try to update using a production build of your app."}];
}
returnnil;
}
// Check our helper is owned by root
if(![installerOwnerIDisEqual:@(0)]){
if(error!=NULL){
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUMissingUpdateErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Due to security, updating apps with package installers is disabled when '%@' is not signed with the same Team ID as your app, and "@SPARKLE_RELAUNCH_TOOL_NAME" is not owned by root (this specific case) or not residing in '%@'. Please either test an exported & production build of your app, or for development, code sign your app and Sparkle's embedded helpers with the same team: https://sparkle-project.org/documentation/sandboxing#code-signing",installerExecutablePath,hostBundlePath]}];
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUMissingUpdateErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Due to security, updating apps with package installers is disabled when '%@' is not signed with the same Team ID as your app, and "@SPARKLE_RELAUNCH_TOOL_NAME" is not owned by root or not residing in '%@' (this specific case). Please either test an exported & production build of your app, or for development, code sign your app and Sparkle's embedded helpers with the same team: https://sparkle-project.org/documentation/sandboxing#code-signing",installerExecutablePath,hostBundlePath]}];
}
returnnil;
}
// Check out helper resides inside the host app to be updated
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUMissingUpdateErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Due to security, updating apps with package installers is disabled when '%@' is not signed with the same Team ID as your app, and "@SPARKLE_RELAUNCH_TOOL_NAME" is not owned by root or not residing in '%@' (this specific case). Please either test an exported & production build of your app, or for development, code sign your app and Sparkle's embedded helpers with the same team: https://sparkle-project.org/documentation/sandboxing#code-signing",installerExecutablePath,hostBundlePath]}];
}
returnnil;
}
}
#else
(void)connectionCodeSigningValidationSkipped;
#endif
// Make sure we find the type of installer that we were expecting to find
// We shouldn't implicitly trust the installation type fed into here from the appcast because the installation type helps us determine
// ahead of time whether or not this installer tool should be ran as root or not
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUInstallationErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Found guided package installer but '%@=%@' was probably missing in the appcast item enclosure",SUAppcastAttributeInstallationType,SPUInstallationTypeGuidedPackage]}];
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUInstallationErroruserInfo:@{NSLocalizedDescriptionKey:@"Found interactive package installer (with 'sparkle_interactive' in the filename) but these are no longer supported. Please remove 'sparkle_interactive' from the filename."}];
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUInstallationErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Found regular application update but expected '%@=%@' from the appcast item enclosure instead",SUAppcastAttributeInstallationType,expectedInstallationType]}];
// If we have a normalized path, we'll install to "#{CFBundleName}.app", but only if that path doesn't already exist. If we're "Foo 4.2.app," and there's a "Foo.app" in this directory, we don't want to overwrite it! But if there's no "Foo.app," we'll take that name.
// Otherwise if there's no normalized path (the more likely case), we'll just use the host bundle's path
// Check progress agent app which computes normalized path too according to these rules
// This may fail due to a write PIPE error but we don't currently support extracting archives that have
// extraneous data leftover because these may be corrupt.
// We don't want to later workaround extraction by not piping the data.
NSError*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUUnarchivingErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Extraction failed, command '%@' got only %ld of %ld bytes",command,(long)bytesWritten,(long)expectedLength]}];
SULog(SULogLevelError,@"Failed to perform installation because either installation URL (%@) or new URL (%@) is nil",installationURL,newURL);
if(error!=NULL){
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUInstallationErroruserInfo:@{NSLocalizedDescriptionKey:@"Failed to perform installation because the paths to install at and from are not valid"}];
NSMutableDictionary*userInfo=[NSMutableDictionarydictionaryWithDictionary:@{NSLocalizedDescriptionKey:@"Failed to recursively update new application's modification time before moving into temporary directory"}];
SULog(SULogLevelError,@"Failed to construct URL from bundle path: %@",host.bundlePath);
if(error!=NULL){
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUInstallationErroruserInfo:@{NSLocalizedDescriptionKey:@"Failed to perform installation because a path could not be constructed for the old installation"}];
}
returnNO;
}
if(progress){
progress(2/11.0);
}
NSURL*tempNewDirectoryURL;
if(!_newAndOldBundlesOnSameVolume){
// Create a temporary directory for our new app that resides on our destination's volume
// We use oldURL here instead of installationURL because in the case of normalization, installationURL may not exist
// And we don't want to use either of the URL's parent directories because the parent directory could be on a different volume
NSMutableDictionary*userInfo=[NSMutableDictionarydictionaryWithDictionary:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Failed to move the new app from %@ to its temp directory at %@",newURL.path,newFinalURL.path]}];
SULog(SULogLevelError,@"Failed to retrieve last path component from old URL: %@",oldURL.path);
if(error!=NULL){
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUInstallationErroruserInfo:@{NSLocalizedDescriptionKey:@"Failed to perform installation because the last path component of the old installation URL could not be constructed."}];
NSMutableDictionary*userInfo=[NSMutableDictionarydictionaryWithDictionary:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Failed to move the old app at %@ to a temporary location at %@",oldURL.path,oldTempURL.path]}];
NSMutableDictionary*userInfo=[NSMutableDictionarydictionaryWithDictionary:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"Failed to move new app at %@ to final destination %@",newFinalURL.path,installationURL.path]}];
NSString*errorMessage=[NSStringstringWithFormat:@"For security reasons, updates that downgrade version of the application are not allowed. Refusing to downgrade app from version %@ to %@. Aborting update.",hostVersion,updateVersion];
SULog(SULogLevelDefault,@"Skipping atomic rename/swap and gatekeeper scan because new update %@ has a custom NSUpdateSecurityPolicy",bundle.bundleURL.lastPathComponent);
}else{
SULog(SULogLevelDefault,@"Skipping atomic rename/swap and gatekeeper scan because Autoupdate is not signed with same identity as the new update %@",bundle.bundleURL.lastPathComponent);
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUValidationErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"No signatures given to verify data for %@",fileKind]}];
NSString*message=[NSStringstringWithFormat:@"The %@ has an EdDSA signature, but the app has an invalid EdDSA public key, so the %@ will automatically be rejected.",fileKind,fileKind];
SULog(SULogLevelDefault,@"The app has an invalid EdDSA public key, but there is no EdDSA signature in the %@. Falling back to DSA.",fileKind);
break;
caseSUSigningInputStatusPresent:
switch(signatures.ed25519SignatureStatus){
caseSUSigningInputStatusAbsent:{
NSString*message=[NSStringstringWithFormat:@"The app has an EdDSA public key, but there is no EdDSA signature in the %@, so the %@ will be rejected.",fileKind,fileKind];
NSString*message=[NSStringstringWithFormat:@"The %@ has an EdDSA signature, but it's invalid, so the %@ will automatically be rejected.",fileKind,fileKind];
NSMutableString*message=[NSMutableStringstringWithFormat:@"EdDSA signature does not match. Data of the %@ being checked is different than data that has been signed, or the public key and the private key are not from the same set.",fileKind];
// Elaborate on the error message if we have more information about the download archive
// If there is verifierInformation it must be for a downloaded update (rather than feed or release notes)
[messageappendFormat:@" The downloaded %@ is likely different than the signed file because the expected content length from the appcast item (%llu bytes) differs from the downloaded file length (%llu bytes).",downloadedFileDescription,verifierInformation.expectedContentLength,verifierInformation.actualContentLength];
[messageappendFormat:@" The downloaded %@ also has a CFBundleVersion (%@) which differs from the %@ in the appcast item (%@).",downloadedFileDescription,actualVersion,SUAppcastAttributeVersion,verifierInformation.expectedVersion];
[messageappendFormat:@" The downloaded %@ is likely not signed correctly because the file has the expected content length (%llu bytes)%@ which matches the appcast item.",downloadedFileDescription,verifierInformation.actualContentLength,(actualVersion==nil?@"":[NSStringstringWithFormat:@" and CFBundleVersion (%@)",actualVersion])];
}
}
SULog(SULogLevelError,@"%@",[messagecopy]);
#if SPARKLE_BUILD_LEGACY_DSA_SUPPORT
// Legacy DSA verification is only applicable if archive file path is provided
// We don't keep track of DSA signatures, so we will ignore this mistake and treat it as if it were absent
break;
caseSUSigningInputStatusPresent:
if(error!=NULL){
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUValidationErroruserInfo:@{NSLocalizedDescriptionKey:@"The old app has a DSA public key but DSA support is disabled, and the old app does not have an EdDSA public key."}];
}
returnNO;
}
#endif
if(error!=NULL){
// Use generic failure
*error=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUValidationErroruserInfo:@{NSLocalizedDescriptionKey:[NSStringstringWithFormat:@"EdDSA and DSA verification for the %@ has failed",fileKind]}];
SULog(SULogLevelError,@"Invalid arguments to verifyStream");
if(outError!=NULL){
*outError=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUValidationErroruserInfo:@{NSLocalizedDescriptionKey:@"Invalid arguments to verifyStream"}];
}
returnNO;
}
SecKeyRefdsaPubKeySecKey=[selfdsaSecKeyRef];
if(!dsaPubKeySecKey){
if(outError!=NULL){
*outError=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUValidationErroruserInfo:@{NSLocalizedDescriptionKey:@"Failed to create DSA Sec Key Ref"}];
*outError=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUValidationErroruserInfo:@{NSLocalizedDescriptionKey:@"File containing update archive could not be read (failed to create SecTransform for input stream)"}];
*outError=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUValidationErroruserInfo:@{NSLocalizedDescriptionKey:@"File containing update archive could not be read (failed to create SecDigest for input stream)"}];
*outError=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUValidationErroruserInfo:@{NSLocalizedDescriptionKey:@"Failed to connect data read transform",NSUnderlyingErrorKey:(__bridgeNSError*)error}];
*outError=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUValidationErroruserInfo:@{NSLocalizedDescriptionKey:@"Failed to connect data digest transform",NSUnderlyingErrorKey:(__bridgeNSError*)error}];
*outError=[NSErrorerrorWithDomain:SUSparkleErrorDomaincode:SUValidationErroruserInfo:@{NSLocalizedDescriptionKey:@"DSA signature does not match. Data of the update file being checked is different than data that has been signed, or the public key and the private key are not from the same set"}];
NSMutableDictionary*userInfo=[NSMutableDictionarydictionaryWithObject:@"An error occurred while extracting the archive. Please try again later."forKey:NSLocalizedDescriptionKey];
@Option(name:.long,help:ArgumentHelp("The major version of the patch to generate. Defaults to the latest stable version. Older versions will need to be specified for updating from applications using older versions of Sparkle.",valueName:"version"))
fputs(" with level \(header.compressionLevel)",stdout)
}
}
fputs("\n",stdout)
}else{
fputs("Error: Failed to retrieve header due to unknown reason.\n",stderr)
throwExitCode(1)
}
}else{
//Printversionofprogram
fputs("BinaryDelta version \(SUBinaryDeltaMajorVersionLatest.rawValue).\(latestMinorVersionForMajorVersion(SUBinaryDeltaMajorVersionLatest))\n",stdout)
}
}
}
structBinaryDelta:ParsableCommand{
staticletconfiguration=CommandConfiguration(commandName:"BinaryDelta",abstract:"Create and apply small and efficient delta patches between an old and new version of a bundle.",subcommands:[Create.self,Apply.self,Info.self])
Loaded 100 of 815 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.