Draft
Conversation
NotNite
reviewed
Dec 16, 2024
40593c9 to
8025fae
Compare
I missed that hookUpdaterForPersistence (FKA persistAsar) merely hooks into the updater, so we need to run it inside of the hooked emit method. Those are synchronous, so our shelling out to codesign(1) needs to be synchronous, too. This blocks the updater. Not sure if this can somehow be async instead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch aims to implement proper persistence on Darwin (macOS) by reapplying the injector when an update finishes. It also forcibly signs the bundle to ensure that it has a stable Designated Requirement, which is important for e.g. screen sharing and keybinds to work consistently.
Currently, it's hardcoded to use a code signing identity named
Moonlight. This should be made configurable at some point.This doesn't work at the moment because it introduces some kind of race against the app becoming ready:
The code signing process succeeds, but by the time
registerSchemesAsPrivilegedruns (a function in Discord's ASAR) the app is already ready for some reason.As I was repeatedly re-running this I managed to get past the error and get this one:
According to Squirrel, the update bundle needs to match the DR of the target bundle, so we might need to actually sign Discord in moonlight's installer. Doing it from within core seems a bit precarious because macOS might not recognize the designated requirement changing on the fly like that.