예제 #1
0
char *get_tty_password(const char *opt_message)
{
#ifdef HAVE_GETPASS
  char *passbuff;
#else /* ! HAVE_GETPASS */
  TERMIO org,tmp;
#endif /* HAVE_GETPASS */
  char buff[80];

  DBUG_ENTER("get_tty_password");

#ifdef HAVE_GETPASS
  passbuff = getpass(opt_message ? opt_message : "Enter password: "******"Enter password: ",stdout);
    fflush(stdout);
  }
#if defined(HAVE_TERMIOS_H)
  tcgetattr(fileno(stdin), &org);
  tmp = org;
  tmp.c_lflag &= ~(ECHO | ISIG | ICANON);
  tmp.c_cc[VMIN] = 1;
  tmp.c_cc[VTIME] = 0;
  tcsetattr(fileno(stdin), TCSADRAIN, &tmp);
  get_password(buff, sizeof(buff)-1, fileno(stdin), isatty(fileno(stdout)));
  tcsetattr(fileno(stdin), TCSADRAIN, &org);
#elif defined(HAVE_TERMIO_H)
  ioctl(fileno(stdin), (int) TCGETA, &org);
  tmp=org;
  tmp.c_lflag &= ~(ECHO | ISIG | ICANON);
  tmp.c_cc[VMIN] = 1;
  tmp.c_cc[VTIME]= 0;
  ioctl(fileno(stdin),(int) TCSETA, &tmp);
  get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stdout)));
  ioctl(fileno(stdin),(int) TCSETA, &org);
#else
  gtty(fileno(stdin), &org);
  tmp=org;
  tmp.sg_flags &= ~ECHO;
  tmp.sg_flags |= RAW;
  stty(fileno(stdin), &tmp);
  get_password(buff,sizeof(buff)-1,fileno(stdin),isatty(fileno(stdout)));
  stty(fileno(stdin), &org);
#endif
  if (isatty(fileno(stdout)))
    fputc('\n',stdout);
#endif /* HAVE_GETPASS */

  DBUG_RETURN(my_strdup(buff,MYF(MY_FAE)));
}
예제 #2
0
파일: term.c 프로젝트: glamrock/eBBS
init_tty()
{
    bcopy(&tty_state, &tty_new, sizeof(tty_new)) ;
    tty_new.sg_flags |= RAW ;
    tty_new.sg_flags &= ~(TANDEM|CBREAK|LCASE|ECHO|CRMOD) ;
    stty(1,&tty_new) ;
}
예제 #3
0
파일: getty.c 프로젝트: troglobit/finit
int getty(char *tty, speed_t speed, char *term, char *user)
{
	int fd;
	char name[30];

	/* Detach from initial controlling TTY */
	vhangup();

	fd = open(tty, O_RDWR);
	if (fd < 0)
		err(1, "Failed opening %s", tty);

	dup2(fd, STDIN_FILENO);
	dup2(fd, STDOUT_FILENO);
	dup2(fd, STDERR_FILENO);

	if (ioctl(STDIN_FILENO, TIOCSCTTY, 1) < 0)
		warn("Failed TIOCSCTTY");

	/* The getty process is responsible for the UTMP login record */
	utmp_set_login(tty, NULL);
	if (!user)
		do_getty(tty, name, sizeof(name));
	else
		strlcpy(name, user, sizeof(name));

	/* Set up TTY, re-enabling ISIG et al. */
	stty(fd, speed);
	close(fd);

	if (term && term[0])
		setenv("TERM", term, 1);

	return do_login(name);
}
예제 #4
0
파일: main.c 프로젝트: yrchen/Athena
static void init_tty()
{
  if (gtty(1, &tty_state) < 0)
  {
    fprintf(stderr, "gtty failed\n");
    exit(-1);
  }
  memcpy(&tty_new, &tty_state, sizeof(tty_new));

//#ifdef  LINUX

  tty_new.c_lflag &= ~(ICANON | ECHO | ISIG);
  tcsetattr(1, TCSANOW, &tty_new);
  restore_tty();

//#else

//  tty_new.sg_flags |= RAW;

//#ifdef  HP_UX
//  tty_new.sg_flags &= ~(O_HUPCL | O_XTABS | LCASE | ECHO | CRMOD);
//#else
//  tty_new.sg_flags &= ~(TANDEM | CBREAK | LCASE | ECHO | CRMOD);
//#endif

  stty(1, &tty_new);
//#endif
}
예제 #5
0
파일: more.c 프로젝트: pali/util-linux
static void set_tty(void)
{
	otty.c_lflag &= ~(ICANON | ECHO);
	otty.c_cc[VMIN] = 1;	/* read at least 1 char */
	otty.c_cc[VTIME] = 0;	/* no timeout */
	stty(fileno(stderr), &otty);
}
예제 #6
0
파일: open.c 프로젝트: andreiw/polaris
void
openpl(void)
{
	if ( isatty(fileno( stdout )) ) {
		shakehands = TRUE;
		fildes = open(TERMINAL, 0);
		gtty(fildes, &sarg);
		sarg.sg_flags = sarg.sg_flags | RAW;
		stty(fildes, &sarg);
		sarg.sg_flags = sarg.sg_flags & ~RAW;
	}
	else {
		shakehands = FALSE;
	}
	buffcount = 0;
	currentx = 0;
	currenty = 0;
	buffready(8);
	putchar(ESC);
	putchar(GRAPHIC);
	putchar(DISPLAY);
	putchar('c');
	putchar(ESC);
	putchar(GRAPHIC);
	putchar(PLOT);
	putchar(BINARY);
	space(0,0,720,360);
}
예제 #7
0
int raw()
{
	T(("raw() called"));

	SP->_raw = TRUE;
	SP->_cbreak = TRUE;
	SP->_nlmapping = TRUE;

#ifdef TERMIOS
	if(iexten == 0)
		iexten = cur_term->Nttyb.c_lflag & IEXTEN;
	cur_term->Nttyb.c_lflag &= ~(ICANON|ISIG|iexten);
	cur_term->Nttyb.c_iflag &= ~(INPCK|ISTRIP|IXON);
	cur_term->Nttyb.c_oflag &= ~(OPOST);
	cur_term->Nttyb.c_cc[VMIN] = 1;
	cur_term->Nttyb.c_cc[VTIME] = 0;
	if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
		return ERR;
	else
		return OK;
#else
	cur_term->Nttyb.sg_flags |= RAW;
	stty(cur_term->Filedes, &cur_term->Nttyb);
	return OK;
#endif
}
예제 #8
0
파일: n5.c 프로젝트: aksr/heirloom
void 
restore_tty (void)			/*restore tty settings from beginning*/
{

	if (ttysave[0] != -1) {
#ifdef	USG
		ttys.c_lflag = ttysave[0];
		tcsetattr(0, TCSADRAIN, &ttys);
#else
		ttys[0].sg_flags = ttysave[0];
		stty(0, &ttys[0]);
	}
	if (ttysave[1] != -1) {
		ttys[1].sg_flags = ttysave[1];
		stty(1, &ttys[1]);
#endif	/* USG */
	}
}
예제 #9
0
void testValues() {
    f = 2;
    
    struct sgttyb p;
    stty(anyint(), &p);

    //@ assert f == 2;
    //@ assert vacuous: \false;
}
예제 #10
0
파일: subr.c 프로젝트: dank101/4.4BSD-Alpha
outplot()
{
	spew(ESC);
	spew(ACK);
	spew(ESC);
	spew(ACK);
	fflush(stdout);
	stty (OUTF, &ITTY);
}
예제 #11
0
파일: close.c 프로젝트: andreiw/polaris
void
closepl(void)
{
	putchar('Z');
	fflush(stdout);
	if ( shakehands == TRUE ) {
		stty(fildes, &sarg);
		close(fildes);
	}
}
예제 #12
0
static void set_raw_tty(int mode)
{
	Terminal in_raw;

	if(mode != tty_mode && mode != -1) {
		if(!handlerIsSet) {
			/* Determine existing TTY settings */
			gtty (STDIN, &in_orig);
			need_tty_reset = 1;

			/* Restore original TTY settings on exit */
			atexit(cleanup_tty);
			handlerIsSet = 1;
		}


		setup_signal();
		signal (SIGALRM, (SIG_CAST) tty_time_out);
	
		/* Change STDIN settings to raw */

		gtty (STDIN, &in_raw);
		if(mode) {
#ifdef USE_SGTTY
			in_raw.sg_flags |= CBREAK;
#else
			in_raw.c_lflag &= ~ICANON;
			in_raw.c_cc[VMIN]=1;
			in_raw.c_cc[VTIME]=0;			
#endif
			stty (STDIN, &in_raw);
		} else {
#ifdef USE_SGTTY
			in_raw.sg_flags &= ~CBREAK;
#else
			in_raw.c_lflag |= ICANON;
#endif
			stty (STDIN, &in_raw);
		}
		tty_mode = mode;
		discard_input(STDIN);
	}
}
예제 #13
0
파일: cr_tty.c 프로젝트: dank101/4.2BSD
gettmode() {

	if (gtty(_tty_ch, &_tty) < 0)
		return;
	savetty();
	if (stty(_tty_ch, &_tty) < 0)
		_tty.sg_flags = _res_flg;
	ospeed = _tty.sg_ospeed;
	_res_flg = _tty.sg_flags;
	UPPERCASE = (_tty.sg_flags & LCASE) != 0;
	GT = ((_tty.sg_flags & XTABS) == 0);
	NONL = ((_tty.sg_flags & CRMOD) == 0);
	_tty.sg_flags &= ~XTABS;
	stty(_tty_ch, &_tty);
# ifdef DEBUG
	fprintf(outf, "GETTMODE: UPPERCASE = %s\n", UPPERCASE ? "TRUE":"FALSE");
	fprintf(outf, "GETTMODE: GT = %s\n", GT ? "TRUE" : "FALSE");
	fprintf(outf, "GETTMODE: NONL = %s\n", NONL ? "TRUE" : "FALSE");
	fprintf(outf, "GETTMODE: ospeed = %d\n", ospeed);
# endif
}
예제 #14
0
파일: getty.c 프로젝트: troglobit/finit
int sh(char *tty)
{
	int fd;
	char *arg0;
	char *args[2] = {
		NULL,
		NULL
	};
	size_t len;
	struct termios term;

	/* Detach from initial controlling TTY */
	vhangup();

	fd = open(tty, O_RDWR);
	if (fd < 0)
		err(1, "Failed opening %s", tty);

	dup2(fd, STDIN_FILENO);
	dup2(fd, STDOUT_FILENO);
	dup2(fd, STDERR_FILENO);

	if (ioctl(STDIN_FILENO, TIOCSCTTY, 1) < 0)
		warn("Failed TIOCSCTTY");

	/* The getty process is usually responsible for the UTMP login record */
	utmp_set_login(tty, NULL);

	/* Set up TTY, re-enabling ISIG et al. */
	stty(fd, B0);
	close(fd);

	/* Start /bin/sh as a login shell, i.e. with a prefix '-' */
	len = strlen(_PATH_BSHELL) + 2;
	arg0 = malloc(len);
	if (!arg0)
		err(1, "Failed allocating memory");
	snprintf(arg0, len, "-%s", _PATH_BSHELL);
	args[0] = arg0;

	/* Reenable Ctrl-D and Ctrl-C, and ... */
	if (!tcgetattr(STDIN_FILENO, &term)) {
		term.c_lflag    |= ISIG;
		term.c_cc[VEOF]  = CTL('D');
		term.c_cc[VINTR] = CTL('C');
		tcsetattr(STDIN_FILENO, TCSANOW, &term);
	}

	/* ... unblock signals in general */
	sig_unblock();

	return execv(_PATH_BSHELL, args);
}
예제 #15
0
파일: unix.c 프로젝트: axelmuhr/Helios-NG
ttclose()

{
#if	USG | HPUX | XENIX
	ioctl(0, TCSETA, &otermio);	/* restore terminal settings */
	fcntl(0, F_SETFL, kbdflgs);
#endif

#if     V7 | BSD | SUN
        stty(0, &ostate);
	ioctl(0, TIOCSETC, &otchars);	/* Place old character into K */
#endif
}
예제 #16
0
twdone(){
	obufp = obuf;
	oputs(t.twrest);
	flusho();
	if(pipeflg){
		close(ptid);
		wait(&waitf);
	}
	if(ttysave != -1) {
		ttys.sg_flags = ttysave;
		stty(1, &ttys);
	}
}
예제 #17
0
파일: ttymodes.c 프로젝트: akat1/impala
static void
set_ttymodes(TTY *modes)
{
# if USE_POSIX_TERMIOS
    fflush(stdout);
    tcsetattr(0, TCSAFLUSH, modes);
# else
#   if USE_TERMIO
      tcsetattr(0, TCSETAF, modes);
#   else /* USE_SGTTY */
      stty(0, modes);
#   endif
# endif
}
예제 #18
0
파일: n5.c 프로젝트: aksr/heirloom
void 
set_tty (void)			/*this replaces the use of bset and breset*/
{

#ifndef	USG			/*for research/BSD only, reset CRMOD*/
	if (ttysave[1] == -1)
		save_tty();
	if (ttysave[1] != -1) {
		ttys[1].sg_flags &= ~CRMOD;
		stty(1, &ttys[1]);
	}
#endif	/* USG */

}
예제 #19
0
파일: n5.c 프로젝트: aksr/heirloom
void 
echo_on (void)			/*restore ECHO after .rd in "-q" mode*/
{
	if (ttysave[0] == -1)
		return;

#ifdef	USG
	ttys.c_lflag |= ECHO_USG;
	tcsetattr(0, TCSADRAIN, &ttys);
#else
	ttys[0].sg_flags |= ECHO;
	stty(0, &ttys[0]);
#endif	/* USG */

}
예제 #20
0
파일: n5.c 프로젝트: aksr/heirloom
void 
echo_off (void)			/*turn off ECHO for .rd in "-q" mode*/
{
	if (ttysave[0] == -1)
		return;

#ifdef	USG
	ttys.c_lflag &= ~ECHO_USG;
	tcsetattr(0, TCSADRAIN, &ttys);
#else
	ttys[0].sg_flags &= ~ECHO;
	stty(0, &ttys[0]);
#endif	/* USG */

}
예제 #21
0
파일: more.c 프로젝트: pali/util-linux
static void reset_tty(void)
{
	if (no_tty)
		return;
	if (pstate) {
		/* putchar - if that isn't a macro */
		tputs(ULexit, fileno(stdout), ourputch);
		fflush(stdout);
		pstate = 0;
	}
	otty.c_lflag |= ICANON | ECHO;
	otty.c_cc[VMIN] = savetty0.c_cc[VMIN];
	otty.c_cc[VTIME] = savetty0.c_cc[VTIME];
	stty(fileno(stderr), &savetty0);
}
예제 #22
0
파일: getpass.c 프로젝트: aosm/fetchmail
static void disable_tty_echo(void) 
{
    /* turn off echo on the tty */
#if defined(HAVE_TCSETATTR)
    termb.c_lflag &= ~ECHO;
    tcsetattr(ttyfd, TCSAFLUSH, &termb);
#else
#if defined(HAVE_TERMIO_H)
    termb.c_lflag &= ~ECHO;
    ioctl(ttyfd, TCSETA, (char *) &termb);
#else  /* we HAVE_STTY */
    ttyb.sg_flags &= ~ECHO;
    stty(ttyfd, &ttyb);
#endif
#endif
}
예제 #23
0
파일: getpass.c 프로젝트: aosm/fetchmail
static void restore_tty_state(void)
{
    /* restore previous tty echo state */
#if defined(HAVE_TCSETATTR)
    termb.c_lflag = flags;
    tcsetattr(ttyfd, TCSAFLUSH, &termb);
#else
#if defined(HAVE_TERMIO_H)
    termb.c_lflag = flags;
    ioctl(ttyfd, TCSETA, (char *) &termb);
#else  /* we HAVE_STTY */
    ttyb.sg_flags = flags;
    stty(ttyfd, &ttyb);
#endif
#endif
}
예제 #24
0
openpl ()
{
	int reset();
		xnow = ynow = 0;
		OUTF = 1;
		printf("\r");
		gtty(OUTF, &ITTY);
		signal (2, reset);
		PTTY = ITTY;
		PTTY.sg_flags &= ~CRMOD;	/* don't map lf */
		stty(OUTF,&PTTY);
		/* initialize constants */
		xscale  = 4096./(HORZRESP * WIDTH);
		yscale = 4096 /(VERTRESP * HEIGHT);
		xoffset = OFFSET * HORZRESP;
		return;
}
예제 #25
0
int noecho()
{
	T(("noecho() called"));

	SP->_echo = FALSE;

#ifdef TERMIOS
	cur_term->Nttyb.c_lflag &= ~(ECHO);
	if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
		return ERR;
	else
		return OK;
#else
	cur_term->Nttyb.sg_flags &= ~ECHO;
	stty(cur_term->Filedes, &cur_term->Nttyb);
	return OK;
#endif
}
예제 #26
0
파일: tty.c 프로젝트: sng7ca/ygg
/* [...]
 * control terminal:
 * -- checks for STTY | GTTY error;
 * -- checks for !(STTY | GTTY) error;
 * -- clears STTY/GTTY before calling stty/gtty;
 */
static int ctltty(short mn, unsigned rq, unsigned arg)
{
	if (rq & STTY) {
		/* error -- cann't set & get */
		if (rq & GTTY)	/* avoid 2-check STTY && GTTY */
			return -1;
		/* set param */
		rq &= ~STTY;
		return stty(mn, rq, arg);
	}
	if (rq & GTTY) {
		/* get param */
		rq &= ~GTTY;
		return gtty(mn, rq, arg);
	}
	/* set/get not specified */
	return -1;
}
예제 #27
0
int nocbreak()
{
	T(("nocbreak() called"));

	SP->_cbreak = 0;

#ifdef TERMIOS
	cur_term->Nttyb.c_lflag |= ICANON;
	if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
		return ERR;
	else
		return OK;
#else
	cur_term->Nttyb.sg_flags &= ~CBREAK;
	stty(cur_term->Filedes, &cur_term->Nttyb);
	return OK;
#endif
}
예제 #28
0
int echo()
{
	T(("echo() called"));

	SP->_echo = TRUE;

#ifdef TERMIOS
	cur_term->Nttyb.c_lflag |= ECHO;
	if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
		return ERR;
	else
		return OK;
#else
	cur_term->Nttyb.sg_flags |= ECHO;
	stty(cur_term->Filedes, &cur_term->Nttyb);
	return OK;
#endif
}
예제 #29
0
int nonl()
{
	T(("nonl() called"));

	SP->_nl = SP->_nlmapping = FALSE;

#ifdef TERMIOS
	cur_term->Nttyb.c_iflag &= ~ICRNL;
	cur_term->Nttyb.c_oflag &= ~ONLCR;
	if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
		return ERR;
	else
		return OK;
#else
	cur_term->Nttyb.sg_flags &= ~CRMOD;
	stty(cur_term->Filedes, &cur_term->Nttyb);
	return OK;
#endif
}
예제 #30
0
int nl()
{
	T(("nl() called"));

	SP->_nl = TRUE;
	SP->_nlmapping = ! SP->_raw;

#ifdef TERMIOS
	cur_term->Nttyb.c_iflag |= IXON|ICRNL|IXOFF;
	cur_term->Nttyb.c_oflag |= OPOST|ONLCR;
	if((tcsetattr(cur_term->Filedes, TCSANOW, &cur_term->Nttyb)) == -1)
		return ERR;
	else
		return OK;
#else
	cur_term->Nttyb.sg_flags |= CRMOD;
	stty(cur_term->Filedes, &cur_term->Nttyb);
	return OK;
#endif
}