bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] getpass echoes on many systems


From: Larry Jones
Subject: Re: [Bug-gnulib] getpass echoes on many systems
Date: Wed, 1 Oct 2003 15:14:31 -0400 (EDT)

Paul Eggert writes:
> 
> The C standard isn't the issue here, surely.  The problem is the
> interaction between the input/output streams and applying system calls
> like tcsetattr to the underlying file descriptors.  This matter is
> covered by POSIX, not by the C standard.

No, *this* problem is the interaction between input and output on the
same stream, which *is* covered by the C standard.  In the usual case,
getpass() opens a stream to /dev/tty, writes a prompt to the stream,
flushes the stream, reads the password from the stream, then writes a
newline to the stream.  It's reading the password and then immediately
writing the newline that's the problem -- most stdio implementations use
the same buffer for input as for output so switching directions without
flushing the buffer leads to confusion.  The only method provided by the
C standard for doing that (on an input stream) is to call a file
positioning function.  I don't see anything in POSIX that supplements
that.

The interaction between a stream and its underlying file descriptor is a
different issue.  As I read the relevant section of POSIX, the existing
code is OK because tcsetattr doesn't affect the file offset.

-Larry Jones

Mom must've put my cape in the wrong drawer. -- Calvin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]