summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog6
-rw-r--r--src/Propellor/Gpg.hs10
2 files changed, 13 insertions, 3 deletions
diff --git a/debian/changelog b/debian/changelog
index 3b975e62..8da187d9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+propellor (4.7.5) UNRELEASED; urgency=medium
+
+ * Avoid crashing when getTerminalName fails due to eg, being in a chroot.
+
+ -- Joey Hess <id@joeyh.name> Tue, 01 Aug 2017 15:28:32 -0400
+
propellor (4.7.4) unstable; urgency=medium
* Set GPG_TTY when run at a terminal, so that gpg can do password
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