Repository navigation
server.sh cleanup: delete relative to the directory find walked - #106
Merged
Merged
Conversation
Files were listed by find and removed later by full path with xargs rm, so a directory swapped for a symlink in between redirected root's unlink outside the cleaned tree. find now runs rm with -execdir on ./name inside the directory it walked. A test swaps a directory after the listing and checks a file outside the tree survives. Closes #103
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 #103.
What changed
xargs rm. The listing functions take find actions, and the clean functions pass-execdir rm -f -- {} +, sormruns on./nameinside the directory find itself walked.-print0.Why
Removing by a path printed earlier re-resolves every directory in it. When run as root over trees other users can write to, a directory replaced in between pointed the delete outside the tree.
Verification
server/tests/cleanup_test.sh: a first-callrmshim swaps a user's thumbnail directory for a symlink to another directory, and the file there must survive. On the old code:FAIL: a swapped-in symlink redirected the delete out of the cleaned tree; new code:PASS../run-tests:all 10 passed, 3 skipped.Not verified
rmdir. rmdir only removes empty directories; noted as hardening.