diff options
Diffstat (limited to 'lib/GnuPGAgent.hs')
-rw-r--r-- | lib/GnuPGAgent.hs | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/GnuPGAgent.hs b/lib/GnuPGAgent.hs index 7161b92..067e3bc 100644 --- a/lib/GnuPGAgent.hs +++ b/lib/GnuPGAgent.hs | |||
@@ -12,6 +12,7 @@ module GnuPGAgent | |||
12 | 12 | ||
13 | import Debug.Trace | 13 | import Debug.Trace |
14 | import Control.Monad | 14 | import Control.Monad |
15 | import ControlMaybe | ||
15 | import Data.Char | 16 | import Data.Char |
16 | import Data.OpenPGP | 17 | import Data.OpenPGP |
17 | import Data.OpenPGP.Util | 18 | import Data.OpenPGP.Util |
@@ -39,9 +40,11 @@ import Data.Word | |||
39 | 40 | ||
40 | data GnuPGAgent = GnuPGAgent { agentHandle :: Handle } | 41 | data GnuPGAgent = GnuPGAgent { agentHandle :: Handle } |
41 | 42 | ||
43 | session :: IO (Maybe GnuPGAgent) | ||
42 | session = do | 44 | session = do |
43 | envhomedir Nothing gpgHomeSpec >>= \case | 45 | envhomedir Nothing gpgHomeSpec >>= \case |
44 | Just gpghome -> do | 46 | Just gpghome -> do |
47 | handleIO_ (hPutStrLn stderr "Failed to connect to gpg-agent." >> return Nothing) $ do | ||
45 | sock <- socket AF_UNIX Stream defaultProtocol | 48 | sock <- socket AF_UNIX Stream defaultProtocol |
46 | connect sock (SockAddrUnix (gpghome ++ "/S.gpg-agent")) | 49 | connect sock (SockAddrUnix (gpghome ++ "/S.gpg-agent")) |
47 | agent <- socketToHandle sock ReadWriteMode | 50 | agent <- socketToHandle sock ReadWriteMode |