summaryrefslogtreecommitdiff
path: root/doc/forum/use_withUmask_in_a_property
diff options
context:
space:
mode:
authorJoey Hess2016-06-20 14:14:51 -0400
committerJoey Hess2016-06-20 14:14:51 -0400
commit89a2bb07a11829070f3fd20a90cf1be5901ec878 (patch)
tree1dd54cf9cf006f03d1180f81f11170fbd0fac7ea /doc/forum/use_withUmask_in_a_property
parent1b928982d74e029c02d22905c222ab1730906d10 (diff)
comment
Diffstat (limited to 'doc/forum/use_withUmask_in_a_property')
-rw-r--r--doc/forum/use_withUmask_in_a_property/comment_1_593c3e8b1499b4cc9cc7db74bb775506._comment38
1 files changed, 38 insertions, 0 deletions
diff --git a/doc/forum/use_withUmask_in_a_property/comment_1_593c3e8b1499b4cc9cc7db74bb775506._comment b/doc/forum/use_withUmask_in_a_property/comment_1_593c3e8b1499b4cc9cc7db74bb775506._comment
new file mode 100644
index 00000000..d52b4786
--- /dev/null
+++ b/doc/forum/use_withUmask_in_a_property/comment_1_593c3e8b1499b4cc9cc7db74bb775506._comment
@@ -0,0 +1,38 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 1"""
+ date="2016-06-20T18:04:27Z"
+ content="""
+ withUmask :: (MonadIO m, MonadMask m) => FileMode -> m a -> m a
+
+That needs a monad, and propellor Property is not a monad itself.
+But, a Property does contain an Propellor monad action, which is run to ensure
+that the property is met. You can use withUmask inside that action.
+
+The problem then becomes, how to run a Property like
+your `cmdProperty` inside the Propellor monad?
+
+The answer is, using `ensureProperty`.
+[Documentation](http://hackage.haskell.org/package/propellor/docs/Propellor-EnsureProperty.html)
+
+Something like this is what you're looking for:
+
+ foo = Property UnixLike
+ foo = property' "generate new key file" $ \w ->
+ withUmask filemode $
+ ensureProperty w genrsa
+ where
+ filemode = -- something
+
+ genrsa :: Property UnixLike
+ genrsa = cmdProperty "openssl"
+ [ "genrsa"
+ , "4096"
+ , "> " ++ key
+ ]
+ `assume` MadeChange
+
+Incidentially, cmdProperty runs a command without exposing it to the
+shell, so I don't think the redirection in your example will work.
+You probably want to use scriptProperty instead.
+"""]]