summaryrefslogtreecommitdiff
path: root/src/Propellor/Types/PrivData.hs
diff options
context:
space:
mode:
authorJoey Hess2014-12-14 15:24:21 -0400
committerJoey Hess2014-12-14 15:24:21 -0400
commitfbf9cc6f2b66ba5e56993a239e511cc6bae4af54 (patch)
treecd00a21d0a0b27603374a04f3de505facee651ec /src/Propellor/Types/PrivData.hs
parent9d06d2f835143c308bc409b7dc737c4292d9bc72 (diff)
parent71723ca09f369ccf96462cef1e0200e1615677d1 (diff)
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Types/PrivData.hs')
-rw-r--r--src/Propellor/Types/PrivData.hs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Propellor/Types/PrivData.hs b/src/Propellor/Types/PrivData.hs
index 80dad762..ab3e108a 100644
--- a/src/Propellor/Types/PrivData.hs
+++ b/src/Propellor/Types/PrivData.hs
@@ -11,10 +11,29 @@ data PrivDataField
| SshPrivKey SshKeyType UserName
| SshAuthorizedKeys UserName
| Password UserName
+ | CryptPassword UserName
| PrivFile FilePath
| GpgKey
deriving (Read, Show, Ord, Eq)
+-- | Explains how the user can generate a particular PrivDataField.
+howtoMkPrivDataField :: PrivDataField -> String
+howtoMkPrivDataField fld = case fld of
+ DockerAuthentication -> "/root/.dockercfg" `genbycmd` "docker login"
+ SshPubKey keytype _ -> forexample $
+ "sshkey.pub" `genbycmd` keygen keytype
+ SshPrivKey keytype _ -> forexample $
+ "sshkey" `genbycmd` keygen keytype
+ SshAuthorizedKeys _ -> forexample "~/.ssh/id_rsa.pub"
+ Password username -> "a password for " ++ username
+ CryptPassword _ -> "a crypt(3)ed password, which can be generated by, for example: perl -e 'print crypt(shift, q{$6$}.shift)' 'somepassword' 'somesalt'"
+ PrivFile f -> "file contents for " ++ f
+ GpgKey -> "Either a gpg public key, exported with gpg --export -a, or a gpg private key, exported with gpg --export-secret-key -a"
+ where
+ genbycmd f cmd = f ++ " generated by running `" ++ cmd ++ "`"
+ keygen keytype = "ssh-keygen -t " ++ sshKeyTypeParam keytype ++ " -f sshkey"
+ forexample s = "for example, " ++ s
+
-- | A context in which a PrivDataField is used.
--
-- Often this will be a domain name. For example,
@@ -63,3 +82,11 @@ type PrivData = String
data SshKeyType = SshRsa | SshDsa | SshEcdsa | SshEd25519
deriving (Read, Show, Ord, Eq)
+
+-- | Parameter that would be passed to ssh-keygen to generate key of this type
+sshKeyTypeParam :: SshKeyType -> String
+sshKeyTypeParam SshRsa = "RSA"
+sshKeyTypeParam SshDsa = "DSA"
+sshKeyTypeParam SshEcdsa = "ECDSA"
+sshKeyTypeParam SshEd25519 = "ED25519"
+