Skip to content

fix(update): give staged plugin dir the plugin home's permissions - #833

Merged
linghengqian merged 2 commits into
version-fox:mainfrom
draarivpatel-ui:fix/update-plugin-dir-mode
Nov 26, 2026
Merged

linghengqian merged 2 commits into
version-fox:mainfrom
draarivpatel-ui:fix/update-plugin-dir-mode

Conversation

@draarivpatel-ui

Copy link
Copy Markdown
Contributor

Summary

Fixes #829.

installPluginToTemp stages plugins in an os.MkdirTemp directory, which is always created with mode 0700. Update then moves that directory into Shared.Plugins via util.MovePath without changing its mode, so a vfox update leaves the plugin directory at 0700 and every other user sharing the VFOX_HOME loses read and execute access to it.

Add already chmods the staged directory to the plugin home's mode before the move. This change factors that logic into Manager.matchPluginsDirMode and calls it on the update path too, so both paths normalize the staged directory's permissions the same way.

Testing

  • Added TestUpdatePluginDirTakesPluginHomePermissions, which installs a plugin, updates it through the registry path, and asserts the resulting plugin directory has the plugin home's permission bits. It failed before the fix (mode = 700, want 755) and passes after.
  • go test ./internal/ passes.

The update path staged the plugin in an os.MkdirTemp directory (mode
0700) and moved it into place without touching the mode, so the updated
plugin ended up unreadable and unexecutable for every other user
sharing the VFOX_HOME. The add path already chmods the staged directory
to the plugin home's mode; factor that out and apply it on update too.

Fixes version-fox#829
Copilot AI balanced review requested due to automatic review settings November 24, 2026 19:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.77778% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.16%. Comparing base (43acf4e) to head (6479de8).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
internal/manager.go 77.77% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #833      +/-   ##
==========================================
+ Coverage   61.98%   63.16%   +1.18%     
==========================================
  Files         125      125              
  Lines        9810     9910     +100     
==========================================
+ Hits         6081     6260     +179     
+ Misses       3207     3119      -88     
- Partials      522      531       +9     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@linghengqian linghengqian 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.

Not ready to merge at d096934.

matchPluginsDirMode sets the mode on the staging directory before util.MovePath runs. That only holds when the move is a rename. When the staging directory and VFOX_HOME are on different filesystems, MovePath falls back to copyDir (internal/shared/util/file.go:194), and copyDir creates the top-level directory with os.MkdirAll(dst, info.Mode().Perm()) (file.go:199). The umask applies to that call, so the mode the helper set is lost.

Reproduced with VFOX_HOME on a different filesystem from $HOME and umask 077: after vfox update tool, the plugin directory is 700 while the plugin home is 755. The same update with umask 022, or with both directories on one filesystem, leaves the directory at 755.

Suggested fix: apply the mode to the installed path after the move has succeeded, in Update (internal/manager.go:355-357) and in Add (internal/manager.go:719-721). That covers the rename and the copy path. The new test puts both directories under one t.TempDir(), so it only exercises the rename path. A case that goes through the copy path would keep this from coming back.

@linghengqian linghengqian added this to the 1.1.1 milestone Nov 24, 2026
The staging chmod only held when the move was a rename. On a
cross-filesystem move, MovePath falls back to copyDir, which creates the
top-level directory through os.MkdirAll, and the umask masks the mode
back down: with umask 077 the updated plugin ended at 0700 while the
plugin home was 0755. Apply the mode to the installed path after the
move in Update and Add so both the rename and the copy path keep it.

The new test stages on /dev/shm, a filesystem separate from the plugin
home, under umask 077, so the copy path stays covered.
@draarivpatel-ui

Copy link
Copy Markdown
Contributor Author

Thanks for the careful review, @linghengqian. You were right about the copy path: the staging chmod only survived a rename, and a cross-filesystem move lost the mode to the umask in copyDir's os.MkdirAll.

Reworked in 6479de8:

  • Update and Add now apply the plugin home's mode to the installed path after the move has succeeded, so the rename and the copy path are both covered.
  • Added a regression test that stages on /dev/shm (a filesystem separate from the plugin home) under umask 077, so the move really goes through the copy path. Verified it fails with the pre-fix ordering (plugin dir 700 vs plugin home 755, matching your repro) and passes with the fix.

@linghengqian linghengqian added bug Something isn't working and removed need-more-info labels Nov 26, 2026

@linghengqian linghengqian 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

@linghengqian
linghengqian merged commit f690dc6 into version-fox:main Nov 26, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: installPluginToTemp creates plugin directory with mode 0700, blocking shared VFOX_HOME users

3 participants