su password prompt to stdout instead of /dev/tty

Oliver Fromme olli at
Fri Jan 29 08:02:38 UTC 2010

Cyrille Lefevre wrote:
 > found it, the guilty is prompt() in 
 > src/contrib/openpam/lib/openpam_ttyconv.c and not getpass() as usual...

Are you sure this affects su(1) only?

 > => 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);

As long as it's still possible to easily redirect the prompt
on the command line, it's fine with me.
Right now I can do this in a script:

echo -n "$myprompt: " ; su $somerole >/dev/null ...

If that doesn't work anymore, I'll complain.  ;-)

Best regards

Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:

"With sufficient thrust, pigs fly just fine.  However, this
is not necessarily a good idea.  It is hard to be sure where
they are going to land, and it could be dangerous sitting
under them as they fly overhead." -- RFC 1925

More information about the freebsd-standards mailing list