Skip to content

cmd/syncthing: Work around binary in current dir restriction (fixes #8499) - #8500

Merged
imsodin merged 4 commits into
syncthing:mainfrom
imsodin:cmd/exec-local-dir
Aug 14, 2022
Merged

imsodin merged 4 commits into
syncthing:mainfrom
imsodin:cmd/exec-local-dir

Conversation

@imsodin

@imsodin imsodin commented Aug 13, 2022

Copy link
Copy Markdown
Member

Apparently there's an exec.ErrDot error handling this case and it should return the local path in that case, however I did not get that behaviour playing around with it (exec.LookupPath("test.sh") returned ErrNotFound). So I just "manually" handled it regardless of what the error is.

@tomasz1986

Copy link
Copy Markdown
Member

Perfect 🙂. Just tested, and everything seems to work as expected.

@calmh calmh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this should be scoped to windows only and perhaps look specifically in the directory the executable lives in rather than dot...

@imsodin

imsodin commented Aug 14, 2022

Copy link
Copy Markdown
Member Author

Changed it to be windows only (hoping no-one will find a way to run a local binary on unixes without the ./ prefix :) ).

Not sure what you mean with the directory/dot: This restriction is specifically about the binary being in the current directory/dot, and not being a path. Checking in $PWD/<binary> and ./<binary> should be equivalent, right?

@calmh

calmh commented Aug 14, 2022 •

Copy link
Copy Markdown
Member

Yeah I guess what I meant is that in the general case we're interested in running the same binary as the monitor. There's a library call to get the directory of the currently running binary. That's probably where we should look, and whether dot is in the path or the binary is in $PWD then doesn't really matter?

@calmh calmh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Looking at this from a higher level it seems to me we should always use os.Executable and only resort to a PATH search if that's unavailable for some reason... but that's a behaviour change and this is a bug fix 🤷

@imsodin
imsodin merged commit 5fd6278 into syncthing:main Aug 14, 2022
@imsodin
imsodin deleted the cmd/exec-local-dir branch August 14, 2022 19:25
calmh added a commit to calmh/syncthing that referenced this pull request Aug 17, 2022
* main:
  cmd/syncthing: Use os.executable in monitor, only fallback to PATH (syncthing#8502)
  all: Modernize error wrapping (syncthing#8491)
  gui, man, authors: Update docs, translations, and contributors
  cmd/syncthing: Work around binary in current dir restriction (fixes syncthing#8499) (syncthing#8500)
  lib/fs: Cache user lookups (syncthing#8496)
  all: Make scanning ownership opt-in (syncthing#8497)
calmh added a commit to calmh/syncthing that referenced this pull request Aug 18, 2022
* main: (256 commits)
  cmd/syncthing: Use os.executable in monitor, only fallback to PATH (syncthing#8502)
  all: Modernize error wrapping (syncthing#8491)
  gui, man, authors: Update docs, translations, and contributors
  cmd/syncthing: Work around binary in current dir restriction (fixes syncthing#8499) (syncthing#8500)
  lib/fs: Cache user lookups (syncthing#8496)
  all: Make scanning ownership opt-in (syncthing#8497)
  lib/model: Skip paused folders in aggregated completion loop (fixes syncthing#8219) (syncthing#8220)
  gui: Remove unused strings from translations (syncthing#8288)
  gui, api: Show internal config and state paths (fixes syncthing#8323) (syncthing#8324)
  build(deps): bump github.com/go-ldap/ldap/v3 from 3.4.1 to 3.4.4 (syncthing#8475)
  build: bump actions/setup-go from 2.2.0 to 3.2.1 (syncthing#8492)
  build: Let dependabot suggest updates to GitHub actions (syncthing#8490)
  update: Go version in update-docs-translations action (syncthing#8489)
  gui, man, authors: Update docs, translations, and contributors
  cmd/syncthing: Refactor CLI code to allow passing CLI arguments via function parameter (syncthing#8485)
  build: Update quic-go for Go 1.19 (syncthing#8483)
  lib/ur: Properly initialize map in failure data (fixes syncthing#8479) (syncthing#8480)
  lib/ur: Properly initialize map in failure data (fixes syncthing#8479)
  gui, man, authors: Update docs, translations, and contributors
  docs: Clarify docker network mode limitations (syncthing#8472)
  ...
@calmh calmh added this to the v1.21.0 milestone Aug 23, 2022
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Aug 15, 2023
@syncthing syncthing locked and limited conversation to collaborators Aug 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants