summaryrefslogtreecommitdiff
path: root/Propellor/Property/File.hs
diff options
context:
space:
mode:
authorJoey Hess2014-04-10 03:06:35 -0400
committerJoey Hess2014-04-10 03:06:35 -0400
commit7a0074454bbae2506c102a57add9af17a32907cc (patch)
tree71cdb3e3e57937a433723fee5227536530fb71db /Propellor/Property/File.hs
parenteb71c76711a3952a1851fea4f80bbf17a0fc61b4 (diff)
propellor spin
Diffstat (limited to 'Propellor/Property/File.hs')
-rw-r--r--Propellor/Property/File.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/Propellor/Property/File.hs b/Propellor/Property/File.hs
index 0c1155fe..64dce66f 100644
--- a/Propellor/Property/File.hs
+++ b/Propellor/Property/File.hs
@@ -58,3 +58,13 @@ fileProperty desc a f = Property desc $ go =<< doesFileExist f
dirExists :: FilePath -> Property
dirExists d = check (not <$> doesDirectoryExist d) $ Property (d ++ " exists") $
makeChange $ createDirectoryIfMissing True d
+
+-- | Ensures that a file/dir has the specified owner and group.
+ownerGroup :: FilePath -> UserName -> GroupName -> Property
+ownerGroup f owner group = Property (f ++ " owner " ++ og) $ do
+ r <- ensureProperty $ cmdProperty "chown" [og, f]
+ if r == FailedChange
+ then return r
+ else noChange
+ where
+ og = owner ++ ":" ++ group