Date: Fri, 29 Jan 2010 01:16:47 +0100 From: Cyrille Lefevre <cyrille.lefevre-lists@laposte.net> To: jhell <jhell@DataIX.net> Cc: freebsd-standards@freebsd.org, freebsd-stable@freebsd.org, Glen Barber <glen.j.barber@gmail.com> Subject: Re: su password prompt to stdout instead of /dev/tty Message-ID: <4B6228EF.5050400@laposte.net> In-Reply-To: <4B60B734.7060803@laposte.net> References: <4B5CEC53.3090402@laposte.net> <20100125025744.GA94378@orion.hsd1.pa.comcast.net> <alpine.BSF.2.00.1001242243460.72774@pragry.qngnvk.ybpny> <4B60B734.7060803@laposte.net>
index | next in thread | previous in thread | raw e-mail
Cyrille Lefevre a écrit :
>
>
> sorry, repost to -standards w/ an s !
>
> jhell a écrit :
>> On Sun, 24 Jan 2010 21:57, glen.j.barber@ wrote:
>>>
>>> Cyrille Lefevre wrote:
>>>>
>>>> su password prompt is displayed to *stdout* instead of */dev/tty*.
>>>>
>>>> # su user
>>>> $ su root -c date > /tmp/date 2>&1
>>>> (nothing displayed)
>>>> $ cat /tmp/date
>>>> Password:su: Sorry
>>>> $ uname -a
>>>> FreeBSD freebsd8.my.domain 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Sat Nov
>>>> 21 15:48:17 UTC 2009
>>>> root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC i386
>>>>
>>>> I suppose this is a getpass() problem ?
>>>>
>>
>> This is intended operation as su(1) may not always be affiliated with
>> a TTY. This leaves it open for a script to chat with much like what
>> samba does with its passwd chat mechanism.
>
> just to feed the debate :
>
> aix 5.2 : prompt to tty
> hp-ux : prompt to stderr
> netbsd : prompt to tty
> solaris 9 : prompt to stderr
> solaris 10 : prompt to tty
> openbsd : prompt to tty
> ubuntu : prompt to stderr
>
> freebsd is the only one which prompt to stdout !
> IMHO, it should at least prompt to stderr if not tty...
> and report errors to stderr as usually.
>
> CC -standards
found it, the guilty is prompt() in
src/contrib/openpam/lib/openpam_ttyconv.c and not getpass() as usual...
=> fputs(msg, stdout);
which should be, IMHO, something like :
FILE *ttyp;
ttyp = fopen("/dev/tty", "w")
if (!stdtty)
ttyp = isatty(fileno(stderr)) ? stderr : stdout;
fputs(msg, ttyp);
or, at least :
fputs(msg, stderr);
Regards,
Cyrille Lefevre
--
mailto:Cyrille.Lefevre-lists@laposte.net
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4B6228EF.5050400>
