From ac76e80fa24efe90d312c18a950e65e1e150a776 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 31 Mar 2014 14:41:40 -0400 Subject: propellor spin --- Propellor/CmdLine.hs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'Propellor/CmdLine.hs') 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 () -- cgit v1.3-2-g0d8e