From b0f90c096f9b5a176fe3082aab1d0ca566fbe8c9 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Sun, 20 Dec 2020 01:27:27 +0800 Subject: [PATCH] Fix chmod on executables, wrt #97 --- lib/GHCup.hs | 8 ++++---- lib/GHCup/Utils/File.hs | 13 ++++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/GHCup.hs b/lib/GHCup.hs index 0ac6e25..661edbc 100644 --- a/lib/GHCup.hs +++ b/lib/GHCup.hs @@ -333,7 +333,7 @@ installCabalBindist dlinfo ver (PlatformRequest {..}) = do (path cabalFile) (destPath) Overwrite - lift $ chmod_777 destPath + lift $ chmod_755 destPath -- | Installs cabal into @~\/.ghcup\/bin/cabal-\@ and @@ -449,7 +449,7 @@ installHLSBindist dlinfo ver (PlatformRequest {..}) = do (path f) (inst toF) Overwrite - lift $ chmod_777 (inst toF) + lift $ chmod_755 (inst toF) -- install haskell-language-server-wrapper let wrapper = [rel|haskell-language-server-wrapper|] @@ -458,7 +458,7 @@ installHLSBindist dlinfo ver (PlatformRequest {..}) = do (path wrapper) (inst toF) Overwrite - lift $ chmod_777 (inst toF) + lift $ chmod_755 (inst toF) -- | Installs hls binaries @haskell-language-server-\@ @@ -1319,7 +1319,7 @@ upgradeGHCup dls mtarget force pfreq = do handleIO (throwE . CopyError . show) $ liftIO $ copyFile p fullDest Overwrite - lift $ chmod_777 fullDest + lift $ chmod_755 fullDest pure latestVer diff --git a/lib/GHCup/Utils/File.hs b/lib/GHCup/Utils/File.hs index e5301a0..87ac2d2 100644 --- a/lib/GHCup/Utils/File.hs +++ b/lib/GHCup/Utils/File.hs @@ -440,13 +440,16 @@ isBrokenSymlink p = pure False -chmod_777 :: (MonadLogger m, MonadIO m) => Path a -> m () -chmod_777 (toFilePath -> fp) = do +chmod_755 :: (MonadLogger m, MonadIO m) => Path a -> m () +chmod_755 (toFilePath -> fp) = do let exe_mode = - newFilePerms + nullFileMode `unionFileModes` ownerExecuteMode + `unionFileModes` ownerReadMode + `unionFileModes` ownerWriteMode `unionFileModes` groupExecuteMode + `unionFileModes` groupReadMode `unionFileModes` otherExecuteMode - $(logDebug) [i|chmod 777 #{fp}|] + `unionFileModes` otherReadMode + $(logDebug) [i|chmod 755 #{fp}|] liftIO $ setFileMode fp exe_mode -