Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
luckman212 opened this issue Mar 6, 2024 · 8 comments
Labels
bug docs Documentation should reproduce Should try to reproduce the problem
Milestone

Comments

@luckman212
Copy link

luckman212 commented Mar 6, 2024

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:

@luckman212 luckman212 changed the title How can we specify an alternate syncthing Executable? Can we specify an alternate syncthing Executable? Mar 6, 2024
xor-gate pushed a commit that referenced this issue Mar 6, 2024
@xor-gate
Copy link
Member

xor-gate commented Mar 6, 2024

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.

@luckman212
Copy link
Author

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 xor-gate added bug should reproduce Should try to reproduce the problem labels Mar 8, 2024
@xor-gate xor-gate added this to the Next milestone Mar 8, 2024
@xor-gate xor-gate added the docs Documentation label Mar 8, 2024
@xor-gate xor-gate changed the title Can we specify an alternate syncthing Executable? Override of syncthing Executable from .app to custom filesystem path via NSUserDefaults resets always back to bundle path Mar 8, 2024
@xor-gate
Copy link
Member

@luckman212
Copy link
Author

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

@luckman212
Copy link
Author

@xor-gate LGTM ! 👍

screenshot_K0yOvWhb

@xor-gate
Copy link
Member

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

@luckman212
Copy link
Author

this was modified without testing

😱

@xor-gate
Copy link
Member

xor-gate commented Apr 3, 2024

It would be nice to have it also in the documentation README for power users.

@xor-gate xor-gate reopened this Apr 3, 2024
@xor-gate xor-gate modified the milestones: v1.27.4-2, Next Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug docs Documentation should reproduce Should try to reproduce the problem
Projects
None yet
Development

No branches or pull requests

2 participants