diff options
| author | Joey Hess <joeyh@joeyh.name> | 2017-08-01 15:28:56 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2017-08-01 15:28:56 -0400 |
| commit | 205cdf51045184c6d8d9a3d3303dafdc87b19e45 (patch) | |
| tree | 40440e46b745f5db1167a5b8cee1f6e53af725c2 | |
| parent | b45339f9c3268878bdd7e886dd5bd31bc8f5a306 (diff) | |
Avoid crashing when getTerminalName fails due to eg, being in a chroot.
| -rw-r--r-- | debian/changelog | 6 | ||||
| -rw-r--r-- | src/Propellor/Gpg.hs | 10 |
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 |
