From 9ca332e48169ac19dad050a7f99e0db523d8d9c4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 7 Dec 2014 14:57:35 -0400 Subject: Fixed privdata introspection for User.hasPassword and User.hasSomePassword This is not a complete fix for the problem that Info doen't propigate from the called property when code does something like: do hostname <- asks hostName ensureProperty $ foo hostname Instead, I just eliminated the need to implement hasPassword that way, by making the PrivData Info use a HostContext which automatically gets the right hostname passed to it. All other uses of withPrivData don't have the problem. It's still possible for the user to run into the problem if they write something like the above, where foo is a property that uses privdata. However, all properties that take a Context now also accept a HostContext, so it's at least less likely the user needs to write that. --- src/Propellor/Property/Ssh.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Propellor/Property/Ssh.hs') diff --git a/src/Propellor/Property/Ssh.hs b/src/Propellor/Property/Ssh.hs index 5d326b83..88a757bd 100644 --- a/src/Propellor/Property/Ssh.hs +++ b/src/Propellor/Property/Ssh.hs @@ -88,7 +88,7 @@ hostKeys ctx = propertyList "known ssh host keys" ] -- | Sets a single ssh host key from the privdata. -hostKey :: SshKeyType -> Context -> Property +hostKey :: IsContext c => SshKeyType -> c -> Property hostKey keytype context = combineProperties desc [ installkey (SshPubKey keytype "") (install writeFile ".pub") , installkey (SshPrivKey keytype "") (install writeFileProtected "") @@ -107,7 +107,7 @@ hostKey keytype context = combineProperties desc -- | Sets up a user with a ssh private key and public key pair from the -- PrivData. -keyImported :: SshKeyType -> UserName -> Context -> Property +keyImported :: IsContext c => SshKeyType -> UserName -> c -> Property keyImported keytype user context = combineProperties desc [ installkey (SshPubKey keytype user) (install writeFile ".pub") , installkey (SshPrivKey keytype user) (install writeFileProtected "") @@ -158,7 +158,7 @@ knownHost hosts hn user = property desc $ -- | Makes a user have authorized_keys from the PrivData -- -- This removes any other lines from the file. -authorizedKeys :: UserName -> Context -> Property +authorizedKeys :: IsContext c => UserName -> c -> Property authorizedKeys user context = withPrivData (SshAuthorizedKeys user) context $ \get -> property (user ++ " has authorized_keys") $ get $ \v -> do f <- liftIO $ dotFile "authorized_keys" user -- cgit v1.2.3