Bug#333138: [Pkg-shadow-devel] Bug#333138: chfn behaves bogusly when either fd 0, 1 or 2 is not a tty
Quoting Nicolas François ([EMAIL PROTECTED]): Hello, I don't think it is really a bug. The chfn man page indicates that If none of the options are selected, chfn operates in an interactive fashion, prompting the user with the current values for all of the fields. The interactive fashion means that it will hang and wait for the user's input. If you intend to use chfn in a script, you should use the [-f full_name] [-r room_no] [-w work_ph] [-h home_ph] [-o other] options. Funnily, stdin can still be used as input to chfn (and, I guess, chsh) as I showed in my example. The output is a bit ugly because the prompts are still sent to stdout, but it does the job. I propose closing this bug report.
Bug#333138: [Pkg-shadow-devel] Bug#333138: chfn behaves bogusly when either fd 0, 1 or 2 is not a tty
On Tue, Oct 11, 2005 at 06:40:02AM +0200, Christian Perrier wrote: Funnily, stdin can still be used as input to chfn (and, I guess, chsh) as I showed in my example. The output is a bit ugly because the prompts are still sent to stdout, but it does the job. I propose closing this bug report. No, there's a bug that needs fixing. And as said before the fix is as simple as adding an fflush call. Did you see the patch I just sent? -- Robert Millan -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#333138: [Pkg-shadow-devel] Bug#333138: chfn behaves bogusly when either fd 0, 1 or 2 is not a tty
retitle 333138 chfn/chsh: no prompt when stdout is a tty while stdin isn't severity 333138 wishlist thanks Hi! On Tue, Oct 11, 2005 at 10:48:36AM +0200, Robert Millan wrote: No, there's a bug that needs fixing. No, there's only 1 BTW very common issue which does not need any fixing IMNSHO. Interactive operation works, cmdline operation works. What else? Nobody promised operating in semi- or improperly emulated interactive modes (proper emulation is achieved with expect, python-expect, libexpect-perl or alike). Citing `man expect`: For example, here are some things Expect can do: ... * Run fsck, and in response to its questions, answer yes, no or give control back to you, based on predetermined criteria. ... * Carry environment variables, current directory, or any kind of information across rlogin, telnet, tip, su, chgrp, etc. There are a variety of reasons why the shell cannot perform these tasks. (Try, you’ll see.) All are possible with Expect. please consider what's stated there. And as said before the fix is as simple as adding an fflush call. Yes, it's my words. Did you see the patch I just sent? I personally (we all?) didn't see any patch from you, although, well, today _I_ am actually experimenting with shadow hacked with my own patches which among others include a workaround for this issue you suffer from. But this insertion of fflush() here and there without any defined plan etc. is just chaotic patching/fixing, it won't resolve the conceptual issues -- and even with shadow patched to its furthest limits, you would still require to use smth. expect-like for your purposes, becaue there are still awk/grep/sed (*) and other old good :/ Unix utils besides shadow suite... (*) http://suxx.kak-sam.to/awkgrep.jpg -- WBR, xrgtn
Bug#333138: [Pkg-shadow-devel] Bug#333138: chfn behaves bogusly when either fd 0, 1 or 2 is not a tty
On Tue, Oct 11, 2005 at 08:47:08PM +0300, Alexander Gattin wrote: No, there's only 1 BTW very common issue which does not need any fixing IMNSHO. Interactive operation works, cmdline operation works. What else? Nobody promised operating in semi- or improperly emulated interactive modes (proper emulation is achieved with expect, python-expect, libexpect-perl or alike). I don't understand why you mention expect. This program is intended to solve more complex problems than this one. I personally (we all?) didn't see any patch from you, It's in the bug log. But it's just a one-liner based on the code lines you quoted, so it's not really worth searching for it.. although, well, today _I_ am actually experimenting with shadow hacked with my own patches which among others include a workaround for this issue you suffer from. That's nice to hear. But this insertion of fflush() here and there without any defined plan etc. is just chaotic patching/fixing, it won't resolve the conceptual issues -- and even with shadow patched to its furthest limits, you would still require to use smth. expect-like for your purposes, becaue there are still awk/grep/sed (*) and other old good :/ Unix utils besides shadow suite... These utilities are general purpose and not specificaly intended to obtain input from the user. In case a script invokes them with this purpose, it is the responsability of such script to ensure that question prompts are flushed out before reading from stdin is attempted. (*) http://suxx.kak-sam.to/awkgrep.jpg Heh, funny. -- Robert Millan --- shadow-4.0.12.old/libmisc/fields.c 2005-06-14 22:27:35.0 +0200 +++ shadow-4.0.12/libmisc/fields.c 2005-10-11 07:58:57.0 +0200 @@ -71,6 +71,7 @@ maxsize = sizeof (newf); printf (\t%s [%s]: , prompt, buf); + fflush (stdout); if (fgets (newf, maxsize, stdin) != newf) return;
Bug#333138: chfn behaves bogusly when either fd 0, 1 or 2 is not a tty
Package: passwd Version: 1:4.0.3-39 Severity: normal aragorn:~# chfn rmh Changing the user information for rmh Enter the new value, or press ENTER for the default Full Name [rmh]:^C aragorn:~# cat | chfn rmh Changing the user information for rmh Enter the new value, or press ENTER for the default ^C aragorn:~# chfn rmh | cat ^C aragorn:~# chfn rmh 21 | cat ^C aragorn:~# -- System Information: Debian Release: testing/unstable APT prefers unstable APT policy: (500, 'unstable') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.11-1-k7 Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ANSI_X3.4-1968) (ignored: LC_ALL set to C) Versions of packages passwd depends on: ii libc6 2.3.5-6GNU C Library: Shared libraries an ii libpam-modules0.76-23Pluggable Authentication Modules f ii libpam0g 0.76-23Pluggable Authentication Modules l ii login 1:4.0.3-39 system login tools passwd recommends no packages. -- debconf information excluded -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#333138: [Pkg-shadow-devel] Bug#333138: chfn behaves bogusly when either fd 0, 1 or 2 is not a tty
Package: passwd Version: 1:4.0.3-39 Severity: normal Testing with 4.0.13 (next version). Should be the same with 4.0.12 (the version in unstable and Wednesday in testing): aragorn:~# chfn rmh Changing the user information for rmh Enter the new value, or press ENTER for the default Full Name [rmh]:^C aragorn:~# cat | chfn rmh Changing the user information for rmh Enter the new value, or press ENTER for the default ^C If you enter something here, even on more than 1 line, then chfn will do what's advertised and change informations: [EMAIL PROTECTED]:/tmp# useradd krabs [EMAIL PROTECTED]:/tmp# cat | LC_ALL=C chfn krabs Changing the user information for krabs Enter the new value, or press ENTER for the default Captain Krabs Krusty Krab Spongebob boss and Carlo boss as well THE big boss Full Name []: Room Number []: Work Phone []: Home Phone []: Other []: [EMAIL PROTECTED]:/tmp# grep krabs /etc/passwd krabs:x:1004:100:Captain Krabs,Krusty Krab,Spongebob boss,and Carlo boss as well,THE big boss:/home/krabs:/bin/sh The display is a bit clumsy because the prompts are sent to stdout but you can get it clean: [EMAIL PROTECTED]:/tmp# cat | LC_ALL=C chfn krabs /dev/null Captain Krabs Krusty Krab Spongebob boss and Carlo boss as well THE big boss [EMAIL PROTECTED]:/tmp# aragorn:~# chfn rmh | cat ^C No idea what you're actually trying to do here... aragorn:~# chfn rmh 21 | cat ^C Same here So, I actually fail to see what is exactly the bug you report. -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#333138: [Pkg-shadow-devel] Bug#333138: chfn behaves bogusly when either fd 0, 1 or 2 is not a tty
On Mon, Oct 10, 2005 at 08:08:01PM +0200, Christian Perrier wrote: Package: passwd Version: 1:4.0.3-39 Severity: normal Testing with 4.0.13 (next version). Should be the same with 4.0.12 (the version in unstable and Wednesday in testing): Sorry, my sid is a bit outdated :) aragorn:~# chfn rmh Changing the user information for rmh Enter the new value, or press ENTER for the default Full Name [rmh]:^C aragorn:~# cat | chfn rmh Changing the user information for rmh Enter the new value, or press ENTER for the default ^C If you enter something here, even on more than 1 line, then chfn will do what's advertised and change informations: Ok, but why wasn't Full Name [rmh]: printed? they're just standard characters; they don't really need a terminal to be output. I suspect there's a bogus isatty() check or something. aragorn:~# chfn rmh | cat ^C No idea what you're actually trying to do here... aragorn:~# chfn rmh 21 | cat ^C Same here 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 21 | 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 (unless you were using set -x of course). Thanks, -- Robert Millan -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#333138: [Pkg-shadow-devel] Bug#333138: chfn behaves bogusly when either fd 0, 1 or 2 is not a tty
Hello, I don't think it is really a bug. The chfn man page indicates that If none of the options are selected, chfn operates in an interactive fashion, prompting the user with the current values for all of the fields. The interactive fashion means that it will hang and wait for the user's input. If you intend to use chfn in a script, you should use the [-f full_name] [-r room_no] [-w work_ph] [-h home_ph] [-o other] options. Kind Regards, -- Nekral -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]