summaryrefslogtreecommitdiff
path: root/src/Propellor/PrivData.hs
diff options
context:
space:
mode:
authorJoey Hess2015-09-30 15:33:14 -0400
committerJoey Hess2015-09-30 15:33:14 -0400
commit84561f6c429a59eaccfc6b957166baf66f7133a1 (patch)
treed5578fcf44df414c9e7c5c3435610fd4ceda0d77 /src/Propellor/PrivData.hs
parent47ed1b33c3943852e01a4f376aa85187c07e52b7 (diff)
change HostContext for containers
Privdata that uses HostContext inside a container will now have the name of the container as its context, rather than the name of the host(s) where the container is used. This allows eg, having different passwords for a user in different containers. Note that previously, propellor would prompt using the container name as the context, but not actually use privdata using that context; so this is a bug fix. I don't entirely like the implementation; I had to put the code to change the context in PropAccum, and it's not generalized past PrivInfo.
Diffstat (limited to 'src/Propellor/PrivData.hs')
-rw-r--r--src/Propellor/PrivData.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Propellor/PrivData.hs b/src/Propellor/PrivData.hs
index 5df9fe0d..0019730d 100644
--- a/src/Propellor/PrivData.hs
+++ b/src/Propellor/PrivData.hs
@@ -17,6 +17,7 @@ module Propellor.PrivData (
decryptPrivData,
PrivMap,
PrivInfo,
+ forceHostContext,
) where
import Control.Applicative
@@ -236,3 +237,10 @@ newtype PrivInfo = PrivInfo
-- hosts need it.
instance IsInfo PrivInfo where
propigateInfo _ = True
+
+-- | Sets the context of any privdata that uses HostContext to the
+-- provided name.
+forceHostContext :: String -> PrivInfo -> PrivInfo
+forceHostContext name i = PrivInfo $ S.map go (fromPrivInfo i)
+ where
+ go (f, d, HostContext ctx) = (f, d, HostContext (const $ ctx name))