=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/sudo/Attic/tgetpass.c,v retrieving revision 1.12 retrieving revision 1.13 diff -c -r1.12 -r1.13 *** src/usr.bin/sudo/Attic/tgetpass.c 2007/10/17 04:26:05 1.12 --- src/usr.bin/sudo/Attic/tgetpass.c 2007/10/17 15:40:54 1.13 *************** *** 70,76 **** #include "sudo.h" #ifndef lint ! __unused static const char rcsid[] = "$Sudo: tgetpass.c,v 1.111.2.4 2007/10/08 16:01:10 millert Exp $"; #endif /* lint */ #ifndef TCSASOFT --- 70,76 ---- #include "sudo.h" #ifndef lint ! __unused static const char rcsid[] = "$Sudo: tgetpass.c,v 1.111.2.5 2007/10/17 15:39:43 millert Exp $"; #endif /* lint */ #ifndef TCSASOFT *************** *** 89,114 **** #endif /* ! * Abstract method of getting at the term flags. */ ! #undef TERM ! #undef tflags ! #ifdef HAVE_TERMIOS_H ! # define TERM termios ! # define tflags c_lflag ! # define term_getattr(f, t) tcgetattr(f, t) ! # define term_setattr(f, t) tcsetattr(f, TCSADRAIN|TCSASOFT, t) ! #else # ifdef HAVE_TERMIO_H ! # define TERM termio ! # define tflags c_lflag ! # define term_getattr(f, t) ioctl(f, TCGETA, t) ! # define term_setattr(f, t) ioctl(f, TCSETAF, t) # else ! # define TERM sgttyb ! # define tflags sg_flags ! # define term_getattr(f, t) ioctl(f, TIOCGETP, t) ! # define term_setattr(f, t) ioctl(f, TIOCSETP, t) # endif /* HAVE_TERMIO_H */ #endif /* HAVE_TERMIOS_H */ --- 89,124 ---- #endif /* ! * QNX 6 (at least) has issues with TCSAFLUSH. */ ! #ifdef __QNX__ ! #undef TCSAFLUSH ! #define TCSAFLUSH TCSADRAIN ! #endif ! ! /* ! * Compat macros for non-termios systems. ! */ ! #ifndef HAVE_TERMIOS_H # ifdef HAVE_TERMIO_H ! # undef termios ! # define termios termio ! # define tcgetattr(f, t) ioctl(f, TCGETA, t) ! # define tcsetattr(f, a, t) ioctl(f, a, t) ! # undef TCSAFLUSH ! # define TCSAFLUSH TCSETAF ! # undef TCSANOW ! # define TCSANOW TCSETA # else ! # undef termios ! # define termios sgttyb ! # define c_lflag sg_flags ! # define tcgetattr(f, t) ioctl(f, TIOCGETP, t) ! # define tcsetattr(f, a, t) ioctl(f, a, t) ! # undef TCSAFLUSH ! # define TCSAFLUSH TIOCSETP ! # undef TCSANOW ! # define TCSANOW TIOCSETN # endif /* HAVE_TERMIO_H */ #endif /* HAVE_TERMIOS_H */ *************** *** 128,134 **** { sigaction_t sa, savealrm, saveint, savehup, savequit, saveterm; sigaction_t savetstp, savettin, savettou; ! struct TERM term, oterm; char *pass; static char buf[SUDO_PASS_MAX + 1]; int input, output, save_errno; --- 138,144 ---- { sigaction_t sa, savealrm, saveint, savehup, savequit, saveterm; sigaction_t savetstp, savettin, savettou; ! struct termios term, oterm; char *pass; static char buf[SUDO_PASS_MAX + 1]; int input, output, save_errno; *************** *** 162,175 **** (void) sigaction(SIGTTOU, &sa, &savettou); /* Turn echo off/on as specified by flags. */ ! if (term_getattr(input, &oterm) == 0) { (void) memcpy(&term, &oterm, sizeof(term)); if (!ISSET(flags, TGP_ECHO)) ! CLR(term.tflags, (ECHO | ECHONL)); #ifdef VSTATUS term.c_cc[VSTATUS] = _POSIX_VDISABLE; #endif ! (void) term_setattr(input, &term); } else { memset(&term, 0, sizeof(term)); memset(&oterm, 0, sizeof(oterm)); --- 172,185 ---- (void) sigaction(SIGTTOU, &sa, &savettou); /* Turn echo off/on as specified by flags. */ ! if (tcgetattr(input, &oterm) == 0) { (void) memcpy(&term, &oterm, sizeof(term)); if (!ISSET(flags, TGP_ECHO)) ! CLR(term.c_lflag, ECHO|ECHONL); #ifdef VSTATUS term.c_cc[VSTATUS] = _POSIX_VDISABLE; #endif ! (void) tcsetattr(input, TCSAFLUSH|TCSASOFT, &term); } else { memset(&term, 0, sizeof(term)); memset(&oterm, 0, sizeof(oterm)); *************** *** 186,198 **** alarm(0); save_errno = errno; ! if (!ISSET(term.tflags, ECHO)) (void) write(output, "\n", 1); } /* Restore old tty settings and signals. */ ! if (memcmp(&term, &oterm, sizeof(term)) != 0) ! (void) term_setattr(input, &oterm); (void) sigaction(SIGALRM, &savealrm, NULL); (void) sigaction(SIGINT, &saveint, NULL); (void) sigaction(SIGHUP, &savehup, NULL); --- 196,211 ---- alarm(0); save_errno = errno; ! if (!ISSET(term.c_lflag, ECHO)) (void) write(output, "\n", 1); } /* Restore old tty settings and signals. */ ! if (memcmp(&term, &oterm, sizeof(term)) != 0) { ! while (tcsetattr(input, TCSANOW|TCSASOFT, &oterm) == -1 && ! errno == EINTR) ! continue; ! } (void) sigaction(SIGALRM, &savealrm, NULL); (void) sigaction(SIGINT, &saveint, NULL); (void) sigaction(SIGHUP, &savehup, NULL);