git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] Avoid crippled getpass function on Solaris

From
Tay Ray Chuan <rctay89@gmail.com>
Date
Aug 7, 2012, 02:18 UTC
Message-ID
<CALUzUxoKHSw_8U0S_jmrhW3fWF0OPL39+4q7385-_34xq8MXqQ@mail.gmail.com>
In-Reply-To
<20120807003541.GA18219@sigill.intra.peff.net>
On Tue, Aug 7, 2012 at 8:35 AM, Jeff King <peff@peff.net> wrote:
Show 33 quoted lines
> Subject: [PATCH] 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 immediately followed by
> reading) is also disallowed, but our fflush immediately
> after printing the prompt is sufficient to satisfy the
> standard.
> ---
>  compat/terminal.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/compat/terminal.c b/compat/terminal.c
> index 6d16c8f..bbb038d 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);
>         }
This works. Ben, does this work for you too?
-- 
Cheers,
Ray Chuan
Previous: Jeff KingNext: Ben Walton
Message 19 of 27 in “Avoid crippled getpass function on Solaris”
  1. Avoid crippled getpass function on SolarisBen Walton, Aug 5, 2012
  2. Tay Ray ChuanAug 6, 2012
  3. Ben WaltonAug 6, 2012
  4. Junio C HamanoAug 6, 2012
  5. Ben WaltonAug 6, 2012
  6. Jeff KingAug 6, 2012
  7. Junio C HamanoAug 6, 2012
  8. Ben WaltonAug 6, 2012
  9. Jeff KingAug 6, 2012
  10. Ben WaltonAug 6, 2012
  11. Jeff KingAug 6, 2012
  12. Ben WaltonAug 6, 2012
  13. Jeff KingAug 6, 2012
  14. Ben WaltonAug 6, 2012
  15. Jeff KingAug 7, 2012
  16. Andreas SchwabAug 6, 2012
  17. Jeff KingAug 7, 2012
  18. Jeff KingAug 7, 2012
  19. Tay Ray ChuanAug 7, 2012
  20. Ben WaltonAug 7, 2012
  21. Enable HAVE_DEV_TTY for SolarisBen Walton, Aug 7, 2012
  22. Junio C HamanoAug 7, 2012
  23. Jeff KingAug 7, 2012
  24. Jeff KingAug 7, 2012
  25. Ben WaltonAug 7, 2012
  26. Erik Faye-LundAug 8, 2012
  27. Jeff KingAug 8, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.