fix some file modes in calls to withTmpFileIn to honor umask
Also audited for other calls to openTempFile, and all are ok, except for viaTmp which will need further work. Remote.Directory fixed to set umask mode when writing to an export, although it has another one using viaTmp that's not fixed. Will make exports that are published via a http server running as another user work, for example. Remote.BitTorrent fixed to set umask mode when downloading the torrent file. Normally this does not matter as that file does not hang around after the download, but if a bittorrent download were started by one user, got interrupted and then another user ran it, this will let them access the torrent file created by the first user.
This commit is contained in:
parent
5a9f518a42
commit
eed20fe3b7
5 changed files with 51 additions and 7 deletions
|
@ -30,6 +30,10 @@ type Template = String
|
|||
{- Runs an action like writeFile, writing to a temp file first and
|
||||
- then moving it into place. The temp file is stored in the same
|
||||
- directory as the final file to avoid cross-device renames.
|
||||
-
|
||||
- Note that the tmp file will have a file mode that only allows the
|
||||
- current user to access it. The write action can change the mode
|
||||
- to whatever is desired.
|
||||
-}
|
||||
viaTmp :: (MonadMask m, MonadIO m) => (FilePath -> v -> m ()) -> FilePath -> v -> m ()
|
||||
viaTmp a file content = bracketIO setup cleanup use
|
||||
|
@ -55,7 +59,11 @@ withTmpFile template a = do
|
|||
withTmpFileIn tmpdir template a
|
||||
|
||||
{- Runs an action with a tmp file located in the specified directory,
|
||||
- then removes the file. -}
|
||||
- then removes the file.
|
||||
-
|
||||
- Note that the tmp file will have a file mode that only allows the
|
||||
- current user to access it.
|
||||
-}
|
||||
withTmpFileIn :: (MonadIO m, MonadMask m) => FilePath -> Template -> (FilePath -> Handle -> m a) -> m a
|
||||
withTmpFileIn tmpdir template a = bracket create remove use
|
||||
where
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue