avoid using removePathForcibly everywhere, it is unsafe

If the temp directory can somehow contain a hard link, it changes the
mode, which affects all other hard linked files. So, it's too unsafe
to use everywhere in git-annex, since hard links are possible in
multiple ways and it would be very hard to prove that every place that
uses a temp directory cannot possibly put a hard link in it.

Added a call to removeDirectoryForCleanup to test_crypto, which will
fix the problem that commit 17b20a2450
was intending to fix, with a much smaller hammer.

Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
Joey Hess 2022-05-02 14:06:20 -04:00
parent 1b02cd4715
commit 642703c7e4
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 40 additions and 8 deletions

View file

@ -1794,7 +1794,12 @@ test_crypto = do
-- it needs to be able to store the agent socket there,
-- which can be problimatic when testing some filesystems.
absgpgtmp <- fromRawFilePath <$> absPath (toRawFilePath gpgtmp)
testscheme' scheme absgpgtmp
res <- testscheme' scheme absgpgtmp
-- gpg may still be running and would prevent
-- removeDirectoryRecursive from succeeding, so
-- force removal of the temp directory.
liftIO $ removeDirectoryForCleanup gpgtmp
return res
testscheme' scheme absgpgtmp = intmpclonerepo $ do
-- Since gpg uses a unix socket, which is limited to a
-- short path, use whichever is shorter of absolute