propellor spin

This commit is contained in:
Joey Hess 2014-04-13 17:16:31 -04:00
parent e958460475
commit 56dd4ff4d8
Failed to extract signature
1 changed files with 12 additions and 6 deletions

View File

@ -107,8 +107,12 @@ keyImported keytype user = combineProperties desc
f <- liftIO $ keyfile ext
ifM (liftIO $ doesFileExist f)
( noChange
, withPrivData p $ \key -> makeChange $
, ensureProperty $ combineProperties desc
[ Property desc $
withPrivData p $ \key -> makeChange $
writer f key
, File.ownerGroup f user user
]
)
keyfile ext = do
home <- homeDirectory <$> getUserEntryForName user
@ -130,6 +134,7 @@ knownHost hosts hn user = Property desc $
ensureProperty $ combineProperties desc
[ File.dirExists (takeDirectory f)
, f `File.containsLine` (hn ++ " " ++ k)
, File.ownerGroup f user user
]
go _ = do
warningMessage $ "no configred sshPubKey for " ++ hn
@ -138,8 +143,9 @@ knownHost hosts hn user = Property desc $
-- | Makes a user have authorized_keys from the PrivData
authorizedKeys :: UserName -> Property
authorizedKeys user = Property (user ++ " has authorized_keys") $
withPrivData (SshAuthorizedKeys user) $ \v -> liftIO $ do
withPrivData (SshAuthorizedKeys user) $ \v -> do
f <- liftIO $ dotFile "authorized_keys" user
liftIO $ do
createDirectoryIfMissing True (takeDirectory f)
writeFileProtected f v
return NoChange
ensureProperty $ File.ownerGroup f user user