From 67ba123fd1fcb9a7699ae85f05f1229513322c1c Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 7 Aug 2012 00:10:26 -0400 Subject: [PATCH 1/2] terminal: seek when switching between reading and writing When a stdio stream is opened in update mode (e.g., "w+"), the C standard forbids switching between reading or writing without an intervening positioning function. Many implementations are lenient about this, but Solaris libc will flush the recently-read contents to the output buffer. In this instance, that meant writing the non-echoed password that the user just typed to the terminal. Fix it by inserting a no-op fseek between the read and write. The opposite direction (writing followed by reading) is also disallowed, but our intervening fflush is an acceptable positioning function for that alternative. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- compat/terminal.c | 1 + 1 file changed, 1 insertion(+) diff --git a/compat/terminal.c b/compat/terminal.c index 6d16c8fba0..bbb038dd01 100644 --- a/compat/terminal.c +++ b/compat/terminal.c @@ -59,6 +59,7 @@ char *git_terminal_prompt(const char *prompt, int echo) r = strbuf_getline(&buf, fh, '\n'); if (!echo) { + fseek(fh, SEEK_CUR, 0); putc('\n', fh); fflush(fh); } From 436783c95a59cca00a7cca1219666bb0af67cb81 Mon Sep 17 00:00:00 2001 From: Ben Walton Date: Mon, 6 Aug 2012 23:07:42 -0400 Subject: [PATCH 2/2] Enable HAVE_DEV_TTY for Solaris Now that git_terminal_prompt can cleanly interact with /dev/tty on Solaris, enable HAVE_DEV_TTY so that this code path is used for credential reading instead of relying on the crippled getpass(). Signed-off-by: Ben Walton Signed-off-by: Junio C Hamano --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 7c370ea57c..9472ff768c 100644 --- a/Makefile +++ b/Makefile @@ -909,6 +909,7 @@ ifeq ($(uname_S),SunOS) NO_MKSTEMPS = YesPlease NO_REGEX = YesPlease NO_FNMATCH_CASEFOLD = YesPlease + HAVE_DEV_TTY = YesPlease ifeq ($(uname_R),5.6) SOCKLEN_T = int NO_HSTRERROR = YesPlease