From 89a2bb07a11829070f3fd20a90cf1be5901ec878 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 20 Jun 2016 14:14:51 -0400 Subject: comment --- ...ent_1_593c3e8b1499b4cc9cc7db74bb775506._comment | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 doc/forum/use_withUmask_in_a_property/comment_1_593c3e8b1499b4cc9cc7db74bb775506._comment (limited to 'doc/forum/use_withUmask_in_a_property') 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. +"""]] -- cgit v1.2.3