summaryrefslogtreecommitdiff
path: root/lib/GnuPGAgent.hs
diff options
context:
space:
mode:
authorjoe <joe@jerkface.net>2016-08-31 23:33:04 -0400
committerjoe <joe@jerkface.net>2016-08-31 23:33:04 -0400
commit6734397a53e2160257a89f8c391d89ea4aa02ad4 (patch)
tree57da0c2ff30e97abb9e821e587172ecb6d5e15b5 /lib/GnuPGAgent.hs
parentd8950d3ccdf51f308aa93f06c16f26b15a6c55c4 (diff)
Better error reporting
Diffstat (limited to 'lib/GnuPGAgent.hs')
-rw-r--r--lib/GnuPGAgent.hs3
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
13import Debug.Trace 13import Debug.Trace
14import Control.Monad 14import Control.Monad
15import ControlMaybe
15import Data.Char 16import Data.Char
16import Data.OpenPGP 17import Data.OpenPGP
17import Data.OpenPGP.Util 18import Data.OpenPGP.Util
@@ -39,9 +40,11 @@ import Data.Word
39 40
40data GnuPGAgent = GnuPGAgent { agentHandle :: Handle } 41data GnuPGAgent = GnuPGAgent { agentHandle :: Handle }
41 42
43session :: IO (Maybe GnuPGAgent)
42session = do 44session = 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