[client] apply patch from Ilya Tumaykin for terminal setting type

This commit also fixes a 'possible use of uninitialized value' warning from gcc for
the old_c_lflag variable.
This commit is contained in:
Michael Rash 2013-07-24 22:44:08 -04:00
parent 5ec4998aaa
commit ea9d6a0fdc

View File

@ -130,13 +130,13 @@ read_passwd_from_stream(FILE *stream)
char* char*
getpasswd(const char *prompt, int fd) getpasswd(const char *prompt, int fd)
{ {
char *ptr; char *ptr = NULL;
FILE *fp; FILE *fp = NULL;
#ifndef WIN32 #ifndef WIN32
sigset_t sig, old_sig; sigset_t sig, old_sig;
struct termios ts; struct termios ts;
int old_c_lflag; tcflag_t old_c_lflag = 0;
#else #else
/* Force stdin on windows. */ /* Force stdin on windows. */
fd = 0; fd = 0;
@ -197,11 +197,14 @@ getpasswd(const char *prompt, int fd)
_putch(PW_CR_CHAR); _putch(PW_CR_CHAR);
_putch(PW_LF_CHAR); _putch(PW_LF_CHAR);
#else #else
/* Reset terminal settings if(! FD_IS_VALID(fd))
*/ {
fputs("\n", fp); /* Reset terminal settings
ts.c_lflag = old_c_lflag; */
tcsetattr(fileno(fp), TCSAFLUSH, &ts); fputs("\n", fp);
ts.c_lflag = old_c_lflag;
tcsetattr(fileno(fp), TCSAFLUSH, &ts);
}
#endif #endif
fclose(fp); fclose(fp);