summaryrefslogtreecommitdiff
path: root/doc/forum/use_withUmask_in_a_property/comment_3_5bdd79ed99f2b001d5dfc8a7d0b2c177._comment
blob: 3a9f89c20969819921e189c84f63673bf6704594 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[[!comment format=mdwn
 username="gueux"
 subject="comment 3"
 date="2016-06-20T18:49:30Z"
 content="""
Thanks!

By reading Cmd.hs, I've managed to get this:

    createKey :: FilePath -> Property UnixLike
    createKey key = property (\"new private key file: \" ++ key) $ liftIO $ withUmask 0o0177 $ withFile key WriteMode $ \h ->
            cmdResult <$> boolSystem' \"openssl\" [Param \"genrsa\", Param \"4096\"] (\p -> p { std_out = UseHandle h })

    cmdResult :: Bool -> Result
    cmdResult False = FailedChange
    cmdResult True = NoChange

"""]]