diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-10-23 01:27:51 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-10-23 01:27:51 -0400 |
| commit | eca865628c2cae8996854d596dfee0dea4ef17c2 (patch) | |
| tree | d30425bf0630173bc17be40c5ca8283b2a3897f6 /src/Propellor/Property/User.hs | |
| parent | bf25cb287bcec0b85f64c90a88a4556291efe74a (diff) | |
| parent | 1a55d09b5452f07508d4624b632e9a54782dbee8 (diff) | |
Merge branch 'joeyconfig'
Diffstat (limited to 'src/Propellor/Property/User.hs')
| -rw-r--r-- | src/Propellor/Property/User.hs | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/Propellor/Property/User.hs b/src/Propellor/Property/User.hs index c3314738..78e606ac 100644 --- a/src/Propellor/Property/User.hs +++ b/src/Propellor/Property/User.hs @@ -58,14 +58,21 @@ hasPassword' (User u) context = go `requires` shadowConfig True setPassword :: (((PrivDataField, PrivData) -> Propellor Result) -> Propellor Result) -> Propellor Result setPassword getpassword = getpassword $ go where - go (Password user, password) = set user (privDataVal password) [] - go (CryptPassword user, hash) = set user (privDataVal hash) ["--encrypted"] + go (Password user, password) = chpasswd (User user) (privDataVal password) [] + go (CryptPassword user, hash) = chpasswd (User user) (privDataVal hash) ["--encrypted"] go (f, _) = error $ "Unexpected type of privdata: " ++ show f - set user v ps = makeChange $ withHandle StdinHandle createProcessSuccess - (proc "chpasswd" ps) $ \h -> do - hPutStrLn h $ user ++ ":" ++ v - hClose h +-- | Makes a user's password be the passed String. Highly insecure: +-- The password is right there in your config file for anyone to see! +hasInsecurePassword :: User -> String -> Property NoInfo +hasInsecurePassword u@(User n) p = property (n ++ " has insecure password") $ + chpasswd u p [] + +chpasswd :: User -> String -> [String] -> Propellor Result +chpasswd (User user) v ps = makeChange $ withHandle StdinHandle createProcessSuccess + (proc "chpasswd" ps) $ \h -> do + hPutStrLn h $ user ++ ":" ++ v + hClose h lockedPassword :: User -> Property NoInfo lockedPassword user@(User u) = check (not <$> isLockedPassword user) $ cmdProperty "passwd" |
