summaryrefslogtreecommitdiff
path: root/src/Propellor/Gpg.hs
diff options
context:
space:
mode:
authorJoey Hess2017-08-01 15:28:56 -0400
committerJoey Hess2017-08-01 15:28:56 -0400
commit205cdf51045184c6d8d9a3d3303dafdc87b19e45 (patch)
tree40440e46b745f5db1167a5b8cee1f6e53af725c2 /src/Propellor/Gpg.hs
parentb45339f9c3268878bdd7e886dd5bd31bc8f5a306 (diff)
Avoid crashing when getTerminalName fails due to eg, being in a chroot.
Diffstat (limited to 'src/Propellor/Gpg.hs')
-rw-r--r--src/Propellor/Gpg.hs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Propellor/Gpg.hs b/src/Propellor/Gpg.hs
index 5df16389..c48bc060 100644
--- a/src/Propellor/Gpg.hs
+++ b/src/Propellor/Gpg.hs
@@ -20,6 +20,7 @@ import Utility.Tmp
import Utility.Env
import Utility.Directory
import Utility.Split
+import Utility.Exception
-- | When at a tty, set GPG_TTY to point to the tty device. This is needed
-- so that when gpg is run with stio connected to a pipe, it is still able
@@ -35,9 +36,12 @@ setupGpgEnv = checkhandles [stdInput, stdOutput, stdError]
isterm <- queryTerminal h
if isterm
then do
- ttyname <- getTerminalName h
- -- do not overwrite
- setEnv "GPG_TTY" ttyname False
+ v <- tryNonAsync $ getTerminalName h
+ case v of
+ Right ttyname ->
+ -- do not overwrite
+ setEnv "GPG_TTY" ttyname False
+ Left _ -> checkhandles hs
else checkhandles hs
type KeyId = String