summaryrefslogtreecommitdiff
path: root/Propellor
diff options
context:
space:
mode:
authorJoey Hess2014-03-31 14:41:40 -0400
committerJoey Hess2014-03-31 14:41:40 -0400
commitac76e80fa24efe90d312c18a950e65e1e150a776 (patch)
treeefbd7d39b6fea21a0325b2442fa78eb85206d53d /Propellor
parent48b3c546b75ee27638562e3031e8c42677d506e2 (diff)
propellor spin
Diffstat (limited to 'Propellor')
-rw-r--r--Propellor/CmdLine.hs15
1 files changed, 11 insertions, 4 deletions
diff --git a/Propellor/CmdLine.hs b/Propellor/CmdLine.hs
index ff90b07c..eff279d0 100644
--- a/Propellor/CmdLine.hs
+++ b/Propellor/CmdLine.hs
@@ -3,11 +3,14 @@ module Propellor.CmdLine where
import System.Environment
import Data.List
import System.Exit
+import qualified Data.ByteString.Lazy as BL
+import qualified Data.ByteString.Base64.Lazy as B64
+import Data.Bits.Utils
import Propellor
import Utility.FileMode
import Utility.SafeCommand
-import Utility.Base64
+import Utility.Data
data CmdLine
= Run HostName
@@ -73,7 +76,8 @@ spin host = do
NeedKeyRing -> do
putStr $ "Sending " ++ keyring ++ " to " ++ host ++ "..."
hFlush stdout
- s <- toB64 <$> readFile keyring
+ s <- w82s . BL.unpack . B64.encode
+ <$> BL.readFile keyring
putStrLn $ show $ toMarked keyringMarker s
hFlush stdout
hPutStrLn toh $ toMarked keyringMarker s
@@ -153,8 +157,11 @@ boot props = do
makePrivDataDir
maybe noop (writeFileProtected privDataLocal) $
fromMarked privDataMarker reply
- maybe noop (writeFileProtected keyring) $
- fromB64Maybe =<< fromMarked keyringMarker reply
+ case eitherToMaybe . B64.decode . BL.pack . s2w8 =<< fromMarked keyringMarker reply of
+ Nothing -> noop
+ Just d -> do
+ writeFileProtected keyring ""
+ BL.writeFile keyring d
ensureProperties props
addKey :: String -> IO ()