summaryrefslogtreecommitdiff
path: root/src/Propellor
diff options
context:
space:
mode:
authorJoey Hess2017-07-30 11:30:05 -0400
committerJoey Hess2017-07-30 11:30:05 -0400
commit15f292d177ee96f5a1d384ce50f5246e3f7ea630 (patch)
tree033838d01471f633534c38e5d967264ae2dda634 /src/Propellor
parent497e6b4a227dc977d6bb9fe5fe73aeeca9624244 (diff)
parent6f281e87084587987929dbb6a27671ad96858535 (diff)
Merge branch 'master' into joeyconfig
Diffstat (limited to 'src/Propellor')
-rw-r--r--src/Propellor/CmdLine.hs1
-rw-r--r--src/Propellor/Gpg.hs21
-rw-r--r--src/Propellor/Message.hs4
-rw-r--r--src/Propellor/Property/Rsync.hs2
4 files changed, 25 insertions, 3 deletions
diff --git a/src/Propellor/CmdLine.hs b/src/Propellor/CmdLine.hs
index cba5991d..bd01b34c 100644
--- a/src/Propellor/CmdLine.hs
+++ b/src/Propellor/CmdLine.hs
@@ -111,6 +111,7 @@ data CanRebuild = CanRebuild | NoRebuild
defaultMain :: [Host] -> IO ()
defaultMain hostlist = withConcurrentOutput $ do
useFileSystemEncoding
+ setupGpgEnv
Shim.cleanEnv
checkDebugMode
cmdline <- processCmdLine
diff --git a/src/Propellor/Gpg.hs b/src/Propellor/Gpg.hs
index 43c4eddf..5df16389 100644
--- a/src/Propellor/Gpg.hs
+++ b/src/Propellor/Gpg.hs
@@ -1,6 +1,8 @@
module Propellor.Gpg where
import System.IO
+import System.Posix.IO
+import System.Posix.Terminal
import Data.Maybe
import Control.Monad
import Control.Applicative
@@ -19,6 +21,25 @@ import Utility.Env
import Utility.Directory
import Utility.Split
+-- | 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
+-- to display password prompts at the console.
+--
+-- This should not prevent gpg from using the GUI for prompting when one is
+-- available.
+setupGpgEnv :: IO ()
+setupGpgEnv = checkhandles [stdInput, stdOutput, stdError]
+ where
+ checkhandles [] = return ()
+ checkhandles (h:hs) = do
+ isterm <- queryTerminal h
+ if isterm
+ then do
+ ttyname <- getTerminalName h
+ -- do not overwrite
+ setEnv "GPG_TTY" ttyname False
+ else checkhandles hs
+
type KeyId = String
getGpgBin :: IO String
diff --git a/src/Propellor/Message.hs b/src/Propellor/Message.hs
index 441be76e..51d9babb 100644
--- a/src/Propellor/Message.hs
+++ b/src/Propellor/Message.hs
@@ -42,7 +42,7 @@ import Utility.PartialPrelude
-- make propellor emit these to stdout, in addition to its other output.
data Trace
= ActionStart (Maybe HostName) Desc
- | ActionEnd Result
+ | ActionEnd (Maybe HostName) Desc Result
deriving (Read, Show)
-- | Given a line read from propellor, if it's a serialized Trace,
@@ -110,7 +110,7 @@ actionMessage' mhn desc a = do
, let (msg, intensity, color) = getActionResult r
in colorLine intensity color msg
]
- liftIO $ trace $ ActionEnd $ toResult r
+ liftIO $ trace $ ActionEnd mhn desc (toResult r)
return r
where
diff --git a/src/Propellor/Property/Rsync.hs b/src/Propellor/Property/Rsync.hs
index c7ff3287..d922e79f 100644
--- a/src/Propellor/Property/Rsync.hs
+++ b/src/Propellor/Property/Rsync.hs
@@ -46,7 +46,7 @@ newtype Pattern = Pattern String
-- is found, the file is processed.
syncDirFiltered :: [Filter] -> Src -> Dest -> Property (DebianLike + ArchLinux)
syncDirFiltered filters src dest = rsync $
- [ "-av"
+ [ "-a"
-- Add trailing '/' to get rsync to sync the Dest directory,
-- rather than a subdir inside it, which it will do without a
-- trailing '/'.