From 61d8214d9d8cea6ba047d1a26f9edc1ea180234b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 30 Mar 2014 19:10:32 -0400 Subject: propellor spin --- Property/Cmd.hs | 2 +- Property/Hostname.hs | 2 -- Property/User.hs | 10 ++++++++-- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'Property') diff --git a/Property/Cmd.hs b/Property/Cmd.hs index c78adaeb..b29a12b3 100644 --- a/Property/Cmd.hs +++ b/Property/Cmd.hs @@ -6,7 +6,7 @@ module Property.Cmd ( import Control.Applicative -import Property +import Types import Utility.Monad import Utility.SafeCommand import Utility.Env diff --git a/Property/Hostname.hs b/Property/Hostname.hs index 3d9d2ad0..204ff5d4 100644 --- a/Property/Hostname.hs +++ b/Property/Hostname.hs @@ -3,8 +3,6 @@ module Property.Hostname where import Common import qualified Property.File as File -type HostName = String - set :: HostName -> Property set hostname = "/etc/hostname" `File.hasContent` [hostname] `onChange` cmdProperty "hostname" [Param hostname] diff --git a/Property/User.hs b/Property/User.hs index 58bfa37a..dcbf56c9 100644 --- a/Property/User.hs +++ b/Property/User.hs @@ -4,8 +4,6 @@ import System.Posix import Common -type UserName = String - data Eep = YesReallyDeleteHome sshAccountFor :: UserName -> Property @@ -24,6 +22,14 @@ nuked user _ = check (isJust <$> homedir user) $ cmdProperty "userdel" ] `describe` ("nuked user " ++ user) +setPassword :: UserName -> Property +setPassword user = Property (user ++ " password set") $ + withPrivData (Password user) $ \password -> makeChange $ + withHandle StdinHandle createProcessSuccess + (proc "chpasswd" []) $ \h -> do + hPutStrLn h $ user ++ ":" ++ password + hClose h + lockedPassword :: UserName -> Property lockedPassword user = check (not <$> isLockedPassword user) $ cmdProperty "passwd" [ Param "--lock" -- cgit v1.2.3