syncthing/syncthing-macos

Override of `syncthing` Executable from .app to custom filesystem path via NSUserDefaults resets always back to bundle path

luckman212 opened this issue ยท 8 comments

I've been running a custom compiled syncthing binary until syncthing/syncthing#9430 is pulled into a release.

Today I replaced my macOS bundle with v1.27.4, and could no longer run the app due to Gatekeeper. Ugh.

I saw in the NSPrefs that there is a key to specify the Executable:

$ defaults read com.github.xor-gate.syncthing-macosx Executable
/Applications/Syncthing.app/Contents/Resources/syncthing/syncthing

But trying to set it:

$ defaults write com.github.xor-gate.syncthing-macosx Executable -string /usr/local/bin/syncthing

I found it immediately reverts back to the default one. Seems due to this code:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
_executable = [NSString stringWithFormat:@"%@/%@",
[[NSBundle mainBundle] resourcePath],
@"syncthing/syncthing"];
[defaults setValue:_executable forKey:@"Executable"];

Is there an env var or any other supported way to override the default syncthing binary with the app bundle?

related:

See my commit above in the issue branch. I think it was because it was always set, instead try load. Then set when empty. It is untested, currently I have no environment to build dmg setup on my system. And the continuous integration with github actions doesn't create DMG in debug mode. Have a look.

Looks like that will work! I can't test right at this moment but will try ASAP.

In the meantime, I found that stripping com.apple.quarantine from the bundle, running the app and THEN replacing the syncthing binary seems to make Gatekeeper happy. It only checks for modifications to codesigned binaries upon first launch? TIL.

@xor-gate I will test by tomorrow, thank you for the build.

@xor-gate LGTM ! ๐Ÿ‘

screenshot_K0yOvWhb

Great, this was modified without testing. But it was an easy fix :-)

this was modified without testing

๐Ÿ˜ฑ