diff options
author | Andrew Cady <d@jerkface.net> | 2019-07-13 15:22:45 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2019-07-13 15:41:12 -0400 |
commit | 006d1f0b7f36c25a91006fce24cbe76416fcee86 (patch) | |
tree | bf3e95582edf806677c6aaf56c825ba33c2c2974 /lib/GnuPGAgent.hs | |
parent | 495d9fbac3d633b768d910fced5cf00d00118fa0 (diff) |
no cpp needed, since my love is unconditional
Diffstat (limited to 'lib/GnuPGAgent.hs')
-rw-r--r-- | lib/GnuPGAgent.hs | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/lib/GnuPGAgent.hs b/lib/GnuPGAgent.hs index 1e40269..d73ceed 100644 --- a/lib/GnuPGAgent.hs +++ b/lib/GnuPGAgent.hs | |||
@@ -1,6 +1,6 @@ | |||
1 | {-# LANGUAGE LambdaCase #-} | 1 | {-# LANGUAGE LambdaCase #-} |
2 | {-# LANGUAGE CPP #-} | 2 | {-# LANGUAGE PatternGuards #-} |
3 | {-# LANGUAGE PatternGuards #-} {-# LANGUAGE TupleSections #-} | 3 | {-# LANGUAGE TupleSections #-} |
4 | module GnuPGAgent | 4 | module GnuPGAgent |
5 | ( session | 5 | ( session |
6 | , GnuPGAgent | 6 | , GnuPGAgent |
@@ -26,21 +26,11 @@ import System.Posix.User | |||
26 | import System.Environment | 26 | import System.Environment |
27 | import System.IO | 27 | import System.IO |
28 | import Text.Printf | 28 | import Text.Printf |
29 | #if defined(VERSION_memory) | ||
30 | import qualified Data.ByteString.Char8 as S8 | 29 | import qualified Data.ByteString.Char8 as S8 |
31 | import Data.ByteArray.Encoding | 30 | import Data.ByteArray.Encoding |
32 | #elif defined(VERSION_dataenc) | ||
33 | import qualified Codec.Binary.Base16 as Base16 | ||
34 | #endif | ||
35 | import LengthPrefixedBE | 31 | import LengthPrefixedBE |
36 | import qualified Data.ByteString.Lazy as L | 32 | import qualified Data.ByteString.Lazy as L |
37 | #if defined(VERSION_hourglass) | ||
38 | import Data.Hourglass | 33 | import Data.Hourglass |
39 | #else | ||
40 | import Data.Time.Calendar | ||
41 | import Data.Time.Clock | ||
42 | import Data.Time.Clock.POSIX | ||
43 | #endif | ||
44 | import ProcessUtils | 34 | import ProcessUtils |
45 | import Control.Monad.Fix | 35 | import Control.Monad.Fix |
46 | import Control.Concurrent (threadDelay) | 36 | import Control.Concurrent (threadDelay) |
@@ -166,18 +156,12 @@ getPassphrase agent ask (Query key uid masterkey) = do | |||
166 | "OK" | not (null $ drop 3 r0) -> return r0 >>= unhex . drop 3 -- . (\x -> trace (show x) x) | 156 | "OK" | not (null $ drop 3 r0) -> return r0 >>= unhex . drop 3 -- . (\x -> trace (show x) x) |
167 | | otherwise -> hGetLine (agentHandle agent) >>= unhex . drop 3 -- . (\x -> trace (show x) x) | 157 | | otherwise -> hGetLine (agentHandle agent) >>= unhex . drop 3 -- . (\x -> trace (show x) x) |
168 | where | 158 | where |
169 | #if defined(VERSION_memory) | ||
170 | unhex hx = case convertFromBase Base16 (S8.pack hx) of | 159 | unhex hx = case convertFromBase Base16 (S8.pack hx) of |
171 | Left e -> do | 160 | Left e -> do |
172 | -- Useful for debugging but insecure generally ;) | 161 | -- Useful for debugging but insecure generally ;) |
173 | -- putStrLn $ "convertFromBase error for input "++show hx++": "++show e | 162 | -- putStrLn $ "convertFromBase error for input "++show hx++": "++show e |
174 | return Nothing | 163 | return Nothing |
175 | Right bs -> return $ Just $ S8.unpack bs | 164 | Right bs -> return $ Just $ S8.unpack bs |
176 | #elif defined(VERSION_dataenc) | ||
177 | unhex hx = maybe (return () {- putStrLn $ "dataenc error for input "++show hx -}) | ||
178 | return | ||
179 | $ fmap (map $ chr . fromIntegral) $ Base16.decode hx | ||
180 | #endif | ||
181 | "ERR" -> return Nothing | 165 | "ERR" -> return Nothing |
182 | 166 | ||
183 | quit :: GnuPGAgent -> IO () | 167 | quit :: GnuPGAgent -> IO () |
@@ -232,12 +216,8 @@ envhomedir opt home = do | |||
232 | timeString :: Word32 -> String | 216 | timeString :: Word32 -> String |
233 | timeString t = printf "%d-%d-%d" year month day | 217 | timeString t = printf "%d-%d-%d" year month day |
234 | where | 218 | where |
235 | #if defined(VERSION_hourglass) | ||
236 | Date year m day = timeFromElapsed (Elapsed (Seconds $ fromIntegral t)) | 219 | Date year m day = timeFromElapsed (Elapsed (Seconds $ fromIntegral t)) |
237 | month = fromEnum m + 1 | 220 | month = fromEnum m + 1 |
238 | #else | ||
239 | (year,month,day) = toGregorian . utctDay $ posixSecondsToUTCTime (realToFrac t) | ||
240 | #endif | ||
241 | 221 | ||
242 | key_nbits :: Packet -> Int | 222 | key_nbits :: Packet -> Int |
243 | key_nbits p@(SecretKeyPacket {}) = _key_nbits (key_algorithm p) (key p) | 223 | key_nbits p@(SecretKeyPacket {}) = _key_nbits (key_algorithm p) (key p) |