summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/User.hs
diff options
context:
space:
mode:
authorFélix Sipma2014-11-23 18:25:39 +0100
committerJoey Hess2014-11-23 14:37:10 -0400
commitf4e06ae77818f32c16c5051b4fe40a7bc993b624 (patch)
treefc711fdb385a76653d8e085d20fbc432eeb215ab /src/Propellor/Property/User.hs
parentfeae1912abde54c109471d3beb6bca8905935d0e (diff)
User: hasGroup
Signed-off-by: Félix Sipma <felix.sipma@no-log.org>
Diffstat (limited to 'src/Propellor/Property/User.hs')
-rw-r--r--src/Propellor/Property/User.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/Propellor/Property/User.hs b/src/Propellor/Property/User.hs
index f9c400a8..b7bd5e93 100644
--- a/src/Propellor/Property/User.hs
+++ b/src/Propellor/Property/User.hs
@@ -30,7 +30,7 @@ hasSomePassword user context = check ((/= HasPassword) <$> getPasswordStatus use
hasPassword :: UserName -> Context -> Property
hasPassword user context = withPrivData (Password user) context $ \getpassword ->
- property (user ++ " has password") $
+ property (user ++ " has password") $
getpassword $ \password -> makeChange $
withHandle StdinHandle createProcessSuccess
(proc "chpasswd" []) $ \h -> do
@@ -60,3 +60,12 @@ isLockedPassword user = (== LockedPassword) <$> getPasswordStatus user
homedir :: UserName -> IO FilePath
homedir user = homeDirectory <$> getUserEntryForName user
+
+hasGroup :: UserName -> GroupName -> Property
+hasGroup user group' = check test $ cmdProperty "adduser"
+ [ user
+ , group'
+ ]
+ `describe` unwords ["user", user, "in group", group']
+ where
+ test = not <$> elem group' <$> words <$> readProcess "groups" [user]