git-annex/Annex
Joey Hess 51e60259e1
fix replaceFile makeAnnexLink race
replaceFile created a temp file, which was guaranteed to not overlap with
another temp file. However, makeAnnexLink then deleted that file, in
preparation for making the symlink in its place. This caused a race, since
some other replaceFile could create a temp file, using the same name!

I was able to reproduce the race easily running git-annex add -J10 in a
directory with 100 files (all with different contents). Some files would
get ingested into the annex, but their annex links would fail to be added.

There could be other situations where this same problem could occur.
Perhaps when the assistant is adding a file, if the user manually also ran
git-annex add. Perhaps in cases not involving adding a file.

The new replaceFile makes a temprary directory, which is guaranteed to be
unique, and doesn't make a temp file in there. makeAnnexLink can thus
create the symlink without problem and the race is avoided.

Audited all calls to replaceFile to make sure that the old behavior of
providing an empty temp file was not relied on.

The general problem of asking for a temp file and deleting it as part of
the process of using it could reach beyond replaceFile. Did some quick
audits and didn't find other cases of it. Probably only symlink creation
stuff would tend to make that mistake, mostly.
2015-11-06 15:08:19 -04:00
..
Branch update my email address and homepage url 2015-01-21 12:50:09 -04:00
Content a few hlints 2015-04-11 00:10:34 -04:00
MetaData update my email address and homepage url 2015-01-21 12:50:09 -04:00
View update my email address and homepage url 2015-01-21 12:50:09 -04:00
Action.hs Improve shutdown due to --time-limit, especially for fsck 2015-07-31 16:01:54 -04:00
AutoMerge.hs avoid making post-merge-conflict-resolution commit when no conflicts were resolved 2015-10-15 14:22:46 -04:00
BloomFilter.hs use bloom filter in second pass of sync --all --content 2015-06-16 18:50:13 -04:00
Branch.hs Avoid unncessary write to the location log when a file is unlocked and then added back with unchanged content. 2015-10-12 14:46:47 -04:00
BranchState.hs simplify and make more atomic 2015-04-10 15:16:17 -04:00
CatFile.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
CheckAttr.hs refactor 2015-04-10 17:53:58 -04:00
CheckIgnore.hs refactor 2015-04-10 17:53:58 -04:00
Concurrent.hs merge git command queue when joining with concurrent thread 2015-11-05 18:21:48 -04:00
Content.hs fix windows build 2015-10-12 15:48:59 -04:00
Difference.hs a few hlints 2015-04-11 00:10:34 -04:00
Direct.hs do tmp dir cleanup in error case too 2015-10-15 14:27:14 -04:00
DirHashes.hs a few hlints 2015-04-11 00:10:34 -04:00
Drop.hs Changed drop ordering when using git annex sync --content or the assistant, to drop from remotes first and from the local repo last. This works better with the behavior changes to drop in many cases. 2015-10-14 12:33:02 -04:00
Environment.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
FileMatcher.hs Added new "anything" preferred content expression, which matches all versions of all files. 2015-06-16 17:03:34 -04:00
Fixup.hs avoid using --literal-pathspecs with git older than 1.8.1 which added it 2015-04-06 13:46:11 -04:00
Hook.hs Added a post-update-annex hook, which is run after the git-annex branch is updated. Needed for git update-server-info. 2015-03-20 14:52:58 -04:00
Index.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
Init.hs use action, not sideAction 2015-10-11 13:29:44 -04:00
Journal.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
Link.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
LockFile.hs use lock pools throughout git-annex 2015-05-19 14:09:52 -04:00
MakeRepo.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
MetaData.hs a few hlints 2015-04-11 00:10:34 -04:00
Notification.hs a few hlints 2015-04-11 00:10:34 -04:00
NumCopies.hs also generate a drop safety proof for move --from remote 2015-10-09 16:16:03 -04:00
Path.hs Fix bug introduced in the last release that broke git-annex sync when git-annex was installed from the standalone tarball. 2015-03-27 12:55:18 -04:00
Perms.hs unused import 2015-10-08 14:59:34 -04:00
Queue.hs merge git command queue when joining with concurrent thread 2015-11-05 18:21:48 -04:00
Quvi.hs remove Params constructor from Utility.SafeCommand 2015-06-01 13:52:23 -04:00
ReplaceFile.hs fix replaceFile makeAnnexLink race 2015-11-06 15:08:19 -04:00
SpecialRemote.hs enableremote: List uuids and descriptions of remotes that can be enabled, and accept either the uuid or the description in leu if the name. 2015-10-26 14:55:40 -04:00
Ssh.hs clean 2015-08-04 17:07:45 -04:00
TaggedPush.hs Fix setting/setting/viewing metadata that contains unicode or other special characters, when in a non-unicode locale. 2015-08-11 18:40:59 -04:00
Transfer.hs other 80% of avoding verification when hard linking to objects in shared repo 2015-10-02 14:35:12 -04:00
Url.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
UUID.hs Avoid displaying network transport warning when a ssh remote does not yet have an annex.uuid set. 2015-10-15 15:36:54 -04:00
VariantFile.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
Version.hs update my email address and homepage url 2015-01-21 12:50:09 -04:00
View.hs a few hlints 2015-04-11 00:10:34 -04:00
Wanted.hs import Data.Default in Common 2015-01-28 16:11:28 -04:00