mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-31 14:25:15 +00:00
now works on sgi's
This commit is contained in:
24
getpass.c
24
getpass.c
@@ -22,9 +22,6 @@ static char sccsid[] = "@(#)getpass.c based on 5.3 (Berkeley) 9/22/88";
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sgtty.h>
|
||||
#ifdef sgi
|
||||
#include <curses.h>
|
||||
#endif
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/signal.h>
|
||||
#include <stdio.h>
|
||||
@@ -33,13 +30,21 @@ char *
|
||||
getpass(prompt)
|
||||
char *prompt;
|
||||
{
|
||||
#if defined(sgi)
|
||||
struct termio ttyb;
|
||||
#else
|
||||
struct sgttyb ttyb;
|
||||
#endif
|
||||
register int ch;
|
||||
register char *p;
|
||||
FILE *fp, *outfp;
|
||||
long omask;
|
||||
int fd_tmp;
|
||||
#if defined(sgi)
|
||||
tcflag_t svflagval;
|
||||
#else
|
||||
int svflagval;
|
||||
#endif
|
||||
#define PASSWD_LEN 8
|
||||
static char buf[PASSWD_LEN + 1];
|
||||
|
||||
@@ -53,11 +58,19 @@ getpass(prompt)
|
||||
fp = stdin;
|
||||
}
|
||||
|
||||
#if defined(sgi)
|
||||
(void)ioctl(fileno(fp), TCGETA, &ttyb);
|
||||
svflagval = ttyb.c_lflag;
|
||||
ttyb.c_lflag &= ~ECHO;
|
||||
omask = sigblock(sigmask(SIGINT));
|
||||
(void)ioctl(fileno(fp), TCSETA, &ttyb);
|
||||
#else
|
||||
(void)ioctl(fileno(fp), TIOCGETP, &ttyb);
|
||||
svflagval = ttyb.sg_flags;
|
||||
ttyb.sg_flags &= ~ECHO;
|
||||
omask = sigblock(sigmask(SIGINT));
|
||||
(void)ioctl(fileno(fp), TIOCSETP, &ttyb);
|
||||
#endif
|
||||
|
||||
fprintf(outfp, "%s", prompt);
|
||||
rewind(outfp); /* implied flush */
|
||||
@@ -67,8 +80,13 @@ getpass(prompt)
|
||||
*p = '\0';
|
||||
(void)write(fileno(outfp), "\n", 1);
|
||||
|
||||
#if defined(sgi)
|
||||
ttyb.c_lflag = svflagval;
|
||||
(void)ioctl(fileno(fp), TCSETA, &ttyb);
|
||||
#else
|
||||
ttyb.sg_flags = svflagval;
|
||||
(void)ioctl(fileno(fp), TIOCSETP, &ttyb);
|
||||
#endif
|
||||
(void)sigsetmask(omask);
|
||||
if (fp != stdin)
|
||||
(void)fclose(fp);
|
||||
|
Reference in New Issue
Block a user