summaryrefslogtreecommitdiff
path: root/lib/GnuPGAgent.hs
diff options
context:
space:
mode:
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