From: Todd C. Miller Date: Fri, 12 Mar 2010 16:45:57 +0000 (-0500) Subject: Require either termios or termio, no more sgtty. X-Git-Tag: SUDO_1_8_0~830 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0795ef846ca9d41b6cb249a1dcbea43342b7f8ab;p=sudo Require either termios or termio, no more sgtty. --- diff --git a/configure b/configure index 82524ba66..df304bcb0 100755 --- a/configure +++ b/configure @@ -14271,8 +14271,7 @@ fi done -if test "$OS" != "ultrix"; then - { echo "$as_me:$LINENO: checking POSIX termios" >&5 +{ echo "$as_me:$LINENO: checking POSIX termios" >&5 echo $ECHO_N "checking POSIX termios... $ECHO_C" >&6; } if test "${ac_cv_sys_posix_termios+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -14328,12 +14327,12 @@ fi { echo "$as_me:$LINENO: result: $ac_cv_sys_posix_termios" >&5 echo "${ECHO_T}$ac_cv_sys_posix_termios" >&6; } - if test "$ac_cv_sys_posix_termios" = "yes"; then - cat >>confdefs.h <<\_ACEOF +if test "$ac_cv_sys_posix_termios" = "yes"; then + cat >>confdefs.h <<\_ACEOF #define HAVE_TERMIOS_H 1 _ACEOF - else +else for ac_header in termio.h do @@ -14475,11 +14474,14 @@ if test `eval echo '${'$as_ac_Header'}'` = yes; then #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF +else + { { echo "$as_me:$LINENO: error: Must have either termios.h or termio.h to build sudo" >&5 +echo "$as_me: error: Must have either termios.h or termio.h to build sudo" >&2;} + { (exit 1); exit 1; }; } fi done - fi fi if test ${with_logincap-'no'} != "no"; then diff --git a/configure.in b/configure.in index 7230243d5..ad504f025 100644 --- a/configure.in +++ b/configure.in @@ -1827,14 +1827,11 @@ AC_HEADER_STDC AC_HEADER_DIRENT AC_HEADER_TIME AC_CHECK_HEADERS(malloc.h paths.h utime.h netgroup.h sys/sockio.h sys/bsdtypes.h sys/select.h sys/stropts.h) -dnl ultrix termio/termios are broken -if test "$OS" != "ultrix"; then - AC_SYS_POSIX_TERMIOS - if test "$ac_cv_sys_posix_termios" = "yes"; then - AC_DEFINE(HAVE_TERMIOS_H) - else - AC_CHECK_HEADERS(termio.h) - fi +AC_SYS_POSIX_TERMIOS +if test "$ac_cv_sys_posix_termios" = "yes"; then + AC_DEFINE(HAVE_TERMIOS_H) +else + AC_CHECK_HEADERS(termio.h, [], [AC_MSG_ERROR([Must have either termios.h or termio.h to build sudo])]) fi if test ${with_logincap-'no'} != "no"; then AC_CHECK_HEADERS(login_cap.h, [LOGINCAP_USAGE='[[-c class|-]] '; LCMAN="" diff --git a/src/lbuf.c b/src/lbuf.c index d63433230..8f4687633 100644 --- a/src/lbuf.c +++ b/src/lbuf.c @@ -44,9 +44,7 @@ #ifdef HAVE_TERMIOS_H # include #else -# ifdef HAVE_TERMIO_H -# include -# endif +# include #endif #include "compat.h" diff --git a/src/script.c b/src/script.c index 8d8858054..96b319f61 100644 --- a/src/script.c +++ b/src/script.c @@ -25,11 +25,7 @@ #ifdef HAVE_TERMIOS_H # include #else -# ifdef HAVE_TERMIO_H -# include -# else -# include -# endif /* HAVE_TERMIO_H */ +# include #endif /* HAVE_TERMIOS_H */ #include #ifdef HAVE_SYS_SELECT_H diff --git a/src/term.c b/src/term.c index bb5156b94..993f53fd9 100644 --- a/src/term.c +++ b/src/term.c @@ -40,12 +40,7 @@ #ifdef HAVE_TERMIOS_H # include #else -# ifdef HAVE_TERMIO_H -# include -# else -# include -# include -# endif /* HAVE_TERMIO_H */ +# include #endif /* HAVE_TERMIOS_H */ #include "sudo.h" @@ -72,29 +67,17 @@ #endif /* - * Compat macros for non-termios systems. + * Emulate POSIX termios using termio */ #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 TCSADRAIN -# define TCSADRAIN TCSETAW -# else /* SGTTY */ -# 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 TCSADRAIN -# define TCSADRAIN TIOCSETN -# endif /* 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 TCSADRAIN +# define TCSADRAIN TCSETAW #endif /* HAVE_TERMIOS_H */ typedef struct termios sudo_term_t; @@ -134,8 +117,6 @@ term_noecho(int fd) return(0); } -#if defined(HAVE_TERMIOS_H) || defined(HAVE_TERMIO_H) - int term_raw(int fd, int opost, int isig) { @@ -199,68 +180,3 @@ term_copy(int src, int dst, int opost) return(0); return(1); } - -#else /* SGTTY */ - -int -term_raw(int fd, int onlcr) -{ - if (!changed && ioctl(fd, TIOCGETP, &oterm) != 0) - return(0); - (void) memcpy(&term, &oterm, sizeof(term)); - /* Set terminal to raw mode */ - CLR(term.c_lflag, ECHO); - SET(term.sg_flags, RAW); - /* Retain NL to NLCR conversion if onlcr flag set. */ - if (onlcr) - SET(term.sg_flags, CRMOD); - if (ioctl(fd, TIOCSETP, &term) == 0) { - changed = 1; - return(1); - } - return(0); -} - -int -term_cbreak(int fd) -{ - if (!changed && ioctl(fd, TIOCGETP, &oterm) != 0) - return(0); - (void) memcpy(&term, &oterm, sizeof(term)); - /* Set terminal to half-cooked mode */ - CLR(term.c_lflag, ECHO); - SET(term.sg_flags, CBREAK); - if (ioctl(fd, TIOCSETP, &term) == 0) { - term_erase = term.sg_erase; - term_kill = term.sg_kill; - changed = 1; - return(1); - } - return(0); -} - -int -term_copy(int src, int dst, int onlcr) -{ - struct sgttyb b; - struct tchars tc; - struct ltchars lc; - int l, lb; - - if (ioctl(src, TIOCGETP, &b) != 0 || ioctl(src, TIOCGETC, &tc) != 0 || - ioctl(src, TIOCGETD, &l) != 0 || ioctl(src, TIOCGLTC, &lc) != 0 || - ioctl(src, TIOCLGET, &lb)) { - return(0); - } - /* Do not convert line endings from NL to NLCR. */ - if (!onlcr) - CLR(b.sg_flags, CRMOD); - if (ioctl(dst, TIOCSETP, &b) != 0 || ioctl(dst, TIOCSETC, &tc) != 0 || - ioctl(dst, TIOCSLTC, &lc) != 0 || ioctl(dst, TIOCLSET, &lb) != 0 || - ioctl(dst, TIOCSETD, &l) != 0) { - return(0); - } - return(1); -} - -#endif