[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnulib] getpass echoes on many systems
From: |
Bruno Haible |
Subject: |
Re: [Bug-gnulib] getpass echoes on many systems |
Date: |
Thu, 2 Oct 2003 19:08:49 +0200 |
User-agent: |
KMail/1.5 |
Larry Jones wrote:
> They may have been closed and reopened.
Or they might have been closed and not reopened... I've looked at the
manual page of getpass() on Solaris, and it doesn't assume anything about
stdin or stderr. So I think we shouldn't document it either, and then,
to avoid any wrong behaviour when the caller has
fclose (stdin)
and getpass's fopen() call returns stdin, it's safest to just add a boolean
variable to the code.
2003-10-02 Bruno Haible <address@hidden>
* getpass.c (getpass): Don't assume that fopen() always returns a
stream != stdin. Reported by Larry Jones <address@hidden>.
*** getpass.c 1 Oct 2003 11:11:02 -0000 1.5
--- getpass.c 2 Oct 2003 17:05:30 -0000
***************
*** 39,44 ****
--- 39,45 ----
getpass (const char *prompt)
{
FILE *in, *out;
+ int fopen_succeeded;
struct termios s, t;
int tty_changed;
static char *buf;
***************
*** 53,61 ****
{
in = stdin;
out = stderr;
}
else
! out = in;
/* Turn echoing off if it is on now. */
--- 54,66 ----
{
in = stdin;
out = stderr;
+ fopen_succeeded = 0;
}
else
! {
! out = in;
! fopen_succeeded = 1;
! }
/* Turn echoing off if it is on now. */
***************
*** 104,110 ****
if (tty_changed)
(void) tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &s);
! if (in != stdin)
/* We opened the terminal; now close it. */
fclose (in);
--- 109,115 ----
if (tty_changed)
(void) tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &s);
! if (fopen_succeeded)
/* We opened the terminal; now close it. */
fclose (in);
- Re: [Bug-gnulib] getpass echoes on many systems, Bruno Haible, 2003/10/01
- Re: [Bug-gnulib] getpass echoes on many systems, Paul Eggert, 2003/10/01
- Re: [Bug-gnulib] getpass echoes on many systems, Larry Jones, 2003/10/01
- Re: [Bug-gnulib] getpass echoes on many systems, Paul Eggert, 2003/10/01
- Re: [Bug-gnulib] getpass echoes on many systems, Larry Jones, 2003/10/01
- Re: [Bug-gnulib] getpass echoes on many systems, Paul Eggert, 2003/10/02
- Re: [Bug-gnulib] getpass echoes on many systems, Larry Jones, 2003/10/02
- Re: [Bug-gnulib] getpass echoes on many systems, Bruno Haible, 2003/10/02
- Re: [Bug-gnulib] getpass echoes on many systems, Larry Jones, 2003/10/02
- Re: [Bug-gnulib] getpass echoes on many systems,
Bruno Haible <=
- Re: [Bug-gnulib] getpass echoes on many systems, Larry Jones, 2003/10/02
- Re: [Bug-gnulib] getpass echoes on many systems, Paul Eggert, 2003/10/02