Bug#333138: [Pkg-shadow-devel] chfn behaves bogusly when either fd 0, 1 or 2 is not a tty

Alexander Gattin xrgtn at yandex.ru
Mon Oct 10 23:22:51 UTC 2005


Hi!

On Mon, Oct 10, 2005 at 09:28:24PM +0200, Robert Millan wrote:
> This was just a test.  When I found the problem,
> I was running chfn as part of a script, and
> redirecting stderr of the parent shell like this:
> 
>   script 2>&1 | tee /tmp/log
> 
> In this situation, this bug is very annoying, because your script
> suddenly hangs and you don't know what's going on

chfn/chsh without cmdline parameters work interactively
so you _should_ use ptys/expect-like program to script
them (or use cmdline parameters). It's common issue
with a lot of Unix utils.

for example, here:
> aragorn:~# chfn rmh | cat
> ^C
> aragorn:~# chfn rmh 2>&1 | cat
> ^C
you see The Classical Effect of Pipe Being
Block-Buffered. I.e. without using smth. like
fsync()/fflush() you won't see output until pipe is
closed gracefully or buffer (4096 usually) gets full.

WRT "Full Name [rmh]:" prompt being or not being
printed depending on type of stdin, that's another
issue though, but also unrelated to "passwd" pkg IMHO.

P.S.
Difference between:
> aragorn:~# chfn rmh
> Changing the user information for rmh
> Enter the new value, or press ENTER for the default
>         Full Name [rmh]:^C
and the next:
> aragorn:~# cat | chfn rmh
> Changing the user information for rmh
> Enter the new value, or press ENTER for the default
> ^C
must be contained just in the following code:
> 	printf ("\t%s [%s]: ", prompt, buf);
> 	if (fgets (newf, maxsize, stdin) != newf)

As you can see no "bogus" isatty() is there.

P.P.S. I think we should close the bug.
-- 
WBR,
xrgtn




More information about the Pkg-shadow-devel mailing list