summaryrefslogtreecommitdiff
path: root/src/Propellor/Property/Group.hs
blob: f47867c147cf4df267ff6c50a8db8dca3720008b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Propellor.Property.Group where

import Propellor.Base
import Propellor.Property.User (hasGroup)

type GID = Int

exists :: Group -> Maybe GID -> Property UnixLike
exists (Group group') mgid = check test (cmdProperty "addgroup" (args mgid))
	`describe` unwords ["group", group']
  where
	groupFile = "/etc/group"
	test = not . elem group' . words <$> readProcess "cut" ["-d:", "-f1", groupFile]
	args Nothing = [group']
	args (Just gid) = ["--gid", show gid, group']

hasUser :: Group -> User -> Property DebianLike
hasUser = flip hasGroup