Backing up a hook without hard links makes it executable (0755), so a hook switched off with chmod -x runs again
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Start with prepareHookBackup, replaceWithCopy, and copyHookFile, following the copy fallback described in the issue. Check the existing mode-preserving helper and link-failure test seam from #3046 for the related re-wrap path. Add or update a unit test that forces the link to fail; done means the backup preserves the source permissions, including non-executable and private modes.
Written by the indexing model from the issue text.
Description
Description
When hard links are unavailable in the hooks directory, entire enable copies the user's hook into <hook>.pre-entire, and the copy is always mode 0755. Entire's chained hook runs <hook>.pre-entire when it is executable, so a hook the user switched off with chmod -x (which git skips) starts running on every commit or push. A private hook (0600) also becomes world-readable.
Trace on main (3a760b96): prepareHookBackup calls replaceWithCopy(root, name, backup), which calls linkOrCopy. When root.Link fails with anything other than fs.ErrExist, copyOrRelink falls back to copyHookFile, which opens the copy with 0o755 and then chmods it to 0o755. keepOlderCopy and replaceWithOwnCopy go through the same copy, so older copies and keep copies also end up 0755. A hard link shares the source's mode, so filesystems that support links are not affected.
Proposed fix: have copyHookFile (or its callers that place a hook where it runs) give the copy the source's permission bits. #3046 already has a helper for this on the re-wrap path (replaceWithCopyKeepingMode) and a test seam for the link (linkHookFile).
Repro
- Put a repo's hooks on a filesystem without hard links (some FUSE or network mounts, exFAT), or in a unit test, make the hard link fail.
printf '#!/bin/sh\necho user hook ran\n' > .git/hooks/pre-push; chmod 644 .git/hooks/pre-push. Git now skips it.entire enable.ls -l .git/hooks/pre-push.pre-entireshows -rwxr-xr-x, andgit pushprints "user hook ran".
Expected: pre-push.pre-entire keeps mode 0644, and the push does not run it.
Not reproduced end to end on a filesystem without links. It is traced in source, and reproduced in a unit test by making the link fail.
Version
main 3a760b96
Agent
Any (the git hook install is the same for every agent)
Additional
Found while fixing #2960 in #3046, where the same copy fallback is fixed for the re-wrap path only.
- Dominant language
- Go
- Stars
- 5.1k
- Forks
- 475
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 208
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from entireio/cli
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
entireio/cli#2416 · 1 comment ·
Maintainers usually reply within 1 day
-
Stale `entire configure --agent` hints in investigate and review error messagesPossibly taken @suhaanthayyil claimed this 61 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
Similar issues
-
[Bug] Custom tool truncation leaves unused stream copies openPossibly taken @OUAO-FRANK claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
[v3] KeyBindingManager calls (Add/Remove) are not converted into a case-insensitive accelerator.KeyOpenBug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
crmne/hyprmoncfg#114 · 1 comment ·
Maintainers usually reply within 1 day
-
runtime: usleep sleeps nanoseconds instead of microseconds on linux/mips and linux/mips64Possibly taken @BRobertson7 claimed this today. Opencompiler/runtime
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100