summaryrefslogtreecommitdiffhomepage
path: root/Storage
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2016-08-11 20:39:45 -0400
committerJoey Hess <joeyh@joeyh.name>2016-08-11 20:39:45 -0400
commitab3594dacb0461ae5e253544f65c3e3d50eb721d (patch)
tree306ad29a1cde9ce31a8364a9529953f93239013e /Storage
parentf5a53103a95b93f5cdb3cfe0c7043c190e591f0c (diff)
downloadkeysafe-ab3594dacb0461ae5e253544f65c3e3d50eb721d.tar.gz
obscure shard timestamps
Diffstat (limited to 'Storage')
-rw-r--r--Storage/LocalFiles.hs15
1 files changed, 15 insertions, 0 deletions
diff --git a/Storage/LocalFiles.hs b/Storage/LocalFiles.hs
index d339774..083a74e 100644
--- a/Storage/LocalFiles.hs
+++ b/Storage/LocalFiles.hs
@@ -13,6 +13,7 @@ import Serialization ()
import qualified Data.ByteString as B
import qualified Data.ByteString.UTF8 as U8
import Data.Monoid
+import Data.List
import System.Posix.User
import System.IO
import System.Directory
@@ -26,6 +27,7 @@ localFiles :: Storage
localFiles = Storage
{ storeShard = store
, retrieveShard = retrieve
+ , obscureShards = obscure
}
store :: StorableObjectIdent -> Shard -> IO StoreResult
@@ -48,6 +50,19 @@ retrieve n i = onError (RetrieveFailure . show) $ do
b `deepseq` hClose h
return $ RetrieveSuccess $ Shard n (StorableObject b)
+-- | Set atime and mtime to epoch, to obscure access and modification
+-- patterns.
+--
+-- There is no way to set the ctime to the epoch, but setting the other
+-- times does at least set it to the current time, which makes all
+-- currently stored files look alike.
+obscure :: IO ObscureResult
+obscure = onError (ObscureFailure . show) $ do
+ dir <- shardDir
+ fs <- filter (ext `isSuffixOf`) <$> getDirectoryContents dir
+ mapM_ (\f -> setFileTimes (dir </> f) 0 0) fs
+ return ObscureSuccess
+
onError :: (IOException -> a) -> IO a -> IO a
onError f a = do
v <- try a