summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--Propellor/CmdLine.hs15
-rw-r--r--Utility/Base64.hs24
-rw-r--r--propellor.cabal3
4 files changed, 13 insertions, 31 deletions
diff --git a/Makefile b/Makefile
index 321a4b47..a30015e7 100644
--- a/Makefile
+++ b/Makefile
@@ -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