mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-22 09:57:41 +00:00
Add cfmakeraw() for systems without it.
This commit is contained in:
parent
1b10ac03ea
commit
4690d3ecf6
1
MANIFEST
1
MANIFEST
@ -109,6 +109,7 @@ lib/util/aix.c
|
|||||||
lib/util/arc4random.c
|
lib/util/arc4random.c
|
||||||
lib/util/arc4random.h
|
lib/util/arc4random.h
|
||||||
lib/util/arc4random_uniform.c
|
lib/util/arc4random_uniform.c
|
||||||
|
lib/util/cfmakeraw.c
|
||||||
lib/util/chacha_private.h
|
lib/util/chacha_private.h
|
||||||
lib/util/closefrom.c
|
lib/util/closefrom.c
|
||||||
lib/util/digest.c
|
lib/util/digest.c
|
||||||
|
@ -82,6 +82,9 @@
|
|||||||
/* Define to 1 to enable BSM audit support. */
|
/* Define to 1 to enable BSM audit support. */
|
||||||
#undef HAVE_BSM_AUDIT
|
#undef HAVE_BSM_AUDIT
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `cfmakeraw' function. */
|
||||||
|
#undef HAVE_CFMAKERAW
|
||||||
|
|
||||||
/* Define to 1 if you have the `clock_gettime' function. */
|
/* Define to 1 if you have the `clock_gettime' function. */
|
||||||
#undef HAVE_CLOCK_GETTIME
|
#undef HAVE_CLOCK_GETTIME
|
||||||
|
|
||||||
|
26
configure
vendored
26
configure
vendored
@ -19638,6 +19638,32 @@ done
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
for ac_func in cfmakeraw
|
||||||
|
do :
|
||||||
|
ac_fn_c_check_func "$LINENO" "cfmakeraw" "ac_cv_func_cfmakeraw"
|
||||||
|
if test "x$ac_cv_func_cfmakeraw" = xyes; then :
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define HAVE_CFMAKERAW 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
case " $LIBOBJS " in
|
||||||
|
*" cfmakeraw.$ac_objext "* ) ;;
|
||||||
|
*) LIBOBJS="$LIBOBJS cfmakeraw.$ac_objext"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
for _sym in sudo_cfmakeraw; do
|
||||||
|
COMPAT_EXP="${COMPAT_EXP}${_sym}
|
||||||
|
"
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
for ac_func in getgrouplist
|
for ac_func in getgrouplist
|
||||||
do :
|
do :
|
||||||
ac_fn_c_check_func "$LINENO" "getgrouplist" "ac_cv_func_getgrouplist"
|
ac_fn_c_check_func "$LINENO" "getgrouplist" "ac_cv_func_getgrouplist"
|
||||||
|
@ -2574,6 +2574,10 @@ case "$host_os" in
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
AC_CHECK_FUNCS([cfmakeraw], [], [
|
||||||
|
AC_LIBOBJ(cfmakeraw)
|
||||||
|
SUDO_APPEND_COMPAT_EXP(sudo_cfmakeraw)
|
||||||
|
])
|
||||||
AC_CHECK_FUNCS([getgrouplist], [], [
|
AC_CHECK_FUNCS([getgrouplist], [], [
|
||||||
case "$host_os" in
|
case "$host_os" in
|
||||||
aix*)
|
aix*)
|
||||||
|
@ -392,7 +392,13 @@ int getdomainname(char *, size_t);
|
|||||||
struct passwd;
|
struct passwd;
|
||||||
struct stat;
|
struct stat;
|
||||||
struct timespec;
|
struct timespec;
|
||||||
|
struct termios;
|
||||||
|
|
||||||
|
#ifndef HAVE_CFMAKERAW
|
||||||
|
__dso_public void sudo_cfmakeraw(struct termios *term);
|
||||||
|
# undef cfmakeraw
|
||||||
|
# define cfmakeraw(_a) sudo_cfmakeraw((_a))
|
||||||
|
#endif /* HAVE_CFMAKERAW */
|
||||||
#ifndef HAVE_CLOSEFROM
|
#ifndef HAVE_CLOSEFROM
|
||||||
__dso_public void sudo_closefrom(int);
|
__dso_public void sudo_closefrom(int);
|
||||||
# undef closefrom
|
# undef closefrom
|
||||||
|
59
lib/util/cfmakeraw.c
Normal file
59
lib/util/cfmakeraw.c
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-License-Identifier: ISC
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Todd C. Miller <Todd.Miller@sudo.ws>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is an open source non-commercial project. Dear PVS-Studio, please check it.
|
||||||
|
* PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <termios.h>
|
||||||
|
|
||||||
|
#include "sudo_compat.h"
|
||||||
|
|
||||||
|
/* Non-standard termios input flags */
|
||||||
|
#ifndef IUCLC
|
||||||
|
# define IUCLC 0
|
||||||
|
#endif
|
||||||
|
#ifndef IMAXBEL
|
||||||
|
# define IMAXBEL 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Non-standard termios local flags */
|
||||||
|
#ifndef IEXTEN
|
||||||
|
# define IEXTEN 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set termios to raw mode (BSD extension).
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
sudo_cfmakeraw(struct termios *term)
|
||||||
|
{
|
||||||
|
/* Set terminal to raw mode */
|
||||||
|
CLR(term->c_iflag,
|
||||||
|
IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IMAXBEL|IUCLC);
|
||||||
|
CLR(term->c_oflag, OPOST);
|
||||||
|
CLR(term->c_lflag, ECHO|ECHONL|ICANON|ISIG|IEXTEN);
|
||||||
|
CLR(term->c_cflag, CSIZE|PARENB);
|
||||||
|
SET(term->c_cflag, CS8);
|
||||||
|
term->c_cc[VMIN] = 1;
|
||||||
|
term->c_cc[VTIME] = 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user