Require either termios or termio, no more sgtty.
This commit is contained in:
14
configure
vendored
14
configure
vendored
@@ -14271,8 +14271,7 @@ 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
|
||||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||||
@@ -14328,12 +14327,12 @@ fi
|
|||||||
{ echo "$as_me:$LINENO: result: $ac_cv_sys_posix_termios" >&5
|
{ echo "$as_me:$LINENO: result: $ac_cv_sys_posix_termios" >&5
|
||||||
echo "${ECHO_T}$ac_cv_sys_posix_termios" >&6; }
|
echo "${ECHO_T}$ac_cv_sys_posix_termios" >&6; }
|
||||||
|
|
||||||
if test "$ac_cv_sys_posix_termios" = "yes"; then
|
if test "$ac_cv_sys_posix_termios" = "yes"; then
|
||||||
cat >>confdefs.h <<\_ACEOF
|
cat >>confdefs.h <<\_ACEOF
|
||||||
#define HAVE_TERMIOS_H 1
|
#define HAVE_TERMIOS_H 1
|
||||||
_ACEOF
|
_ACEOF
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
for ac_header in termio.h
|
for ac_header in termio.h
|
||||||
do
|
do
|
||||||
@@ -14475,11 +14474,14 @@ 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
|
||||||
|
|
||||||
|
13
configure.in
13
configure.in
@@ -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
|
AC_SYS_POSIX_TERMIOS
|
||||||
if test "$OS" != "ultrix"; then
|
if test "$ac_cv_sys_posix_termios" = "yes"; then
|
||||||
AC_SYS_POSIX_TERMIOS
|
AC_DEFINE(HAVE_TERMIOS_H)
|
||||||
if test "$ac_cv_sys_posix_termios" = "yes"; then
|
else
|
||||||
AC_DEFINE(HAVE_TERMIOS_H)
|
AC_CHECK_HEADERS(termio.h, [], [AC_MSG_ERROR([Must have either termios.h or termio.h to build sudo])])
|
||||||
else
|
|
||||||
AC_CHECK_HEADERS(termio.h)
|
|
||||||
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=""
|
||||||
|
@@ -44,9 +44,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>
|
|
||||||
# endif
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
@@ -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
|
||||||
|
104
src/term.c
104
src/term.c
@@ -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,29 +67,17 @@
|
|||||||
#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)
|
# define tcsetattr(f, a, t) ioctl(f, a, t)
|
||||||
# define tcsetattr(f, a, t) ioctl(f, a, t)
|
# undef TCSAFLUSH
|
||||||
# undef TCSAFLUSH
|
# 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
|
|
||||||
|
Reference in New Issue
Block a user