diff options
| author | Joey Hess <joey@kitenet.net> | 2014-04-12 21:43:30 -0400 |
|---|---|---|
| committer | Joey Hess <joey@kitenet.net> | 2014-04-12 21:43:30 -0400 |
| commit | 967a0d82dd84a2adfabe702d8ca030d30f8079b5 (patch) | |
| tree | dd8dca709824926c61ff19f49a09405af06b415e /Propellor | |
| parent | 6075fc636dfd9d8c946ed11a58ffa7059dd560d0 (diff) | |
propellor spin
Diffstat (limited to 'Propellor')
| -rw-r--r-- | Propellor/Property/Ssh.hs | 20 | ||||
| -rw-r--r-- | Propellor/Types.hs | 3 |
2 files changed, 13 insertions, 10 deletions
diff --git a/Propellor/Property/Ssh.hs b/Propellor/Property/Ssh.hs index 42809359..51649fd9 100644 --- a/Propellor/Property/Ssh.hs +++ b/Propellor/Property/Ssh.hs @@ -66,22 +66,24 @@ uniqueHostKeys = flagFile prop "/etc/ssh/.unique_host_keys" ["configure"] -- | Sets up a user with a ssh private key from the site's privdata. --- --- The ssh public key (.pub) is not installed. Ssh does not use it. keyImported :: SshKeyType -> UserName -> Property -keyImported keytype user = Property desc install +keyImported keytype user = propertyList desc + [ Property desc (install (SshPubKey keytype user) ".pub") + , Property desc (install (SshPrivKey keytype user) "") + ] where desc = user ++ " has ssh key" - install = do - f <- liftIO keyfile + install p ext = do + f <- liftIO $ keyfile ext ifM (liftIO $ doesFileExist f) ( noChange - , withPrivData (SshKey keytype user) $ \key -> makeChange $ + , withPrivData p $ \key -> makeChange $ writeFileProtected f key ) - keyfile = do + keyfile ext = do home <- homeDirectory <$> getUserEntryForName user - return $ home </> ".ssh" </> "id_" ++ - case keytype of + return $ home </> ".ssh" </> "id_" + ++ case keytype of SshRsa -> "rsa" SshDsa -> "dsa" + ++ ext diff --git a/Propellor/Types.hs b/Propellor/Types.hs index a30b183c..86c56a28 100644 --- a/Propellor/Types.hs +++ b/Propellor/Types.hs @@ -164,7 +164,8 @@ data CmdLine -- It's fine to add new fields. data PrivDataField = DockerAuthentication - | SshKey SshKeyType UserName + | SshPubKey SshKeyType UserName + | SshPrivKey SshKeyType UserName | Password UserName | PrivFile FilePath | GpgKey GpgKeyId |
