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

Re: [PATCH] Enable HAVE_DEV_TTY for Solaris

From
Jeff King <peff@peff.net>
Date
Aug 8, 2012, 21:05 UTC
Message-ID
<20120808210531.GA12822@sigill.intra.peff.net>
In-Reply-To
<CABPQNSaUCEDU4+2N63n0k_XwSXOP_iFZG3GEYSPSBPcSVV8wRQ@mail.gmail.com>
On Wed, Aug 08, 2012 at 04:13:03PM +0200, Erik Faye-Lund wrote:
Show 19 quoted lines
> On Tue, Aug 7, 2012 at 6:10 AM, Jeff King <peff@peff.net> wrote:
> > 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.
> 
> My Windows-patches for git_terminal_prompt would probably also solve
> this problem. Instead of opening a read-write handle to /dev/tty, they
> open two handles to the terminal instead; one for reading and one for
> writing. This is because the terminal cannot be opened in read-write
> mode on Windows (we need to open "CONIN$" and "CONOUT$" separately).

Yeah, it would solve it, although it means opening /dev/tty twice (which is probably not a big deal, though). I'm fine if we go that way in the long run to share implementations, but let's treat it as a separate topic. This fix is an obvious one-liner, and is just fixing me being stupid about actually following the C standard. So it's a no-brainer for as a maintenance fix.

Show 6 quoted lines
> You can have a look at the series here if you're interested:
> https://github.com/kusma/git/tree/work/terminal-cleanup
> 
> That last patch is the reason why I haven't submitted the series yet,
> but perhaps some of the preparatory patches could be worth-while for
> other platforms in the mean time?

Yeah, that last patch is really gross. There's no explanation of the race issue, so I'll refrain from thinking about it until you are ready to post a series. :)

-Peff
Previous: Erik Faye-Lund
Message 27 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.