Require either termios or termio, no more sgtty.

This commit is contained in:
Todd C. Miller
2010-03-12 11:45:57 -05:00
parent cb8696d67e
commit 0795ef846c
5 changed files with 25 additions and 116 deletions

6
configure vendored
View File

@@ -14271,7 +14271,6 @@ fi
done 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; } echo $ECHO_N "checking POSIX termios... $ECHO_C" >&6; }
if test "${ac_cv_sys_posix_termios+set}" = set; then if test "${ac_cv_sys_posix_termios+set}" = set; then
@@ -14475,12 +14474,15 @@ if test `eval echo '${'$as_ac_Header'}'` = yes; then
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
_ACEOF _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 fi
done done
fi fi
fi
if test ${with_logincap-'no'} != "no"; then if test ${with_logincap-'no'} != "no"; then
for ac_header in login_cap.h for ac_header in login_cap.h

View File

@@ -1827,14 +1827,11 @@ AC_HEADER_STDC
AC_HEADER_DIRENT AC_HEADER_DIRENT
AC_HEADER_TIME 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) 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 AC_SYS_POSIX_TERMIOS
if test "$ac_cv_sys_posix_termios" = "yes"; then if test "$ac_cv_sys_posix_termios" = "yes"; then
AC_DEFINE(HAVE_TERMIOS_H) AC_DEFINE(HAVE_TERMIOS_H)
else else
AC_CHECK_HEADERS(termio.h) AC_CHECK_HEADERS(termio.h, [], [AC_MSG_ERROR([Must have either termios.h or termio.h to build sudo])])
fi
fi fi
if test ${with_logincap-'no'} != "no"; then if test ${with_logincap-'no'} != "no"; then
AC_CHECK_HEADERS(login_cap.h, [LOGINCAP_USAGE='[[-c class|-]] '; LCMAN="" AC_CHECK_HEADERS(login_cap.h, [LOGINCAP_USAGE='[[-c class|-]] '; LCMAN=""

View File

@@ -44,10 +44,8 @@
#ifdef HAVE_TERMIOS_H #ifdef HAVE_TERMIOS_H
# include <termios.h> # include <termios.h>
#else #else
# ifdef HAVE_TERMIO_H
# include <termio.h> # include <termio.h>
#endif #endif
#endif
#include "compat.h" #include "compat.h"
#include "alloc.h" #include "alloc.h"

View File

@@ -25,11 +25,7 @@
#ifdef HAVE_TERMIOS_H #ifdef HAVE_TERMIOS_H
# include <termios.h> # include <termios.h>
#else #else
# ifdef HAVE_TERMIO_H
# include <termio.h> # include <termio.h>
# else
# include <sgtty.h>
# endif /* HAVE_TERMIO_H */
#endif /* HAVE_TERMIOS_H */ #endif /* HAVE_TERMIOS_H */
#include <sys/ioctl.h> #include <sys/ioctl.h>
#ifdef HAVE_SYS_SELECT_H #ifdef HAVE_SYS_SELECT_H

View File

@@ -40,12 +40,7 @@
#ifdef HAVE_TERMIOS_H #ifdef HAVE_TERMIOS_H
# include <termios.h> # include <termios.h>
#else #else
# ifdef HAVE_TERMIO_H
# include <termio.h> # include <termio.h>
# else
# include <sgtty.h>
# include <sys/ioctl.h>
# endif /* HAVE_TERMIO_H */
#endif /* HAVE_TERMIOS_H */ #endif /* HAVE_TERMIOS_H */
#include "sudo.h" #include "sudo.h"
@@ -72,10 +67,9 @@
#endif #endif
/* /*
* Compat macros for non-termios systems. * Emulate POSIX termios using termio
*/ */
#ifndef HAVE_TERMIOS_H #ifndef HAVE_TERMIOS_H
# ifdef HAVE_TERMIO_H
# undef termios # undef termios
# define termios termio # define termios termio
# define tcgetattr(f, t) ioctl(f, TCGETA, t) # define tcgetattr(f, t) ioctl(f, TCGETA, t)
@@ -84,17 +78,6 @@
# define TCSAFLUSH TCSETAF # define TCSAFLUSH TCSETAF
# undef TCSADRAIN # undef TCSADRAIN
# define TCSADRAIN TCSETAW # 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 */
#endif /* HAVE_TERMIOS_H */ #endif /* HAVE_TERMIOS_H */
typedef struct termios sudo_term_t; typedef struct termios sudo_term_t;
@@ -134,8 +117,6 @@ term_noecho(int fd)
return(0); return(0);
} }
#if defined(HAVE_TERMIOS_H) || defined(HAVE_TERMIO_H)
int int
term_raw(int fd, int opost, int isig) term_raw(int fd, int opost, int isig)
{ {
@@ -199,68 +180,3 @@ term_copy(int src, int dst, int opost)
return(0); return(0);
return(1); 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