diff options
| author | Joey Hess <joeyh@joeyh.name> | 2015-12-15 21:05:00 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2015-12-15 21:05:00 -0400 |
| commit | 571318218c5598ad841cc3dff73c9fee2c7216ef (patch) | |
| tree | 5b7ef7ba00b9b7556ceacc83d4889fad36c32d52 /src/Utility/Exception.hs | |
| parent | b67c39f990ef0ccf465280e0ecdcbff85b94857c (diff) | |
merge from git-annex
withTmpDir security fix in git-annex merged
Fix potential denial of service attack when creating temp dirs.
withTmpDir now makes directory mode 700. AFAICS, propellor didn't leak any
info with the old permissions, and no uses of withTmpDir in propellor are
broken by the new permissions.
Diffstat (limited to 'src/Utility/Exception.hs')
| -rw-r--r-- | src/Utility/Exception.hs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/Utility/Exception.hs b/src/Utility/Exception.hs index 13000e03..8b110ae6 100644 --- a/src/Utility/Exception.hs +++ b/src/Utility/Exception.hs @@ -20,7 +20,8 @@ module Utility.Exception ( catchNonAsync, tryNonAsync, tryWhenExists, - catchHardwareFault, + catchIOErrorType, + IOErrorType(..) ) where import Control.Monad.Catch as X hiding (Handler) @@ -88,11 +89,11 @@ tryWhenExists a = do v <- tryJust (guard . isDoesNotExistError) a return (eitherToMaybe v) -{- Catches only exceptions caused by hardware faults. - - Ie, disk IO error. -} -catchHardwareFault :: MonadCatch m => m a -> (IOException -> m a) -> m a -catchHardwareFault a onhardwareerr = catchIO a onlyhw +{- Catches only IO exceptions of a particular type. + - Ie, use HardwareFault to catch disk IO errors. -} +catchIOErrorType :: MonadCatch m => IOErrorType -> (IOException -> m a) -> m a -> m a +catchIOErrorType errtype onmatchingerr a = catchIO a onlymatching where - onlyhw e - | ioeGetErrorType e == HardwareFault = onhardwareerr e + onlymatching e + | ioeGetErrorType e == errtype = onmatchingerr e | otherwise = throwM e |
