Skip to content

Commit b80a9f4

Browse files
RyanGlScottBlaisorblade
authored andcommitted
Suppress password echoing from stack upload on MinTTY consoles (#3143)
To this end, force the use of mintty-0.1.1 over 0.1, because mintty-0.1 can cause build failures according to mintty's [changelog](https://hackage.haskell.org/package/mintty-0.1.1/changelog).
1 parent 3517a35 commit b80a9f4

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ Bug fixes:
7373
* Switching a package between extra-dep and local package now forces
7474
rebuild (previously it wouldn't if versions were the same).
7575
See [#2147](https://github.com/commercialhaskell/stack/issues/2147)
76+
* `stack upload` no longer reveals your password when you type it on
77+
MinTTY-based Windows shells, such as Cygwin and MSYS2.
78+
See [#3142](https://github.com/commercialhaskell/stack/issues/3142)
7679

7780

7881
## 1.4.0

src/Stack/Upload.hs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module Stack.Upload
1414
) where
1515

1616
import Control.Applicative
17-
import Control.Exception.Safe (bracket, handleIO, tryIO)
17+
import Control.Exception.Safe (handleIO, tryIO)
1818
import qualified Control.Exception as E
1919
import Control.Monad (void, when, unless)
2020
import Data.Aeson (FromJSON (..),
@@ -54,8 +54,8 @@ import Stack.Types.StringError
5454
import System.Directory (createDirectoryIfMissing,
5555
removeFile)
5656
import System.FilePath ((</>), takeFileName)
57-
import System.IO (hFlush, hGetEcho, hSetEcho,
58-
stdin, stdout)
57+
import System.IO (hFlush, stdout)
58+
import System.IO.Echo (withoutInputEcho)
5959

6060
-- | Username and password to log into Hackage.
6161
--
@@ -121,10 +121,8 @@ promptPassword :: IO Text
121121
promptPassword = do
122122
putStr "Hackage password: "
123123
hFlush stdout
124-
-- save/restore the terminal echoing status
125-
passwd <- bracket (hGetEcho stdin) (hSetEcho stdin) $ \_ -> do
126-
hSetEcho stdin False -- no echoing for entering the password
127-
fmap T.pack getLine
124+
-- save/restore the terminal echoing status (no echoing for entering the password)
125+
passwd <- withoutInputEcho $ fmap T.pack getLine
128126
putStrLn ""
129127
return passwd
130128

stack-7.10.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ nix:
1414
flags:
1515
stack:
1616
hide-dependency-versions: true
17+
mintty:
18+
win32-2-5: false
1719
extra-deps:
1820
- Cabal-1.24.2.0
1921
- th-utilities-0.2.0.1
@@ -34,3 +36,5 @@ extra-deps:
3436
- cryptohash-sha256-0.11.100.1
3537
- ed25519-0.0.5.0
3638
- hackage-security-0.5.2.2
39+
- echo-0.1.3
40+
- mintty-0.1.1

stack.cabal

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ library
205205
, cryptonite >= 0.19 && < 0.22
206206
, cryptonite-conduit >= 0.1 && < 0.3
207207
, directory >= 1.2.1.0 && < 1.4
208+
, echo >= 0.1.3 && < 0.2
208209
, either
209210
, errors < 2.2
210211
, exceptions >= 0.8.0.2
@@ -228,6 +229,7 @@ library
228229
, memory >= 0.13 && < 0.15
229230
, microlens >= 0.3.0.0
230231
, microlens-mtl
232+
, mintty >= 0.1.1
231233
, monad-control
232234
, monad-logger >= 0.3.13.1
233235
, monad-unlift < 0.3

stack.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ nix:
1414
flags:
1515
stack:
1616
hide-dependency-versions: true
17+
mintty:
18+
win32-2-5: false
1719
extra-deps:
20+
- mintty-0.1.1
1821
- store-0.4.1

0 commit comments

Comments
 (0)