From 205cdf51045184c6d8d9a3d3303dafdc87b19e45 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 1 Aug 2017 15:28:56 -0400 Subject: Avoid crashing when getTerminalName fails due to eg, being in a chroot. --- src/Propellor/Gpg.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/Propellor/Gpg.hs') 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 -- cgit v1.2.3