aboutsummaryrefslogtreecommitdiff
path: root/Annex/Content
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-11-15 14:52:03 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-11-15 14:52:03 -0400
commit454c990ce49af450d3177f2ea9c6132681959078 (patch)
tree9c11d10ccac85d646f7c85a1e51b71efc0a7c28a /Annex/Content
parenta4ea1393cef234518bfa8dcaeb522259a485b414 (diff)
Direct mode .git/annex/objects directories are no longer left writable
Because that allowed writing to symlinks of files that are not present, which followed the link and put bad content in an object location. fsck: Fix up .git/annex/object directory permissions. This commit was sponsored by an anonymous bitcoin donor.
Diffstat (limited to 'Annex/Content')
-rw-r--r--Annex/Content/Direct.hs26
1 files changed, 17 insertions, 9 deletions
diff --git a/Annex/Content/Direct.hs b/Annex/Content/Direct.hs
index b0b8621e9..a5d71288b 100644
--- a/Annex/Content/Direct.hs
+++ b/Annex/Content/Direct.hs
@@ -10,6 +10,7 @@ module Annex.Content.Direct (
associatedFilesRelative,
removeAssociatedFile,
removeAssociatedFileUnchecked,
+ removeAssociatedFiles,
addAssociatedFile,
goodContent,
recordedInodeCache,
@@ -64,8 +65,8 @@ changeAssociatedFiles key transform = do
files <- associatedFilesRelative key
let files' = transform files
when (files /= files') $ do
- createContentDir mapping
- liftIO $ viaTmp write mapping $ unlines files'
+ modifyContent mapping $
+ liftIO $ viaTmp write mapping $ unlines files'
top <- fromRepo Git.repoPath
return $ map (top </>) files'
where
@@ -75,6 +76,13 @@ changeAssociatedFiles key transform = do
hPutStr h content
hClose h
+{- Removes the list of associated files. -}
+removeAssociatedFiles :: Key -> Annex ()
+removeAssociatedFiles key = do
+ mapping <- calcRepo $ gitAnnexMapping key
+ modifyContent mapping $
+ liftIO $ nukeFile mapping
+
{- Removes an associated file. Returns new associatedFiles value.
- Checks if this was the last copy of the object, and updates location
- log. -}
@@ -142,16 +150,16 @@ addInodeCache key cache = do
{- Writes inode cache for a key. -}
writeInodeCache :: Key -> [InodeCache] -> Annex ()
-writeInodeCache key caches = withInodeCacheFile key $ \f -> do
- createContentDir f
- liftIO $ writeFile f $
- unlines $ map showInodeCache caches
+writeInodeCache key caches = withInodeCacheFile key $ \f ->
+ modifyContent f $
+ liftIO $ writeFile f $
+ unlines $ map showInodeCache caches
{- Removes an inode cache. -}
removeInodeCache :: Key -> Annex ()
-removeInodeCache key = withInodeCacheFile key $ \f -> do
- createContentDir f -- also thaws directory
- liftIO $ nukeFile f
+removeInodeCache key = withInodeCacheFile key $ \f ->
+ modifyContent f $
+ liftIO $ nukeFile f
withInodeCacheFile :: Key -> (FilePath -> Annex a) -> Annex a
withInodeCacheFile key a = a =<< calcRepo (gitAnnexInodeCache key)