diff options
| author | Joey Hess <joeyh@joeyh.name> | 2016-03-07 21:39:29 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2016-03-07 21:39:55 -0400 |
| commit | 3269dd8ffd621fa977cb108e0e6ad2671a7b6836 (patch) | |
| tree | 70e686ef46056984f27c0eccc9551253f08b3a46 /src/Propellor/PrivData | |
| parent | c98285d957865aadaac3190543be1a1b3ae16476 (diff) | |
| parent | 3137c266b0082cf33d0cf747b2a2ea0929ca2d92 (diff) | |
Merge branch 'master' into wip
Diffstat (limited to 'src/Propellor/PrivData')
| -rw-r--r-- | src/Propellor/PrivData/Paths.hs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/Propellor/PrivData/Paths.hs b/src/Propellor/PrivData/Paths.hs index 3d0d8a58..7410370b 100644 --- a/src/Propellor/PrivData/Paths.hs +++ b/src/Propellor/PrivData/Paths.hs @@ -1,15 +1,31 @@ module Propellor.PrivData.Paths where +import Utility.Exception import System.FilePath +import Control.Applicative +import Prelude privDataDir :: FilePath privDataDir = "privdata" -privDataFile :: FilePath -privDataFile = privDataDir </> "privdata.gpg" +privDataFile :: IO FilePath +privDataFile = allowRelocate $ privDataDir </> "privdata.gpg" + +privDataKeyring :: IO FilePath +privDataKeyring = allowRelocate $ privDataDir </> "keyring.gpg" privDataLocal :: FilePath privDataLocal = privDataDir </> "local" privDataRelay :: String -> FilePath privDataRelay host = privDataDir </> "relay" </> host + +-- Allow relocating files in privdata, by checking for a file +-- privdata/relocate, which contains the path to a subdirectory that +-- contains the files. +allowRelocate :: FilePath -> IO FilePath +allowRelocate f = reloc . lines + <$> catchDefaultIO "" (readFile (privDataDir </> "relocate")) + where + reloc (p:_) | not (null p) = privDataDir </> p </> takeFileName f + reloc _ = f |
