Repository navigation
ops-get: replace the destination by rename, never write into it - #102
Merged
Merged
Conversation
cp into an existing destination kept that file's owner and write bits, so a file another local user had created stayed theirs to change before it was run. Both ops-get and ops-get.ps1 now write a new file beside the destination and rename it over; if that is not allowed they stop. The quick starts fetch into the current directory instead of /tmp. Closes #98
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #98.
What changed
ops-getwrites the verified script to a newmktempfile in the destination's directory, sets mode 755, and renames it over the destination. If any step fails (for example, renaming over another user's file in a sticky directory), it removes the temp file and stops with a message. A destination that is a directory is refused.ops-get.ps1does the same with a GUID-named temp file andMove-Item -Force../server.shinstead of/tmp/server.sh.Why
cponto an existing destination rewrote that file in place. The file kept its owner, and a 0666 file became 0777 afterchmod +x, so the file later run with sudo was not bound to the verified bytes.Verification
tests/ops-get_test.sh: new case pre-creates a 0666 destination and asserts a new inode, mode 755, the right content and no leftover temp file. On the old code:FAIL: the existing destination was written in place.tests/ops-get_test.ps1(pwsh 7 on Linux): a hard link to the pre-existing file must keep the old content. On the old code:FAIL: the existing destination was written in place; new code:PASS../run-tests:all 10 passed, 3 skipped.Not verified