[uClibc]getpass() prints password after hitting enter
Axel Barnitzke
barney at xkontor.com
Thu Apr 4 10:12:44 UTC 2002
Hi Eric,
the following patch solves the problem for me:
--- getpass.c 11 Jan 2001 11:42:17 -0000 1.2
+++ getpass.c 4 Apr 2002 10:16:46 -0000
@@ -45,7 +45,7 @@ getpass (prompt)
/* Try to write to and read from the terminal if we can.
If we can't open the terminal, use stderr and stdin. */
- in = fopen ("/dev/tty", "w+");
+ in = fopen ("/dev/tty", "r+");
if (in == NULL)
{
in = stdin;
@@ -61,7 +61,7 @@ getpass (prompt)
/* Save the old one. */
s = t;
/* Tricky, tricky. */
- t.c_lflag &= ~(ECHO|ISIG);
+ t.c_lflag &= ~(ECHO|ICANON|ISIG);
tty_changed = (tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &t)
== 0);
}
else
Erik Andersen wrote:
> On Thu Apr 04, 2002 at 11:05:55AM +0200, Axel Barnitzke wrote:
>
>>Hi Eric,
>>
>>try this and you will see the problem:
>>
>>#include <stdlib.h>
>>#include <unistd.h>
>>int main(void)
>>{
>> char *foo, *bar;
>> foo=getpass( "Please enter a password:");
>> bar=getpass( "Re-enter new password:");
>> exit(EXIT_SUCCESS);
>>}
>>
>>I guess the TCSAFLUSH attribute in tcsetattr in combination
>>with the new stdio design is the bad guy in this case but
>>I don't know much about terminal settings.
>>
>
> Ok, yes I see it now. Thanks!
>
> -Erik
>
> --
> Erik B. Andersen http://codepoet-consulting.com/
> --This message was written using 73% post-consumer electrons--
>
>
>
>
>
--
-- Barney
--------------------------------------
++ axel (barney) barnitzke
++ it consultant
++ xkontor IT solutions
fon :: +49 40 4100959-0
email :: mailto:barney at xkontor.com
More information about the uClibc
mailing list