/*1* SPDX-License-Identifier: ISC2*3* Copyright (c) 2019-2020 Todd C. Miller <[email protected]>4*5* Permission to use, copy, modify, and distribute this software for any6* purpose with or without fee is hereby granted, provided that the above7* copyright notice and this permission notice appear in all copies.8*9* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES10* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF11* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR12* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES13* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN14* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF15* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.16*/1718#include <config.h>1920#include <termios.h>2122#include <sudo_compat.h>2324/* Non-standard termios input flags */25#ifndef IUCLC26# define IUCLC 027#endif28#ifndef IMAXBEL29# define IMAXBEL 030#endif3132/* Non-standard termios local flags */33#ifndef IEXTEN34# define IEXTEN 035#endif3637/*38* Set termios to raw mode (BSD extension).39*/40void41sudo_cfmakeraw(struct termios *term)42{43/* Set terminal to raw mode */44CLR(term->c_iflag,45IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON|IMAXBEL|IUCLC);46CLR(term->c_oflag, OPOST);47CLR(term->c_lflag, ECHO|ECHONL|ICANON|ISIG|IEXTEN);48CLR(term->c_cflag, CSIZE|PARENB);49SET(term->c_cflag, CS8);50term->c_cc[VMIN] = 1;51term->c_cc[VTIME] = 0;52}535455