diff options
| author | Joey Hess <joey@kitenet.net> | 2014-03-31 14:41:40 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-03-31 14:41:40 -0400 |
| commit | ac76e80fa24efe90d312c18a950e65e1e150a776 (patch) | |
| tree | efbd7d39b6fea21a0325b2442fa78eb85206d53d | |
| parent | 48b3c546b75ee27638562e3031e8c42677d506e2 (diff) | |
propellor spin
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | Propellor/CmdLine.hs | 15 | ||||
| -rw-r--r-- | Utility/Base64.hs | 24 | ||||
| -rw-r--r-- | propellor.cabal | 3 |
4 files changed, 13 insertions, 31 deletions
@@ -11,7 +11,7 @@ build: deps dist/setup-config ln -sf dist/build/propellor/propellor deps: - @if [ $$(whoami) = root ]; then apt-get -y install gnupg ghc cabal-install libghc-missingh-dev libghc-ansi-terminal-dev libghc-ifelse-dev libghc-unix-compat-dev libghc-hslogger-dev libghc-dataenc-dev; fi || true + @if [ $$(whoami) = root ]; then apt-get -y install gnupg ghc cabal-install libghc-missingh-dev libghc-ansi-terminal-dev libghc-ifelse-dev libghc-unix-compat-dev libghc-hslogger-dev libghc-base64-bytestring-dev; fi || true dist/setup-config: propellor.cabal cabal configure 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 () diff --git a/Utility/Base64.hs b/Utility/Base64.hs deleted file mode 100644 index 0c6c8677..00000000 --- a/Utility/Base64.hs +++ /dev/null @@ -1,24 +0,0 @@ -{- Simple Base64 access - - - - Copyright 2011 Joey Hess <joey@kitenet.net> - - - - Licensed under the GNU GPL version 3 or higher. - -} - -module Utility.Base64 (toB64, fromB64Maybe, fromB64) where - -import "dataenc" Codec.Binary.Base64 -import Data.Bits.Utils -import Control.Applicative -import Data.Maybe - -toB64 :: String -> String -toB64 = encode . s2w8 - -fromB64Maybe :: String -> Maybe String -fromB64Maybe s = w82s <$> decode s - -fromB64 :: String -> String -fromB64 = fromMaybe bad . fromB64Maybe - where - bad = error "bad base64 encoded data" diff --git a/propellor.cabal b/propellor.cabal index 779c7df2..80a05f46 100644 --- a/propellor.cabal +++ b/propellor.cabal @@ -29,7 +29,7 @@ Executable propellor Extensions: PackageImports Build-Depends: MissingH, directory, filepath, base >= 4.5, base < 5, IfElse, process, bytestring, hslogger, unix-compat, ansi-terminal, - containers, dataenc + containers, base64-bytestring if (! os(windows)) Build-Depends: unix @@ -67,7 +67,6 @@ Library Propellor.Types Other-Modules: Utility.Applicative - Utility.Base64 Utility.Data Utility.Directory Utility.Env |
