summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/User.hs
diff options
context:
space:
mode:
authorJoey Hess2015-11-24 10:18:26 -0400
committerJoey Hess2015-11-24 10:18:26 -0400
commitc7c9c47d724c710b698d3301637001c056a2c0e3 (patch)
tree6588eac4f69b194ab02d59dd0e5a13a4ba69b095 /src/Propellor/Property/User.hs
parent776c11f6a9187da03324b879e744a8f07b480a09 (diff)
Added User.hasDesktopGroups property.
Based on a property in spwhitton's config, but rewritten.
Diffstat (limited to 'src/Propellor/Property/User.hs')
-rw-r--r--src/Propellor/Property/User.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/Propellor/Property/User.hs b/src/Propellor/Property/User.hs
index 78e606ac..f3842892 100644
--- a/src/Propellor/Property/User.hs
+++ b/src/Propellor/Property/User.hs
@@ -107,6 +107,29 @@ hasGroup (User user) (Group group') = check test $ cmdProperty "adduser"
where
test = not . elem group' . words <$> readProcess "groups" [user]
+-- | Gives a user access to the secondary groups, including audio and
+-- video, that the OS installer normally gives a desktop user access to.
+hasDesktopGroups :: User -> Property NoInfo
+hasDesktopGroups user@(User u) = combineProperties desc $
+ map (hasGroup user . Group) desktopgroups
+ where
+ desc = "user " ++ u ++ " is in standard desktop groups"
+ -- This list comes from user-setup's debconf
+ -- template named "passwd/user-default-groups"
+ desktopgroups =
+ [ "audio"
+ , "cdrom"
+ , "dip"
+ , "floppy"
+ , "video"
+ , "plugdev"
+ , "netdev"
+ , "scanner"
+ , "bluetooth"
+ , "debian-tor"
+ , "lpadmin"
+ ]
+
-- | Controls whether shadow passwords are enabled or not.
shadowConfig :: Bool -> Property NoInfo
shadowConfig True = check (not <$> shadowExists) $